@Override public NetworkServiceRecord query(String id, String projectId) throws NotFoundException { log.trace("Id is: " + id); NetworkServiceRecord networkServiceRecord = nsrRepository.findFirstByIdAndProjectId(id, projectId); if (networkServiceRecord == null) { throw new NotFoundException("NetworkServiceRecord with ID " + id + " not found"); } return networkServiceRecord; }
private synchronized NetworkServiceRecord getNetworkServiceRecordInAnyState( String id, String projectId) throws NotFoundException { NetworkServiceRecord networkServiceRecord = nsrRepository.findFirstByIdAndProjectId(id, projectId); if (networkServiceRecord == null) { throw new NotFoundException("No NetworkServiceRecord found with ID " + id); } return networkServiceRecord; }
/** * Trigger the restart of the NSR after the upgrade of the VNFR * * @param nsrId * @param vnfrId * @param projectId * @throws NotFoundException * @throws BadFormatException * @throws ExecutionException * @throws InterruptedException */ @Override public void upgradeVnfr(String nsrId, String vnfrId, String projectId) throws NotFoundException, BadFormatException, ExecutionException, InterruptedException { NetworkServiceRecord nsr = nsrRepository.findFirstByIdAndProjectId(nsrId, projectId); NetworkServiceDescriptor nsd = nsdRepository.findFirstById(nsr.getDescriptor_reference()); setNsrRestartRequired(projectId, nsrId); // Create ordered list of VNFR to be restarted vnfrNames.put(nsrId, new HashMap<>()); Map<String, Integer> vnfrNamesWeighted = vnfrNames.get(nsrId); fillVnfrNames(nsd, vnfrNamesWeighted); vnfrNames.put(nsrId, sortByValue(vnfrNamesWeighted)); log.debug("VNFRs ordered by dependencies: " + vnfrNames.get(nsrId)); }
private synchronized NetworkServiceRecord getNetworkServiceRecordInActiveState( String id, String projectId) throws NotFoundException, WrongStatusException { NetworkServiceRecord networkServiceRecord = nsrRepository.findFirstByIdAndProjectId(id, projectId); if (networkServiceRecord == null) { throw new NotFoundException("No NetworkServiceRecord found with ID " + id); } if (networkServiceRecord.getStatus().ordinal() != Status.ACTIVE.ordinal()) { throw new WrongStatusException("NetworkServiceDescriptor must be in ACTIVE state"); } return networkServiceRecord; }
@Test public void nsrManagementDeleteTest() throws VimException, InterruptedException, ExecutionException, NotFoundException, WrongStatusException, PluginException, BadFormatException { NetworkServiceRecord nsd_exp = createNetworkServiceRecord(); when(resourceManagement.release(any(VirtualDeploymentUnit.class), any(VNFCInstance.class))) .thenReturn(new AsyncResult<>(null)); when(nsrRepository.findFirstByIdAndProjectId(nsd_exp.getId(), projectId)).thenReturn(nsd_exp); when(vnfrRepository.findByParentNsId(anyString())).thenReturn(new ArrayList<>()); Configuration system = new Configuration(); system.setConfigurationParameters(new HashSet<>()); ConfigurationParameter configurationParameter = new ConfigurationParameter(); configurationParameter.setConfKey("delete-on-all-status"); configurationParameter.setValue("true"); nsrManagement.delete(nsd_exp.getId(), projectId); }
IOException, BadRequestException, VimException, PluginException { NetworkServiceRecord nsr = nsrRepository.findFirstByIdAndProjectId(nsrId, projectId);
nsrRepository.findFirstByIdAndProjectId(nsrId, projectId); if (networkServiceRecord == null) { throw new NotFoundException("No NSR found with ID " + nsrId);
@Test public void nsrManagementUpdateTest() throws NotFoundException { final NetworkServiceRecord nsd_exp = createNetworkServiceRecord(); when(nsrRepository.findOne(nsd_exp.getId())).thenReturn(nsd_exp); when(nsrRepository.findFirstByIdAndProjectId(nsd_exp.getId(), projectId)).thenReturn(nsd_exp); NetworkServiceRecord new_nsr = createNetworkServiceRecord(); new_nsr.setName("UpdatedName"); nsrManagement.update(new_nsr, nsd_exp.getId(), projectId); new_nsr.setId(nsd_exp.getId()); assertEqualsNSR(new_nsr); }
@Override public void restartVnfr(VirtualNetworkFunctionRecord vnfr) throws NotFoundException, BadFormatException, ExecutionException, InterruptedException { VnfmManagerEndpoint endpoint = generator.getVnfm(vnfr.getEndpoint()); if (endpoint == null) { throw new NotFoundException( "VnfManager of type " + vnfr.getType() + " (endpoint = " + vnfr.getEndpoint() + ") is not registered"); } VirtualNetworkFunctionDescriptor vnfd = vnfdRepository.findFirstByIdAndProjectId( vnfr.getDescriptor_reference(), vnfr.getProjectId()); Map<String, Set<String>> vduVimInstances = new HashMap<>(); for (VirtualDeploymentUnit vdu : vnfd.getVdu()) vduVimInstances.put(vdu.getId(), vdu.getVimInstanceName()); NetworkServiceRecord nsr = nsrRepository.findFirstByIdAndProjectId(vnfr.getParent_ns_id(), vnfr.getProjectId()); VnfmSender vnfmSender = generator.getVnfmSender(vnfd); OrVnfmInstantiateMessage message = generator.getNextMessage(vnfd, vduVimInstances, nsr, null, null); // Set the vnfr in the message, so the allocate resources will be skipped message.setVnfr(vnfr); log.debug("----------Executing ACTION: " + message.getAction()); vnfStateHandler.executeAction(vnfmSender.sendCommand(message, endpoint)); log.info("Sent " + message.getAction() + " to VNF: " + vnfd.getName()); }
NetworkServiceRecord nsr = nsrRepository.findFirstByIdAndProjectId(nsrId, projectId);
NetworkServiceRecord nsr = nsrRepository.findFirstByIdAndProjectId(nsrId, projectId);
private void assertEqualsNSR(NetworkServiceRecord nsr_exp) throws NoResultException, NotFoundException { when(nsrRepository.findFirstByIdAndProjectId(nsr_exp.getId(), projectId)).thenReturn(nsr_exp); NetworkServiceRecord networkServiceRecord = nsrManagement.query(nsr_exp.getId(), projectId); Assert.assertEquals(nsr_exp.getId(), networkServiceRecord.getId()); Assert.assertEquals(nsr_exp.getName(), networkServiceRecord.getName()); Assert.assertEquals(nsr_exp.getVendor(), networkServiceRecord.getVendor()); Assert.assertEquals(nsr_exp.getVersion(), networkServiceRecord.getVersion()); }
log.info("Removing NSR with id: " + id); NetworkServiceRecord networkServiceRecord = nsrRepository.findFirstByIdAndProjectId(id, projectId); if (networkServiceRecord == null) { throw new NotFoundException("NetworkServiceRecord with ID " + id + " was not found");