@Test public void testDeployNetwork() throws Exception { Network net = new Network("NET", "vdc", "region"); tier.addNetwork(net); TierInstance tierInstance = new TierInstance(); tierInstance.setTier(tier); when(tierInstanceManager.update(any(TierInstance.class))).thenReturn(tierInstance); when(networkInstanceManager.create(any(ClaudiaData.class), any(NetworkInstance.class), anyString())) .thenReturn(net.toNetworkInstance()); when(networkManager.load(any(String.class), any(String.class), any(String.class))).thenReturn(net); when(tierManager.loadTierWithNetworks(any(String.class), any(String.class), any(String.class))) .thenReturn(tier); Mockito.doThrow(EntityNotFoundException.class).when(networkInstanceManager) .load(any(String.class), any(ClaudiaData.class), any(String.class)); manager.deployNetworks(claudiaData, tierInstance); assertEquals(tierInstance.getNetworkInstances().size(), 1); }
public void deployNetworks(ClaudiaData data, TierInstance tierInstance) throws InvalidEntityException, InfrastructureException, EntityNotFoundException, AlreadyExistsEntityException { Tier tier = tierInstance.getTier(); tier = tierManager.loadTierWithNetworks(tier.getName(), data.getVdc(), tier.getEnviromentName()); log.info("Deploying network for tier instance " + tierInstance.getName() + " " + tier.getNetworks().size() + " region " + tier.getRegion()); List<Network> networkToBeDeployed = new ArrayList<Network>(); for (Network network : tier.getNetworks()) { log.info("Network to be added " + network.getNetworkName()); if (network.getNetworkName().equals("Internet")) { tier.setFloatingip("true"); tier = tierManager.update(tier); tierInstance.update(tier); } else { networkToBeDeployed.add(network); } } for (Network network : networkToBeDeployed) { log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " " + network.getRegion() + " and federated " + network.getfederatedNetwork()); network = networkManager.load(network.getNetworkName(), data.getVdc(), network.getRegion()); NetworkInstance networkInst = network.toNetworkInstance(); log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " region " + networkInst.getRegionName() + " and networkInst " + network.getfederatedNetwork()); if (networkInstanceManager.exists(data, networkInst, tier.getRegion())) { log.info("the network inst " + networkInst.getNetworkName() + " already exists"); networkInst = networkInstanceManager.load(networkInst.getNetworkName(), data, tier.getRegion()); } else { try { log.info("the network inst " + networkInst.getNetworkName() + " do not exists"); networkInst = networkInstanceManager.create(data, networkInst, tierInstance.getTier().getRegion()); } catch (AlreadyExistsEntityException e2) { throw new InvalidEntityException(network); } catch (InfrastructureException e) { String mens = "Error to deploy a network " + network.getNetworkName() + " :" + e.getMessage(); throw new InfrastructureException(mens); } } log.info("Adding network to tier isntance " + networkInst.getNetworkName()); tierInstance.addNetworkInstance(networkInst); } }
InfrastructureManagerClaudiaImpl implements InfrastructureManager { public void deployNetworks(ClaudiaData data, TierInstance tierInstance) throws InvalidEntityException, InfrastructureException, EntityNotFoundException, AlreadyExistsEntityException { Tier tier = tierInstance.getTier(); tier = tierManager.loadTierWithNetworks(tier.getName(), data.getVdc(), tier.getEnviromentName()); log.info("Deploying network for tier instance " + tierInstance.getName() + " " + tier.getNetworks().size() + " region " + tier.getRegion()); List<Network> networkToBeDeployed = new ArrayList<Network>(); for (Network network : tier.getNetworks()) { log.info("Network to be added " + network.getNetworkName()); if (network.getNetworkName().equals("Internet")) { tier.setFloatingip("true"); tier = tierManager.update(tier); tierInstance.update(tier); } else { networkToBeDeployed.add(network); } } for (Network network : networkToBeDeployed) { log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " " + network.getRegion() + " and federated " + network.getfederatedNetwork()); network = networkManager.load(network.getNetworkName(), data.getVdc(), network.getRegion()); NetworkInstance networkInst = network.toNetworkInstance(); log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " region " + networkInst.getRegionName() + " and networkInst " + network.getfederatedNetwork()); if (networkInstanceManager.exists(data, networkInst, tier.getRegion())) { log.info("the network inst " + networkInst.getNetworkName() + " already exists"); networkInst = networkInstanceManager.load(networkInst.getNetworkName(), data, tier.getRegion()); } else { try { log.info("the network inst " + networkInst.getNetworkName() + " do not exists"); networkInst = networkInstanceManager.create(data, networkInst, tierInstance.getTier().getRegion()); } catch (AlreadyExistsEntityException e2) { throw new InvalidEntityException(network); } catch (InfrastructureException e) { String mens = "Error to deploy a network " + network.getNetworkName() + " :" + e.getMessage(); throw new InfrastructureException(mens); } } log.info("Adding network to tier isntance " + networkInst.getNetworkName()); tierInstance.addNetworkInstance(networkInst); } } }
InfrastructureManagerClaudiaImpl implements InfrastructureManager { public void deployNetworks(ClaudiaData data, TierInstance tierInstance) throws InvalidEntityException, InfrastructureException, EntityNotFoundException, AlreadyExistsEntityException { Tier tier = tierInstance.getTier(); tier = tierManager.loadTierWithNetworks(tier.getName(), data.getVdc(), tier.getEnviromentName()); log.info("Deploying network for tier instance " + tierInstance.getName() + " " + tier.getNetworks().size() + " region " + tier.getRegion()); List<Network> networkToBeDeployed = new ArrayList<Network>(); for (Network network : tier.getNetworks()) { log.info("Network to be added " + network.getNetworkName()); if (network.getNetworkName().equals("Internet")) { tier.setFloatingip("true"); tier = tierManager.update(tier); tierInstance.update(tier); } else { networkToBeDeployed.add(network); } } for (Network network : networkToBeDeployed) { log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " " + network.getRegion() + " and federated " + network.getfederatedNetwork()); network = networkManager.load(network.getNetworkName(), data.getVdc(), network.getRegion()); NetworkInstance networkInst = network.toNetworkInstance(); log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " region " + networkInst.getRegionName() + " and networkInst " + network.getfederatedNetwork()); if (networkInstanceManager.exists(data, networkInst, tier.getRegion())) { log.info("the network inst " + networkInst.getNetworkName() + " already exists"); networkInst = networkInstanceManager.load(networkInst.getNetworkName(), data, tier.getRegion()); } else { try { log.info("the network inst " + networkInst.getNetworkName() + " do not exists"); networkInst = networkInstanceManager.create(data, networkInst, tierInstance.getTier().getRegion()); } catch (AlreadyExistsEntityException e2) { throw new InvalidEntityException(network); } catch (InfrastructureException e) { String mens = "Error to deploy a network " + network.getNetworkName() + " :" + e.getMessage(); throw new InfrastructureException(mens); } } log.info("Adding network to tier isntance " + networkInst.getNetworkName()); tierInstance.addNetworkInstance(networkInst); } }  }
InfrastructureManagerClaudiaImpl implements InfrastructureManager { public void deployNetworks(ClaudiaData data, TierInstance tierInstance) throws InvalidEntityException, InfrastructureException, EntityNotFoundException, AlreadyExistsEntityException { Tier tier = tierInstance.getTier(); tier = tierManager.loadTierWithNetworks(tier.getName(), data.getVdc(), tier.getEnviromentName()); log.info("Deploying network for tier instance " + tierInstance.getName() + " " + tier.getNetworks().size() + " region " + tier.getRegion()); List<Network> networkToBeDeployed = new ArrayList<Network>(); for (Network network : tier.getNetworks()) { log.info("Network to be added " + network.getNetworkName()); if (network.getNetworkName().equals("Internet")) { tier.setFloatingip("true"); tier = tierManager.update(tier); tierInstance.update(tier); } else { networkToBeDeployed.add(network); } } for (Network network : networkToBeDeployed) { log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " " + network.getRegion() + " and federated " + network.getfederatedNetwork()); network = networkManager.load(network.getNetworkName(), data.getVdc(), network.getRegion()); NetworkInstance networkInst = network.toNetworkInstance(); log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " region " + networkInst.getRegionName() + " and networkInst " + network.getfederatedNetwork()); if (networkInstanceManager.exists(data, networkInst, tier.getRegion())) { log.info("the network inst " + networkInst.getNetworkName() + " already exists"); networkInst = networkInstanceManager.load(networkInst.getNetworkName(), data, tier.getRegion()); } else { try { log.info("the network inst " + networkInst.getNetworkName() + " do not exists"); networkInst = networkInstanceManager.create(data, networkInst, tierInstance.getTier().getRegion()); } catch (AlreadyExistsEntityException e2) { throw new InvalidEntityException(network); } catch (InfrastructureException e) { String mens = "Error to deploy a network " + network.getNetworkName() + " :" + e.getMessage(); throw new InfrastructureException(mens); } } log.info("Adding network to tier isntance " + networkInst.getNetworkName()); tierInstance.addNetworkInstance(networkInst); } }  @Async TierInstance cloneTemplate(String templateName); List<VM> createEnvironment(EnvironmentInstance envInstance, String ovf, ClaudiaData claudiaData); EnvironmentInstance createInfrasctuctureEnvironmentInstance(EnvironmentInstance environmentInstance,
            Set<Tier> tiers, ClaudiaData claudiaData); String generateVMName(String service, String tierName, int numReplica, String vdc); @Async Template createTemplate(TierInstance tierInstance); void deleteEnvironment(ClaudiaData claudiaData, EnvironmentInstance envInstance); @Override void deleteNetworksInTierInstance(ClaudiaData claudiaData, TierInstance tierInstance); void deleteVMReplica(ClaudiaData claudiaData, TierInstance tierInstance); void deployVM(ClaudiaData claudiaData, TierInstance tierInstance, int replica, VM vm); String ImageScalability(ClaudiaData claudiaData, TierInstance tierInstance); void deployNetworks(ClaudiaData data, TierInstance tierInstance); void setClaudiaClient(ClaudiaClient claudiaClient); void setClaudiaResponseAnalyser(ClaudiaResponseAnalyser claudiaResponseAnalyser); void setEnvironmentInstanceDao(EnvironmentInstanceDao environmentInstanceDao); void setSystemPropertiesProvider(SystemPropertiesProvider systemPropertiesProvider); void setTierInstanceManager(TierInstanceManager tierInstanceManager); String StartStopScalability(ClaudiaData claudiaData, boolean b); void setNetworkInstanceManager(NetworkInstanceManager networkInstanceManager); void setNetworkManager(NetworkManager networkManager); void setTierManager(TierManager tierManager); String getFederatedRange(ClaudiaData data, String region); void federatedNetworks(ClaudiaData data, EnvironmentInstance environmentInstance); }
