if (vnfcInstance_manager.getId() == null) { instances.add(vnfcInstance_manager); log.debug("Update: added new VNFC instance " + vnfcInstance_manager); if (vnfcInstance_nfvo.getId().equals(vnfcInstance_manager.getId())) { log.debug("Update: Updating existing VNFCInstance " + vnfcInstance_nfvo.getId()); found = true; vnfcInstance_nfvo.setHostname(vnfcInstance_manager.getHostname()); vnfcInstance_nfvo.setVim_id(vnfcInstance_manager.getVim_id()); vnfcInstance_nfvo.setVc_id(vnfcInstance_manager.getVc_id()); vnfcInstance_nfvo.setVnfComponent(vnfcInstance_manager.getVnfComponent()); vnfcInstance_nfvo.setConnection_point( updateVNFDConnectionPoints( vnfcInstance_nfvo.getConnection_point(), vnfcInstance_manager.getConnection_point())); log.debug("Update: Added new Component " + vnfcInstance_manager.getId());
vnfciScaled.setState("ACTIVE"); break; for (VNFCInstance instanceInVNFR : vdu.getVnfc_instance()) { log.debug("VNFCInstance: " + instanceInVNFR.getHostname()); if (instanceInVNFR.getId().equals(vnfciStarted.getId())) { instanceInVNFR.setState("ACTIVE"); instanceInVNFR.setState("ACTIVE"); if (instanceInVNFR.getId().equals(vnfciStopped.getId())) { instanceInVNFR.setState("INACTIVE"); if (instanceInVNFR.getState().equals("ACTIVE")) { stopVNFR = false; instanceInVNFR.setState("INACTIVE");
userdata, keys); log.debug("Launched VM with id: " + vnfc.getVc_id()); Map<String, String> floatingIps = new HashMap<>(); for (VNFDConnectionPoint connectionPoint : vnfc.getVnfComponent().getConnection_point()) { if (connectionPoint.getFloatingIp() != null) floatingIps.put( connectionPoint.getVirtual_link_reference(), connectionPoint.getFloatingIp()); if (floatingIps.size() != vnfc.getFloatingIps().size()) { log.warn("NFVO wasn't able to all associate FloatingIPs. Is there enough available?"); log.debug("Expected FloatingIPs: " + floatingIps); log.debug("Real FloatingIPs: " + vnfc.getFloatingIps()); log.info("Finished deploying VMs with external id: " + vnfc.getVc_id()); return new AsyncResult<>(vnfc);
private String getVnfcId() { for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) { for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) { if (this.vnfcInstance.getVc_id().equals(vnfcInstance.getVc_id())) { return vnfcInstance.getId(); } } if (vnfcInstance.getId() != null) { return vnfcInstance.getId(); } } return null; }
private String getVNFCHostname(NetworkServiceRecord nsr, String vnfcId) { for (VirtualNetworkFunctionRecord vnfr : nsr.getVnfr()) { for (VirtualDeploymentUnit vdu : vnfr.getVdu()) { for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) { if (vnfcInstance.getId().equals(vnfcId)) { return vnfcInstance.getHostname(); } } } } return null; }
VirtualNetworkFunctionRecord vnfr) throws VimDriverException, VimException { VNFCInstance vnfcInstance = new VNFCInstance(); if (server == null) { log.trace("Listing potential VMs to recover..."); vnfcInstance.setHostname(hostname); if (server.getExtId() != null) { vnfcInstance.setVc_id(server.getExtId()); } else { vnfcInstance.setVc_id("unknown"); vnfcInstance.setVim_id(vimInstance.getId()); vnfcInstance.setState(server.getStatus()); vnfcInstance.setConnection_point(new HashSet<>()); if (entry.getKey().equals(connectionPoint.getVirtual_link_reference())) connectionPoint_vnfci.setFloatingIp(entry.getValue()); vnfcInstance.getConnection_point().add(connectionPoint_vnfci); vnfcInstance.setVnfComponent(vnfComponent); vnfcInstance.setIps(new HashSet<>()); vnfcInstance.setFloatingIps(new HashSet<>()); ip.setNetName(fip.getKey()); ip.setIp(fip.getValue()); vnfcInstance.getFloatingIps().add(ip);
+ virtualNetworkFunctionRecord.getId() + ") instance is: " + vnfcInstance.toString()); try { log.debug( "Saving VNFC instance " + vnfcInstance.getId() + ". Status of unsaved VNFC instance is: " + vnfcInstance.getState()); for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) { for (VNFCInstance vnfcInstanceTmp : vdu.getVnfc_instance()) { if (vnfcInstanceTmp.getHostname().equals(vnfcInstance.getHostname()) && vnfcInstanceTmp.getVim_id().equals(vnfcInstance.getVim_id())) { if (vnfcInstanceTmp.getState() == null || !vnfcInstanceTmp.getState().equalsIgnoreCase("standby")) { vnfcInstanceTmp.setState("ACTIVE"); + vnfcInstance.getId() + ") is: " + vnfcInstance.getState()); } catch (Exception e) { e.printStackTrace(); if (vnfcInstance.getState() != null && vnfcInstance.getState().equalsIgnoreCase("standby")) { return null; for (Ip ip : vnfcInstance.getFloatingIps()) { vnfcDP.getParameters().put(ip.getNetName() + "_floatingIp", ip.getIp());
vnfcInstance = ((VimException) e1).getVnfcInstance(); else { vnfcInstance = new VNFCInstance(); vnfcInstance.setHostname(hostname); vnfcInstance.setVim_id(vimInstance.getId()); vnfcInstance.setVnfComponent(vnfComponent); vnfcInstance.setVc_id("unknown"); vnfcInstance.setState("ERROR"); vnfcInstance.setIps(new HashSet<>()); vnfcInstance.setFloatingIps(new HashSet<>());
return null; if (vnfcInstance.getState() != null && vnfcInstance.getState().equalsIgnoreCase("ACTIVE")) log.debug("The vnfcInstance activated is: " + vnfcInstance.toString()); else { log.error( vnfcDP.setParameters(new HashMap<String, String>()); for (Ip ip : vnfcInstance.getFloatingIps()) vnfcDP.getParameters().put(ip.getNetName() + "_floatingIp", ip.getIp()); for (Ip ip : vnfcInstance.getIps()) vnfcDP.getParameters().put(ip.getNetName(), ip.getIp()); vnfcDP.getParameters().put("hostname", vnfcInstance.getHostname()); .get(virtualNetworkFunctionRecord.getType()) .getParameters() .remove(failedVnfc.getId()); log.debug( "Current dependency without failed vnfc: "
if (vnfcDependencyParameters.getParameters().get(vnfcInstance.getId()) == null) { DependencyParameters dependencyParameters = new DependencyParameters(); dependencyParameters.setParameters(new HashMap<>()); if (vnfcInstance.getId() == null) { vnfcInstance = vnfcInstanceRepository.save(vnfcInstance); vnfcDependencyParameters.getParameters().put(vnfcInstance.getId(), dependencyParameters); for (Ip ip : vnfcInstance.getIps()) { if (parameterKeys.contains(ip.getNetName())) { log.debug( + ip.getIp() + ". VNFCInstance ID: " + vnfcInstance.getId()); vnfcDependencyParameters .getParameters() .get(vnfcInstance.getId()) .getParameters() .put(ip.getNetName(), ip.getIp()); for (Ip ip : vnfcInstance.getFloatingIps()) { if (parameterKeys.contains(ip.getNetName() + "_floatingIp")) { log.debug( + ip.getIp() + ". VNFCInstance ID: " + vnfcInstance.getId()); vnfcDependencyParameters
log.debug("Parameter: " + parametersEntry); if (parametersEntry.getValue() != null) { parametersEntry.getValue().getParameters().remove(vnfcInstance.getId()); for (Ip ip : vnfcInstance.getIps()) { virtualNetworkFunctionRecord.getVnf_address().remove(ip.getIp()); virtualDeploymentUnit.getVnfc().remove(vnfcInstance.getVnfComponent()); virtualDeploymentUnit.getVnfc_instance().remove(vnfcInstance); for (VNFCInstance instanceInVNFR : vdu.getVnfc_instance()) { log.debug("VNFCInstance status is: " + instanceInVNFR.getState()); if (instanceInVNFR.getState() != null) { if ((instanceInVNFR.getState().equalsIgnoreCase("active")) && (networkServiceRecord.getStatus().ordinal() != Status.ERROR.ordinal())) { stopVNFR = false;
log.debug( "VNFCInstance: (ID: " + vnfcInstance.getId() + " - HOSTNAME: " + vnfcInstance.getHostname() + " - STATE: " + vnfcInstance.getState() + ")"); if (vnfcInstance.getId().equals(idVNFCI)) { vnfcInstanceToStartStop = vnfcInstance; switch (action) { log.debug( "VNFCInstance to be started: " + vnfcInstanceToStartStop.getId() + " - " + vnfcInstanceToStartStop.getHostname()); break; case STOP: log.debug( "VNFCInstance to be stopped: " + vnfcInstanceToStartStop.getId() + " - " + vnfcInstanceToStartStop.getHostname()); break;
log.debug( "Removing VM with ExtId: " + vnfcInstance.getVc_id() + " from VimInstance " + vimInstance.getName()); try { client.deleteServerByIdAndWait(vimInstance, vnfcInstance.getVc_id()); log.info( "Removed VM with ExtId: " + vnfcInstance.getVc_id() + " from VimInstance " + vimInstance.getName()); log.error( "Not removed VM with ExtId " + vnfcInstance.getVc_id() + " successfully from VimInstance " + vimInstance.getName() log.error( "Not removed VM with ExtId " + vnfcInstance.getVc_id() + " successfully from VimInstance " + vimInstance.getName() + vnfcInstance.getVc_id() + " successfully from VimInstance " + vimInstance.getName()
throws VimException { try { if (vnfComponent.getConnection_point().size() != vnfcInstance.getIps().size()) { throw new VimException( "Not all (or too many) internal IPs were associated. Expected: " + vnfComponent.getConnection_point().size() + " Allocated: " + vnfcInstance.getIps().size()); if (expectedFloatingIpCount != vnfcInstance.getFloatingIps().size()) { throw new VimException( "Not all (or too many) Floating IPs were associated. Expected: " + expectedFloatingIpCount + " Allocated: " + vnfcInstance.getFloatingIps().size());
@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); }
private VNFCInstance getVnfcInstance( VirtualNetworkFunctionRecord virtualNetworkFunctionRecord, VNFComponent component) { VNFCInstance vnfcInstance_new = null; boolean found = false; for (VirtualDeploymentUnit virtualDeploymentUnit : virtualNetworkFunctionRecord.getVdu()) { for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) { if (vnfcInstance.getVnfComponent().getId().equals(component.getId())) { vnfcInstance_new = vnfcInstance; fillProvidesVNFC(virtualNetworkFunctionRecord, vnfcInstance); found = true; log.debug("VNFComponentInstance FOUND : " + vnfcInstance_new.getVnfComponent()); break; } } if (found) { break; } } return vnfcInstance_new; }
vnfcInstance_new.setState("STANDBY");
private VNFCInstance allocateVNFC( BaseVimInstance vimInstance, VirtualDeploymentUnit virtualDeploymentUnit, VirtualNetworkFunctionRecord virtualNetworkFunctionRecord, org.openbaton.nfvo.vim_interfaces.resource_management.ResourceManagement vim, VNFComponent component, String userdata, Set<Key> keys) throws InterruptedException, ExecutionException, VimException { log.trace("UserData is: " + userdata); Map<String, String> floatinIps = new HashMap<>(); for (VNFDConnectionPoint connectionPoint : component.getConnection_point()) { floatinIps.put(connectionPoint.getVirtual_link_reference(), connectionPoint.getFloatingIp()); } log.info("FloatingIp chosen are: " + floatinIps); VNFCInstance added = vim.allocate( vimInstance, virtualDeploymentUnit, virtualNetworkFunctionRecord, component, userdata, floatinIps, keys) .get(); virtualDeploymentUnit.getVnfc_instance().add(added); if (!floatinIps.isEmpty() && added.getFloatingIps().isEmpty()) log.warn("NFVO wasn't able to associate FloatingIPs. Is there enough available?"); return added; }
@Override public VnfmOrLogMessage getLog(String nsrId, String vnfrName, String hostname) throws NotFoundException, InterruptedException, BadFormatException, ExecutionException { for (VirtualNetworkFunctionRecord virtualNetworkFunctionRecord : networkServiceRecordRepository.findFirstById(nsrId).getVnfr()) { if (virtualNetworkFunctionRecord.getName().equals(vnfrName)) { for (VirtualDeploymentUnit virtualDeploymentUnit : virtualNetworkFunctionRecord.getVdu()) { for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) { if (hostname.equals(vnfcInstance.getHostname())) { log.debug("Requesting log from VNFM"); Future<NFVMessage> futureMessage = vnfmManager.requestLog(virtualNetworkFunctionRecord, hostname); VnfmOrLogMessage vnfmOrLogMessage = (VnfmOrLogMessage) futureMessage.get(); return vnfmOrLogMessage; } } } } } throw new NotFoundException("Error something was not found"); } }