@Override public Set<BaseNfvImage> queryImagesDirectly(BaseVimInstance vimInstance) throws PluginException, VimException { return new HashSet<>(vimBroker.getVim(vimInstance.getType()).queryImages(vimInstance)); }
anySet())) .thenReturn(new AsyncResult<List<String>>(new ArrayList<>())); when(vimBroker.getVim(anyString())).thenReturn(vim); when(vimBroker.getLeftQuota(any(BaseVimInstance.class))).thenReturn(createQuota()); VNFCInstance vnfcInstance = new VNFCInstance(); when(vim.allocate(
@Test public void vnfLifecycleOperationGrantingTest() throws VimException, PluginException { VirtualNetworkFunctionRecord vnfr = createVirtualNetworkFunctionRecord(); when(vimInstanceRepository.findByProjectIdAndName(anyString(), anyString())) .thenReturn(createVimInstance()); when(vimBroker.getLeftQuota(any(BaseVimInstance.class))).thenReturn(createMaxQuota()); Map<String, BaseVimInstance> granted = vnfLifecycleOperationGranting.grantLifecycleOperation(vnfr); log.debug(granted.size() + " == " + vnfr.getVdu().size()); Assert.assertTrue(granted.size() == vnfr.getVdu().size()); when(vimBroker.getLeftQuota(any(BaseVimInstance.class))).thenReturn(createMinQuota()); granted = vnfLifecycleOperationGranting.grantLifecycleOperation(vnfr); Assert.assertFalse(granted.size() == vnfr.getVdu().size()); }
Quota leftQuota = vimBroker.getLeftQuota(vimInstance); Quota neededQuota = requirements.get(vimInstance); log.info(
@Override public BaseNetwork update(BaseVimInstance vimInstance, Network updatingNetwork) throws VimException, PluginException { // Fetch Vim org.openbaton.nfvo.vim_interfaces.network_management.NetworkManagement vim; vim = vimBroker.getVim(vimInstance.getType()); // Update network on cloud environment return vim.update(vimInstance, updatingNetwork); }
@Override public Quota getLeftQuota(String projectId) throws VimException, PluginException { Quota result = new Quota(); for (BaseVimInstance vimInstance : vimInstanceRepository.findByProjectId(projectId)) { if (vimInstance.getType().equals("test")) { continue; } Quota tmp = vimBroker.getLeftQuota(vimInstance); result.setCores(result.getCores() + tmp.getCores()); result.setFloatingIps(result.getFloatingIps() + tmp.getFloatingIps()); result.setInstances(result.getInstances() + tmp.getInstances()); result.setRam(result.getRam() + tmp.getRam()); } return result; } }
@Override public List<Server> query(BaseVimInstance vimInstance) throws VimException, PluginException { return vimBroker.getVim(vimInstance.getType()).queryResources(vimInstance); }
throws VimException, PluginException { if (vimInstance instanceof OpenstackVimInstance) { Quota leftQuota = vimBroker.getLeftQuota(vimInstance); log.debug("Left Quota on VimInstance " + vimInstance.getName() + " at start is " + leftQuota);
@Override public void delete(BaseVimInstance vimInstance, BaseNetwork network) throws VimException, PluginException { // Fetch Vim org.openbaton.nfvo.vim_interfaces.network_management.NetworkManagement vim; vim = vimBroker.getVim(vimInstance.getType()); // Delete network from cloud environment vim.delete(vimInstance, network); // Delete network from NetworkRepository networkRepository.delete(network); }
@Override @Async public Future<Void> release( VirtualDeploymentUnit virtualDeploymentUnit, VNFCInstance vnfcInstance) throws VimException, ExecutionException, InterruptedException, PluginException { BaseVimInstance vimInstance = vimInstanceRepository.findFirstById(vnfcInstance.getVim_id()); org.openbaton.nfvo.vim_interfaces.resource_management.ResourceManagement vim = vimBroker.getVim(vimInstance.getType()); log.debug("Removing vnfcInstance: " + vnfcInstance); vim.release(vnfcInstance, vimInstance).get(); virtualDeploymentUnit.getVnfc().remove(vnfcInstance.getVnfComponent()); return new AsyncResult<>(null); }
@Override @Async public Future<Void> operate(VirtualDeploymentUnit vdu, String operation) throws PluginException, ExecutionException, InterruptedException, VimException { for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) { BaseVimInstance vimInstance = vimInstanceRepository.findFirstById(vnfcInstance.getVim_id()); org.openbaton.nfvo.vim_interfaces.resource_management.ResourceManagement vim = vimBroker.getVim(vimInstance.getType()); log.info("rebuilding vnfcInstance: " + vnfcInstance.getHostname()); vim.operate(vimInstance, vdu, vnfcInstance, operation).get(); } return new AsyncResult<>(null); }
@Async @Override public Future<Void> deleteNetwork(VirtualLinkRecord vlr) throws PluginException, NotFoundException, VimException { BaseVimInstance vimInstance = this.query(vlr.getVim_id()); if (vimInstance == null) throw new NotFoundException( String.format("VimInstance with it %s not found", vlr.getVim_id())); vimBroker .getVim(vimInstance.getType()) .delete( vimInstance, vimInstance .getNetworks() .parallelStream() .filter(n -> n.getExtId().equals(vlr.getExtId())) .findFirst() .orElseThrow( () -> new NotFoundException( String.format("Network with it %s not found", vlr.getExtId())))); return new AsyncResult<>(null); }
vimInstance = vimBroker.getVim(vimInstance.getType()).refresh(vimInstance); vimInstance = vimRepository.save(vimInstance);
throws VimException, ExecutionException, InterruptedException, PluginException { List<Future<VNFCInstance>> instances = new ArrayList<>(); org.openbaton.nfvo.vim_interfaces.vim.Vim vim = vimBroker.getVim(vimInstance.getType()); log.debug("Executing allocate with Vim: " + vim.getClass().getSimpleName()); log.debug("NAME: " + virtualNetworkFunctionRecord.getName());
private void initMocks() throws VimException, PluginException { Vim vim = mock(Vim.class); when(vim.queryImages(any(BaseVimInstance.class))).thenReturn(new ArrayList<>()); when(vimBroker.getVim(anyString())).thenReturn(vim); // try { // Future<Set<DeploymentFlavour>> futureFlavours = mock(AsyncResult.class); // Future<Set<BaseNetwork>> futureNetworks = mock(AsyncResult.class); // Future<Set<BaseNfvImage>> futureImages = mock(AsyncResult.class); // // when(asyncVimManagement.updateFlavors(any(BaseVimInstance.class))).thenReturn(futureFlavours); // when(asyncVimManagement.updateFlavors(any(BaseVimInstance.class)).get()) // .thenReturn(new HashSet<>()); // // when(asyncVimManagement.updateImages(any(BaseVimInstance.class))).thenReturn(futureImages); // when(asyncVimManagement.updateImages(any(BaseVimInstance.class)).get()) // .thenReturn(new HashSet<>()); // when(asyncVimManagement.updateNetworks(any(BaseVimInstance.class))) // .thenReturn(futureNetworks); // when(asyncVimManagement.updateNetworks(any(BaseVimInstance.class)).get()) // .thenReturn(new HashSet<>()); // } catch (InterruptedException | ExecutionException | BadRequestException e) { // e.printStackTrace(); // } doNothing().when(imageRepository).delete(any(NFVImage.class)); doNothing().when(networkRepository).delete(any(Network.class)); }
throws InterruptedException, ExecutionException, PluginException, VimException { org.openbaton.nfvo.vim_interfaces.resource_management.ResourceManagement vim; vim = vimBroker.getVim(vimInstance.getType()); log.debug("Executing allocate with Vim: " + vim.getClass().getSimpleName()); log.debug("NAME: " + virtualNetworkFunctionRecord.getName());
@Test public void networkManagementDeleteTest() throws VimException, PluginException { BaseNetwork network_exp = createNetwork(); when(vimBroker.getVim(anyString())).thenReturn(myVim); when(networkRepository.findOne(network_exp.getId())).thenReturn(network_exp); networkManagement.delete(createVimInstance(), network_exp); when(networkRepository.findOne(anyString())).thenReturn(null); BaseNetwork network_new = networkManagement.query(network_exp.getId()); Assert.assertNull(network_new); } }
BaseVimInstance vimInstance = vimInstanceRepository.findByProjectIdAndName(projectId, vimName); Vim vim = vimBroker.getVim(vimInstance.getType()); if (vnfPackage.getImageLink() != null && virtualNetworkFunctionDescriptor.getVdu() != null) {
log.info("Creating network " + network.getName() + " on vim " + vimInstance.getName()); org.openbaton.nfvo.vim_interfaces.network_management.NetworkManagement vim; vim = vimBroker.getVim(vimInstance.getType());
throws VimException, PluginException { org.openbaton.nfvo.vim_interfaces.vim.Vim vim = vimBroker.getVim(vimInstance.getType()); log.info( "Checking if Flavor "