InfrastructureManagerClaudiaImpl implements InfrastructureManager { public void deployNetworks(ClaudiaData data, TierInstance tierInstance) throws InvalidEntityException, InfrastructureException, EntityNotFoundException, AlreadyExistsEntityException { Tier tier = tierInstance.getTier(); tier = tierManager.loadTierWithNetworks(tier.getName(), data.getVdc(), tier.getEnviromentName()); log.info("Deploying network for tier instance " + tierInstance.getName() + " " + tier.getNetworks().size() + " region " + tier.getRegion()); List<Network> networkToBeDeployed = new ArrayList<Network>(); for (Network network : tier.getNetworks()) { log.info("Network to be added " + network.getNetworkName()); if (network.getNetworkName().equals("Internet")) { tier.setFloatingip("true"); tier = tierManager.update(tier); tierInstance.update(tier); } else { networkToBeDeployed.add(network); } } for (Network network : networkToBeDeployed) { log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " " + network.getRegion() + " and federated " + network.getfederatedNetwork()); network = networkManager.load(network.getNetworkName(), data.getVdc(), network.getRegion()); NetworkInstance networkInst = network.toNetworkInstance(); log.info("Network instance to be deployed: " + network.getNetworkName() + " vdc " + data.getVdc() + " region " + networkInst.getRegionName() + " and networkInst " + network.getfederatedNetwork()); if (networkInstanceManager.exists(data, networkInst, tier.getRegion())) { log.info("the network inst " + networkInst.getNetworkName() + " already exists"); networkInst = networkInstanceManager.load(networkInst.getNetworkName(), data, tier.getRegion()); } else { try { log.info("the network inst " + networkInst.getNetworkName() + " do not exists"); networkInst = networkInstanceManager.create(data, networkInst, tierInstance.getTier().getRegion()); } catch (AlreadyExistsEntityException e2) { throw new InvalidEntityException(network); } catch (InfrastructureException e) { String mens = "Error to deploy a network " + network.getNetworkName() + " :" + e.getMessage(); throw new InfrastructureException(mens); } } log.info("Adding network to tier isntance " + networkInst.getNetworkName()); tierInstance.addNetworkInstance(networkInst); } }  @Async TierInstance cloneTemplate(String templateName); List<VM> createEnvironment(EnvironmentInstance envInstance, String ovf, ClaudiaData claudiaData); EnvironmentInstance createInfrasctuctureEnvironmentInstance(EnvironmentInstance environmentInstance,
            Set<Tier> tiers, ClaudiaData claudiaData); String generateVMName(String service, String tierName, int numReplica, String vdc); @Async Template createTemplate(TierInstance tierInstance); void deleteEnvironment(ClaudiaData claudiaData, EnvironmentInstance envInstance); @Override void deleteNetworksInTierInstance(ClaudiaData claudiaData, TierInstance tierInstance); void deleteVMReplica(ClaudiaData claudiaData, TierInstance tierInstance); void deployVM(ClaudiaData claudiaData, TierInstance tierInstance, int replica, VM vm); String ImageScalability(ClaudiaData claudiaData, TierInstance tierInstance); void deployNetworks(ClaudiaData data, TierInstance tierInstance); void setClaudiaClient(ClaudiaClient claudiaClient); void setClaudiaResponseAnalyser(ClaudiaResponseAnalyser claudiaResponseAnalyser); void setEnvironmentInstanceDao(EnvironmentInstanceDao environmentInstanceDao); void setSystemPropertiesProvider(SystemPropertiesProvider systemPropertiesProvider); void setTierInstanceManager(TierInstanceManager tierInstanceManager); String StartStopScalability(ClaudiaData claudiaData, boolean b); void setNetworkInstanceManager(NetworkInstanceManager networkInstanceManager); void setNetworkManager(NetworkManager networkManager); void setTierManager(TierManager tierManager); String getFederatedRange(ClaudiaData data, String region); void federatedNetworks(ClaudiaData data, EnvironmentInstance environmentInstance);  }