test_class.declarator: NETWORK_ID = 42L
test_class.modifier: private static final
test_class.original_string: private static final long NETWORK_ID = 42L;
test_class.type: long
test_class.var_name: NETWORK_ID
test_class.declarator: physnetdao = mock(PhysicalNetworkDao.class)
test_class.original_string: PhysicalNetworkDao physnetdao = mock(PhysicalNetworkDao.class);
test_class.type: PhysicalNetworkDao
test_class.var_name: physnetdao
test_class.declarator: nvpdao = mock(NiciraNvpDao.class)
test_class.original_string: NiciraNvpDao nvpdao = mock(NiciraNvpDao.class);
test_class.type: NiciraNvpDao
test_class.var_name: nvpdao
test_class.declarator: dcdao = mock(DataCenterDao.class)
test_class.original_string: DataCenterDao dcdao = mock(DataCenterDao.class);
test_class.type: DataCenterDao
test_class.var_name: dcdao
test_class.declarator: nosd = mock(NetworkOfferingServiceMapDao.class)
test_class.original_string: NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
test_class.type: NetworkOfferingServiceMapDao
test_class.var_name: nosd
test_class.declarator: agentmgr = mock(AgentManager.class)
test_class.original_string: AgentManager agentmgr = mock(AgentManager.class);
test_class.type: AgentManager
test_class.var_name: agentmgr
test_class.declarator: netmgr = mock(NetworkOrchestrationService.class)
test_class.original_string: NetworkOrchestrationService netmgr = mock(NetworkOrchestrationService.class);
test_class.type: NetworkOrchestrationService
test_class.var_name: netmgr
test_class.declarator: netmodel = mock(NetworkModel.class)
test_class.original_string: NetworkModel netmodel = mock(NetworkModel.class);
test_class.type: NetworkModel
test_class.var_name: netmodel
test_class.declarator: hostdao = mock(HostDao.class)
test_class.original_string: HostDao hostdao = mock(HostDao.class);
test_class.type: HostDao
test_class.var_name: hostdao
test_class.declarator: netdao = mock(NetworkDao.class)
test_class.original_string: NetworkDao netdao = mock(NetworkDao.class);
test_class.type: NetworkDao
test_class.var_name: netdao
test_class.declarator: guru
test_class.original_string: NiciraNvpGuestNetworkGuru guru;
test_class.type: NiciraNvpGuestNetworkGuru
test_class.var_name: guru
test_class.file: plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
test_class.identifier: NiciraNvpGuestNetworkGuruTest
test_case.body: @Test
      public void testImplementWithCidr() throws InsufficientVirtualNetworkCapacityException {
          final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
          when(physnetdao.findById((Long)any())).thenReturn(physnet);
          when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
          when(physnet.getId()).thenReturn(NETWORK_ID);
  
          final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
          when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
          when(device.getId()).thenReturn(1L);
  
          final NetworkOffering offering = mock(NetworkOffering.class);
          when(offering.getId()).thenReturn(NETWORK_ID);
          when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
          when(offering.getGuestType()).thenReturn(GuestType.Isolated);
  
          when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
  
          mock(DeploymentPlan.class);
  
          final NetworkVO network = mock(NetworkVO.class);
          when(network.getName()).thenReturn("testnetwork");
          when(network.getState()).thenReturn(State.Implementing);
          when(network.getGateway()).thenReturn("10.1.1.1");
          when(network.getCidr()).thenReturn("10.1.1.0/24");
          when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
  
          final DeployDestination dest = mock(DeployDestination.class);
  
          final DataCenter dc = mock(DataCenter.class);
          when(dest.getDataCenter()).thenReturn(dc);
  
          final HostVO niciraHost = mock(HostVO.class);
          when(hostdao.findById(anyLong())).thenReturn(niciraHost);
          when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
          when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
          when(niciraHost.getId()).thenReturn(NETWORK_ID);
  
          when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
          final Domain dom = mock(Domain.class);
          when(dom.getName()).thenReturn("domain");
          final Account acc = mock(Account.class);
          when(acc.getAccountName()).thenReturn("accountname");
          final ReservationContext res = mock(ReservationContext.class);
          when(res.getDomain()).thenReturn(dom);
          when(res.getAccount()).thenReturn(acc);
  
          final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
          when(answer.getResult()).thenReturn(true);
          when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
          when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
  
          final Network implementednetwork = guru.implement(network, offering, dest, res);
          assertTrue(implementednetwork != null);
          assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
          assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
          verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
      }
