@Override @Transactional public void deleteVNFRecord(String idNsr, String idVnfr) { SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd 'at' HH:mm:ss z"); NetworkServiceRecord nsr = networkServiceRecordRepository.findFirstById(idNsr); if (nsr != null) { nsr.setUpdatedAt(format.format(new Date())); nsr.getVnfr().remove(vnfrRepository.findFirstById(idVnfr)); } vnfrRepository.delete(idVnfr); }
@Override @Transactional public VirtualNetworkFunctionRecord addVnfr(VirtualNetworkFunctionRecord vnfr, String nsrId) throws NsrNotFoundException { if (networkServiceRecordRepository.exists(nsrId)) { vnfr = vnfrRepository.save(vnfr); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd 'at' HH:mm:ss z"); NetworkServiceRecord nsr = networkServiceRecordRepository.findFirstById(nsrId); nsr.setUpdatedAt(format.format(new Date())); nsr.getVnfr().add(vnfr); return vnfr; } vnfrRepository.delete(vnfr.getId()); throw new NsrNotFoundException( String.format( "NSR with id [%s] does not exist, may be already deleted, ignoring save", nsrId)); }
/** * Execute the update of a Virtual Network Function Record (VNFR) (The UPDATE is intended as the * execution of the scripts associated to the lifecycle UPDATE by the VNF provider) * * @param nsrId * @param vnfrId * @param projectId * @return * @throws NotFoundException */ @Override public VirtualNetworkFunctionRecord updateVnfr(String nsrId, String vnfrId, String projectId) throws NotFoundException, BadFormatException, ExecutionException, InterruptedException { VirtualNetworkFunctionRecord vnfr = vnfrRepository.findByIdAndParent_ns_idAndProjectId(vnfrId, nsrId, projectId); log.info("Updating VNFR: " + vnfr.getName()); vnfmManager.updateVnfr(nsrId, vnfrId, projectId); return vnfr; }
protected void printOldAndNewHibernateVersion() { if (virtualNetworkFunctionRecord.getId() != null && vnfrRepository.exists(virtualNetworkFunctionRecord.getId())) { VirtualNetworkFunctionRecord existing = vnfrRepository.findFirstById(virtualNetworkFunctionRecord.getId());
vnfrRepository.findByIdAndParent_ns_idAndProjectId(vnfrId, nsrId, projectId); log.info("Upgrading VNFR: " + vnfr.getName() + " - " + vnfr.getId()); return vnfrRepository.save(vnfr);
@Override public void executeScript(String vnfrId, Script script) throws NotFoundException, BadFormatException, ExecutionException, InterruptedException { VirtualNetworkFunctionRecord vnfr = vnfrRepository.findFirstById(vnfrId); OrVnfmExecuteScriptMessage orVnfmExecuteScriptMessage = new OrVnfmExecuteScriptMessage(); orVnfmExecuteScriptMessage.setScript(script); orVnfmExecuteScriptMessage.setVnfr(vnfr); vnfStateHandler.sendMessageToVNFR(vnfr, orVnfmExecuteScriptMessage); }
@Override @Transactional public NetworkServiceRecord saveCascade(NetworkServiceRecord networkServiceRecord) { vnfrRepository.save(networkServiceRecord.getVnfr()); return networkServiceRecordRepository.save(networkServiceRecord); }
+ virtualNetworkFunctionRecord.getId()); VirtualNetworkFunctionRecord virtualNetworkFunctionRecord_nfvo = vnfrRepository.findOne(virtualNetworkFunctionRecord.getId()); log.debug("Update: VDUs of VNFR " + virtualNetworkFunctionRecord_nfvo.getId() + ": " + vdus); setHistoryLifecycleEvent(); virtualNetworkFunctionRecord = vnfrRepository.save(virtualNetworkFunctionRecord_nfvo); log.info("Update: Finished with VNFR: " + virtualNetworkFunctionRecord_nfvo.getName());
@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); }
for (VirtualNetworkFunctionRecord vnfr : vnfrRepository.findByProjectId(projectId)) { for (VirtualDeploymentUnit vdu : vnfr.getVdu()) { if (vdu.getVimInstanceName().contains(vimInstanceOld.getName())) {
public void deleteVNFRecord(String idNsr, String idVnf, String projectId) throws NotFoundException { // TODO the logic of this request for the moment deletes only the VNFR from the DB, need to be // removed from the // running NetworkServiceRecord VirtualNetworkFunctionRecord vnfr = vnfrRepository.findOne(idVnf); if (vnfr == null) { throw new NotFoundException("Not found VNFR with ID: " + idVnf); } if (!vnfr.getParent_ns_id().equals(idNsr)) { throw new NotFoundException("Not found VNFR " + idVnf + " in the given NSR " + idNsr); } if (!vnfr.getProjectId().equals(projectId)) { throw new UnauthorizedUserException("VNFR not contained in the chosen project."); } nsrRepository.deleteVNFRecord(idNsr, idVnf); NetworkServiceRecord nsr = query(idNsr, projectId); if (nsr != null) { for (VirtualNetworkFunctionRecord virtualNetworkFunctionRecord : nsr.getVnfr()) { if (nsr.getStatus().ordinal() > virtualNetworkFunctionRecord.getStatus().ordinal()) { nsr.setStatus(vnfr.getStatus()); } } nsrRepository.saveCascade(nsr); } else { log.warn("Parent NS does not exist anymore..."); } }
if (networkServiceRecord == null) { log.info("The Record was already deleted by a previous task"); vnfrRepository.delete(virtualNetworkFunctionRecord); } else { log.warn("Descriptor was already removed, calculating the status anyway...");
@Override public void updateScript(Script script, String vnfPackageId) throws NotFoundException, BadFormatException, ExecutionException, InterruptedException { for (VirtualNetworkFunctionDescriptor vnfd : vnfdRepository.findAll()) { if (vnfd.getVnfPackageLocation() != null && vnfd.getVnfPackageLocation().equals(vnfPackageId)) { for (VirtualNetworkFunctionRecord vnfr : vnfrRepository.findAll()) { OrVnfmUpdateMessage orVnfmUpdateMessage = new OrVnfmUpdateMessage(); orVnfmUpdateMessage.setScript(script); orVnfmUpdateMessage.setVnfr(vnfr); if (vnfr.getPackageId().equals(vnfPackageId)) { vnfStateHandler.sendMessageToVNFR(vnfr, orVnfmUpdateMessage); } } } } }
try { Thread.sleep(timeout * 1000); if (vnfrRepository.exists(virtualNetworkFunctionRecord.getId())) { virtualNetworkFunctionRecord = vnfrRepository.findFirstById(virtualNetworkFunctionRecord.getId()); log.debug( "Terminating the VNFR not yet removed: " + virtualNetworkFunctionRecord.getName());
vnfrRepository.findByIdAndParent_ns_idAndProjectId(vnfrId, nsr.getId(), projectId); if (vnfr == null) throw new NotFoundException( vnfr = vnfrRepository.save(vnfr);
vnfrRepository.findFirstById( nsrFather .getVnfr()
protected void saveVirtualNetworkFunctionRecord() throws NsrNotFoundException { if (networkServiceRecordRepository.exists(virtualNetworkFunctionRecord.getParent_ns_id())) { try { lock.lock(); log.trace( "ACTION is: " + action + " and the VNFR id is: " + virtualNetworkFunctionRecord.getId()); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd 'at' HH:mm:ss z"); if (virtualNetworkFunctionRecord.getId() == null || virtualNetworkFunctionRecord.getId().isEmpty()) { virtualNetworkFunctionRecord.setCreatedAt(format.format(new Date())); virtualNetworkFunctionRecord.setUpdatedAt(format.format(new Date())); virtualNetworkFunctionRecord = networkServiceRecordRepository.addVnfr( virtualNetworkFunctionRecord, virtualNetworkFunctionRecord.getParent_ns_id()); } else { virtualNetworkFunctionRecord.setUpdatedAt(format.format(new Date())); virtualNetworkFunctionRecord = vnfrRepository.save(virtualNetworkFunctionRecord); } } finally { lock.unlock(); } } }
vnfrRepository.findByParentNsId(networkServiceRecord.getId())) { if (removeAfterTimeout) { VNFRTerminator terminator = new VNFRTerminator();
when(vimRepository.save(any(BaseVimInstance.class))).thenReturn(vimInstance_new); when(vnfdRepository.findByProjectId(anyString())).thenReturn(new ArrayList<>()); when(vnfrRepository.findByProjectId(anyString())).thenReturn(new ArrayList<>());
@Override public NFVMessage doWork() throws NsrNotFoundException { log.info("Stopped VNFR: " + virtualNetworkFunctionRecord.getName()); VirtualNetworkFunctionRecord existing = vnfrRepository.findFirstById(virtualNetworkFunctionRecord.getId()); log.trace("VNFR existing hibernate version = " + existing.getHbVersion()); log.trace("VNFR reiceived hibernate version = " + virtualNetworkFunctionRecord.getHbVersion()); for (VirtualDeploymentUnit virtualDeploymentUnit : virtualNetworkFunctionRecord.getVdu()) { for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) { log.trace("VNFCI received hibernate version = " + vnfcInstance.getHbVersion()); } } for (VirtualDeploymentUnit virtualDeploymentUnit : existing.getVdu()) { for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) { log.trace("VNFCI existing hibernate version = " + vnfcInstance.getHbVersion()); } } setHistoryLifecycleEvent(); saveVirtualNetworkFunctionRecord(); return null; }