protected boolean allVnfrInInactive(NetworkServiceRecord nsr) { for (VirtualNetworkFunctionRecord virtualNetworkFunctionRecord : nsr.getVnfr()) { if (virtualNetworkFunctionRecord.getStatus().ordinal() < Status.INACTIVE.ordinal()) { log.trace( "VNFR " + virtualNetworkFunctionRecord.getName() + " is in state: " + virtualNetworkFunctionRecord.getStatus()); return false; } } return true; }
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; }
public Set<String> getNotInitializedVnfrSource(Set<String> ids, NetworkServiceRecord nsr) { Set<String> res = new HashSet<>(); for (String sourceName : ids) { log.debug("Looking for VNFR name: " + sourceName); boolean found = false; for (VirtualNetworkFunctionRecord vnfr : nsr.getVnfr()) { if (sourceName.equals(vnfr.getName())) { found = true; if (vnfr.getStatus().ordinal() < Status.INITIALIZED.ordinal()) res.add(vnfr.getName() + nsr.getId()); } } if (!found) res.add(sourceName + nsr.getId()); } if (!res.isEmpty()) log.debug("There are the following not initialized vnfr sources:" + res); return res; }
@Override public List<VNFRecordDependency> getDependencyForAVNFRecordSource( VirtualNetworkFunctionRecord virtualNetworkFunctionRecord) { List<VNFRecordDependency> res = new ArrayList<>(); NetworkServiceRecord nsr = nsrRepository.findFirstById(virtualNetworkFunctionRecord.getParent_ns_id()); if (nsr.getStatus().ordinal() != Status.ERROR.ordinal()) { Set<VNFRecordDependency> vnfRecordDependencies = nsr.getVnf_dependency(); for (VNFRecordDependency vnfRecordDependency : vnfRecordDependencies) { vnfRecordDependency = vnfrDependencyRepository.findOne(vnfRecordDependency.getId()); log.trace( "Checking if " + virtualNetworkFunctionRecord.getName() + " is source for " + vnfRecordDependency); if (vnfRecordDependency.getIdType().containsKey(virtualNetworkFunctionRecord.getName())) { res.add(vnfRecordDependency); } } } return res; } }
@Override public VNFRecordDependency getDependencyForAVNFRecordTarget( VirtualNetworkFunctionRecord virtualNetworkFunctionRecord) { NetworkServiceRecord nsr = nsrRepository.findFirstById(virtualNetworkFunctionRecord.getParent_ns_id()); if (nsr.getStatus().ordinal() != Status.ERROR.ordinal()) { Set<VNFRecordDependency> vnfRecordDependencies = nsr.getVnf_dependency(); for (VNFRecordDependency vnfRecordDependency : vnfRecordDependencies) { vnfRecordDependency = vnfrDependencyRepository.findOne(vnfRecordDependency.getId()); if (vnfRecordDependency.getTarget().equals(virtualNetworkFunctionRecord.getName())) { return vnfRecordDependency; } } } return null; }
if (networkServiceRecord.getStatus().ordinal() == Status.NULL.ordinal()) { throw new WrongStatusException( "The NetworkService " + " )"); if (networkServiceRecord.getStatus().ordinal() != Status.ACTIVE.ordinal() && networkServiceRecord.getStatus().ordinal() != Status.ERROR.ordinal()) { throw new WrongStatusException( "The NetworkService "
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 (virtualNetworkFunctionRecord.getStatus().ordinal() != Status.TERMINATED.ordinal() && nsdRepository .findFirstById(networkServiceRecord.getDescriptor_reference()) if (status.ordinal() > vnfr.getStatus().ordinal()) { status = vnfr.getStatus(); .getVnfr() .stream() .anyMatch(vnfr -> vnfr.getStatus().ordinal() == Status.TERMINATED.ordinal()) ? Status.TERMINATED : status; if (status.ordinal() == Status.ACTIVE.ordinal()) { } else if (status.ordinal() == Status.TERMINATED.ordinal() && networkServiceRecord .getVnfr() .stream() .allMatch(vnfr -> vnfr.getStatus().ordinal() == Status.TERMINATED.ordinal())) { nsrRepository.delete(networkServiceRecord); if (dedicatedNetworks) {
if (failedVnfr.getStatus().ordinal() == (Status.ERROR.ordinal())) { failedVnfr.setStatus(Status.RESUMING); failedVnfr = vnfrRepository.save(failedVnfr); if (vnfrTarget.getStatus().ordinal() == (Status.INITIALIZED.ordinal())) { if (vnfrSource.getStatus().ordinal() == (Status.ERROR.ordinal()) && !isModifyHasBeenExecuted(vnfrSource) && vnfrTarget.getStatus().ordinal() < Status.INACTIVE.ordinal()) { log.info( "Not resolving dependencies for target: "
&& (networkServiceRecord.getStatus().ordinal() != Status.ERROR.ordinal())) { stopVNFR = false; break; if (vnfr.getStatus().ordinal() == Status.INACTIVE.ordinal()) { networkServiceRecord.setStatus(Status.INACTIVE); break; publisher.dispatchEvent(eventNFVO); if (networkServiceRecord.getStatus().ordinal() == Status.SCALING.ordinal()) { networkServiceRecord.setStatus(Status.ACTIVE); networkServiceRecord.setTask("Scaled in");