test_case.class_method_signature: NiciraNvpGuestNetworkGuruTest.testImplementWithCidr()
test_case.full_signature: @Test public void testImplementWithCidr()
test_case.identifier: testImplementWithCidr
test_case.invocations: mock thenReturn when findById any thenReturn when getIsolationMethods asList thenReturn when getId mock thenReturn when listByPhysicalNetwork asList thenReturn when getId mock thenReturn when getId thenReturn when getTrafficType thenReturn when getGuestType thenReturn when areServicesSupportedByNetworkOffering mock mock thenReturn when getName thenReturn when getState thenReturn when getGateway thenReturn when getCidr thenReturn when getPhysicalNetworkId mock mock thenReturn when getDataCenter mock thenReturn when findById anyLong thenReturn when getDetail thenReturn when getDetail thenReturn when getId thenReturn when findPhysicalNetworkId anyLong any any mock thenReturn when getName mock thenReturn when getAccountName mock thenReturn when getDomain thenReturn when getAccount mock thenReturn when getResult thenReturn when getLogicalSwitchUuid thenReturn when easySend eq any implement assertTrue assertTrue equals getCidr assertTrue equals getGateway easySend verify times eq any
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testImplementWithCidr()
focal_class.declarator: MAX_NAME_LENGTH = 40
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_NAME_LENGTH = 40;
focal_class.type: int
focal_class.var_name: MAX_NAME_LENGTH
focal_class.declarator: s_logger = LoggerFactory.getLogger(NiciraNvpGuestNetworkGuru.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger s_logger = LoggerFactory.getLogger(NiciraNvpGuestNetworkGuru.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: networkModel
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected NetworkModel networkModel;
focal_class.type: NetworkModel
focal_class.var_name: networkModel
focal_class.declarator: networkDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected NetworkDao networkDao;
focal_class.type: NetworkDao
focal_class.var_name: networkDao
focal_class.declarator: zoneDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected DataCenterDao zoneDao;
focal_class.type: DataCenterDao
focal_class.var_name: zoneDao
focal_class.declarator: physicalNetworkDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected PhysicalNetworkDao physicalNetworkDao;
focal_class.type: PhysicalNetworkDao
focal_class.var_name: physicalNetworkDao
focal_class.declarator: accountDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected AccountDao accountDao;
focal_class.type: AccountDao
focal_class.var_name: accountDao
focal_class.declarator: niciraNvpDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected NiciraNvpDao niciraNvpDao;
focal_class.type: NiciraNvpDao
focal_class.var_name: niciraNvpDao
focal_class.declarator: hostDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected HostDao hostDao;
focal_class.type: HostDao
focal_class.var_name: hostDao
focal_class.declarator: resourceMgr
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected ResourceManager resourceMgr;
focal_class.type: ResourceManager
focal_class.var_name: resourceMgr
focal_class.declarator: agentMgr
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected AgentManager agentMgr;
focal_class.type: AgentManager
focal_class.var_name: agentMgr
focal_class.declarator: hostDetailsDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected HostDetailsDao hostDetailsDao;
focal_class.type: HostDetailsDao
focal_class.var_name: hostDetailsDao
focal_class.declarator: ntwkOfferingSrvcDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected NetworkOfferingServiceMapDao ntwkOfferingSrvcDao;
focal_class.type: NetworkOfferingServiceMapDao
focal_class.var_name: ntwkOfferingSrvcDao
focal_class.file: plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
focal_class.identifier: NiciraNvpGuestNetworkGuru
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.NiciraNvpGuestNetworkGuru()
focal_class.full_signature: public  NiciraNvpGuestNetworkGuru()
focal_class.identifier: NiciraNvpGuestNetworkGuru
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  NiciraNvpGuestNetworkGuru()
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork)
focal_class.full_signature: @Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork)
focal_class.identifier: canHandle
focal_class.modifiers: @Override protected
focal_class.parameters: (final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork)
focal_class.return: boolean
focal_class.signature: boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner)
focal_class.full_signature: @Override public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner)
focal_class.identifier: design
focal_class.modifiers: @Override public
focal_class.parameters: (final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner)
focal_class.return: Network
focal_class.signature: Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.checkThatLogicalSwitchExists(final Network userSpecified, final NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.full_signature: private void checkThatLogicalSwitchExists(final Network userSpecified, final NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.identifier: checkThatLogicalSwitchExists
focal_class.modifiers: private
focal_class.parameters: (final Network userSpecified, final NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.return: void
focal_class.signature: void checkThatLogicalSwitchExists(final Network userSpecified, final NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.lswitchExists(String lswitchUuid, NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.full_signature: private boolean lswitchExists(String lswitchUuid, NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.identifier: lswitchExists
focal_class.modifiers: private
focal_class.parameters: (String lswitchUuid, NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.return: boolean
focal_class.signature: boolean lswitchExists(String lswitchUuid, NiciraNvpDeviceVO niciraNvpDeviceVO)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_class.full_signature: @Override public Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_class.identifier: implement
focal_class.modifiers: @Override public
focal_class.parameters: (final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_class.return: Network
focal_class.signature: Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.reserve(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context)
focal_class.full_signature: @Override public void reserve(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context)
focal_class.identifier: reserve
focal_class.modifiers: @Override public
focal_class.parameters: (final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context)
focal_class.return: void
focal_class.signature: void reserve(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.release(final NicProfile nic, final VirtualMachineProfile vm, final String reservationId)
focal_class.full_signature: @Override public boolean release(final NicProfile nic, final VirtualMachineProfile vm, final String reservationId)
focal_class.identifier: release
focal_class.modifiers: @Override public
focal_class.parameters: (final NicProfile nic, final VirtualMachineProfile vm, final String reservationId)
focal_class.return: boolean
focal_class.signature: boolean release(final NicProfile nic, final VirtualMachineProfile vm, final String reservationId)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.shutdown(final NetworkProfile profile, final NetworkOffering offering)
focal_class.full_signature: @Override public void shutdown(final NetworkProfile profile, final NetworkOffering offering)
focal_class.identifier: shutdown
focal_class.modifiers: @Override public
focal_class.parameters: (final NetworkProfile profile, final NetworkOffering offering)
focal_class.return: void
focal_class.signature: void shutdown(final NetworkProfile profile, final NetworkOffering offering)
focal_class.class_method_signature: NiciraNvpGuestNetworkGuru.trash(final Network network, final NetworkOffering offering)
focal_class.full_signature: @Override public boolean trash(final Network network, final NetworkOffering offering)
focal_class.identifier: trash
focal_class.modifiers: @Override public
focal_class.parameters: (final Network network, final NetworkOffering offering)
focal_class.return: boolean
focal_class.signature: boolean trash(final Network network, final NetworkOffering offering)
focal_class.superclass: extends GuestNetworkGuru
focal_method.body: @Override
      public Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
              throws InsufficientVirtualNetworkCapacityException {
          assert network.getState() == State.Implementing : "Why are we implementing " + network;
  
          final long dcId = dest.getDataCenter().getId();
  
          Long physicalNetworkId = network.getPhysicalNetworkId();
  
          // physical network id can be null in Guest Network in Basic zone, so locate the physical network
          if (physicalNetworkId == null) {
              physicalNetworkId = networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
          }
  
          final NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(),
                  State.Allocated, network.getDataCenterId(), physicalNetworkId, offering.getRedundantRouter());
  
          if (network.getGateway() != null) {
              implemented.setGateway(network.getGateway());
          }
  
          if (network.getCidr() != null) {
              implemented.setCidr(network.getCidr());
          }
  
          // Name is either the given name or the uuid
          String name = network.getName();
          if (name == null || name.isEmpty()) {
              name = ((NetworkVO) network).getUuid();
          }
          if (name.length() > MAX_NAME_LENGTH) {
              name = name.substring(0, MAX_NAME_LENGTH - 1);
          }
  
          final List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(physicalNetworkId);
          if (devices.isEmpty()) {
              s_logger.error("No NiciraNvp Controller on physical network " + physicalNetworkId);
              return null;
          }
          final NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
          final HostVO niciraNvpHost = hostDao.findById(niciraNvpDevice.getHostId());
          hostDao.loadDetails(niciraNvpHost);
          final String transportzoneuuid = niciraNvpHost.getDetail("transportzoneuuid");
          final String transportzoneisotype = niciraNvpHost.getDetail("transportzoneisotype");
  
          final CreateLogicalSwitchCommand cmd = new CreateLogicalSwitchCommand(transportzoneuuid, transportzoneisotype, name, context.getDomain().getName() + "-"
                  + context.getAccount().getAccountName());
          final CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
  
          if (answer == null || !answer.getResult()) {
              s_logger.error("CreateLogicalSwitchCommand failed");
              return null;
          }
  
          try {
              implemented.setBroadcastUri(new URI("lswitch", answer.getLogicalSwitchUuid(), null));
              implemented.setBroadcastDomainType(BroadcastDomainType.Lswitch);
              s_logger.info("Implemented OK, network linked to  = " + implemented.getBroadcastUri().toString());
          } catch (final URISyntaxException e) {
              s_logger.error("Unable to store logical switch id in broadcast uri, uuid = " + implemented.getUuid(), e);
              return null;
          }
  
          return implemented;
      }
focal_method.class_method_signature: NiciraNvpGuestNetworkGuru.implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_method.full_signature: @Override public Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_method.identifier: implement
focal_method.invocations: getState getId getDataCenter getPhysicalNetworkId findPhysicalNetworkId getTags getTrafficType getTrafficType getMode getBroadcastDomainType getNetworkOfferingId getDataCenterId getRedundantRouter getGateway setGateway getGateway getCidr setCidr getCidr getName isEmpty getUuid length substring listByPhysicalNetwork isEmpty error get findById getHostId loadDetails getDetail getDetail getName getDomain getAccountName getAccount easySend getId getResult error setBroadcastUri getLogicalSwitchUuid setBroadcastDomainType info toString getBroadcastUri error getUuid
focal_method.modifiers: @Override public
focal_method.parameters: (final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)
focal_method.return: Network
focal_method.signature: Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context)