本文整理汇总了Java中org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit.getVnfc_instance方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualDeploymentUnit.getVnfc_instance方法的具体用法?Java VirtualDeploymentUnit.getVnfc_instance怎么用?Java VirtualDeploymentUnit.getVnfc_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit
的用法示例。
在下文中一共展示了VirtualDeploymentUnit.getVnfc_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWork
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@Override
protected NFVMessage doWork() throws Exception {
log.info("Release resources for VNFR: " + virtualNetworkFunctionRecord.getName());
for (VirtualDeploymentUnit virtualDeploymentUnit : virtualNetworkFunctionRecord.getVdu()) {
log.debug(
"Removing VDU: "
+ virtualDeploymentUnit.getHostname()
+ " from VNFR "
+ virtualNetworkFunctionRecord.getId());
for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) {
log.debug(
"Removing VNFC instance: "
+ vnfcInstance
+ " from VNFR "
+ virtualNetworkFunctionRecord.getId());
this.resourceManagement.release(virtualDeploymentUnit, vnfcInstance);
}
}
setHistoryLifecycleEvent(new Date());
saveVirtualNetworkFunctionRecord();
return null;
}
示例2: getVNFCInstance
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
/**
* Returns the VNFCInstance with the passed ID from a specific VDU. If null is passed for the
* VNFCInstance ID, the first VNFCInstance in the VDU is returned.
*
* @param virtualDeploymentUnit the VDU holding the VNFCinstance
* @param idVNFCI the id of the VNFCInstance
* @return the VNFCinstance
* @throws NotFoundException if not found
*/
private VNFCInstance getVNFCInstance(VirtualDeploymentUnit virtualDeploymentUnit, String idVNFCI)
throws NotFoundException {
for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) {
if (idVNFCI == null || idVNFCI.equals(vnfcInstance.getId())) {
return vnfcInstance;
}
}
if (idVNFCI != null) {
throw new NotFoundException(
"VNFCInstance with ID "
+ idVNFCI
+ " was not found in VDU with ID "
+ virtualDeploymentUnit.getId());
} else {
throw new NotFoundException(
"No VNFCInstance found in VDU with ID " + virtualDeploymentUnit.getId());
}
}
示例3: getLog
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@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");
}
示例4: getVnfcInstance
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
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;
}
示例5: updateSoftware
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@Override
public VirtualNetworkFunctionRecord updateSoftware(
Script script, VirtualNetworkFunctionRecord virtualNetworkFunctionRecord) throws Exception {
for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) {
for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) {
updateScript(script, virtualNetworkFunctionRecord, vnfcInstance);
}
}
return virtualNetworkFunctionRecord;
}
示例6: terminate
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@Override
public VirtualNetworkFunctionRecord terminate(
VirtualNetworkFunctionRecord virtualNetworkFunctionRecord) throws Exception {
log.debug("Termination of VNF: " + virtualNetworkFunctionRecord.getName());
if (VnfmUtils.getLifecycleEvent(
virtualNetworkFunctionRecord.getLifecycle_event(), Event.TERMINATE)
!= null) {
StringBuilder output = new StringBuilder("\n--------------------\n--------------------\n");
for (String result :
lcm.executeScriptsForEvent(virtualNetworkFunctionRecord, Event.TERMINATE)) {
output.append(JsonUtils.parse(result));
output.append("\n--------------------\n");
}
output.append("\n--------------------\n");
log.info("Executed script for TERMINATE. Output was: \n\n" + output);
}
for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) {
for (VNFCInstance vnfci : vdu.getVnfc_instance()) {
try {
ems.removeRegistrationUnit(vnfci.getHostname());
} catch (BadFormatException e) {
e.printStackTrace();
}
}
}
return virtualNetworkFunctionRecord;
}
示例7: getVNFCHostname
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
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;
}
示例8: getVnfcId
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
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;
}
示例9: getVnfcInSuchState
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
private VNFCInstance getVnfcInSuchState(String state) {
for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) {
for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) {
if (vnfcInstance.getState() != null && vnfcInstance.getState().equals(state)) {
return vnfcInstance;
}
}
}
return null;
}
示例10: fillVnfrVnfc
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
/**
* Fill the Map vnfrVnfc.
*
* @param nsr
*/
private void fillVnfrVnfc(NetworkServiceRecord nsr) {
for (VirtualNetworkFunctionRecord vnfr : nsr.getVnfr()) {
List<VNFCRepresentation> representationList = new LinkedList<>();
Configuration conf = vnfr.getConfigurations();
Map<String, String> confMap = new HashMap<>();
for (ConfigurationParameter confPar : conf.getConfigurationParameters()) {
confMap.put(confPar.getConfKey(), confPar.getValue());
}
for (VirtualDeploymentUnit vdu : vnfr.getVdu()) {
for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) {
VNFCRepresentation vnfcRepresentation = new VNFCRepresentation();
vnfcRepresentation.setVnfrName(vnfr.getName());
vnfcRepresentation.setHostname(vnfcInstance.getHostname());
vnfcRepresentation.setConfiguration(confMap);
for (Ip ip : vnfcInstance.getIps()) {
vnfcRepresentation.addNetIp(ip.getNetName(), ip.getIp());
}
for (Ip fIp : vnfcInstance.getFloatingIps()) {
vnfcRepresentation.addNetFip(fIp.getNetName(), fIp.getIp());
}
representationList.add(vnfcRepresentation);
}
}
if (!vnfrVnfc.containsKey(vnfr.getType())) {
vnfrVnfc.put(vnfr.getType(), representationList);
} else {
List<VNFCRepresentation> l = vnfrVnfc.get(vnfr.getType());
l.addAll(representationList);
}
}
}
示例11: status
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
/**
* Checks the lifecycle status of the NSR referenced by the occi-Id.
* If the creation is completed all public and private ip's of the
* vnfds are returned as well.
*
* @param response HttpServletResponse object containing to be returned header
* @param headers HttpHeaders object containing the request headers
* @return simple OK
* @throws SDKException
*/
@RequestMapping(value = "/default", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public String status(HttpServletResponse response, @RequestHeader HttpHeaders headers) throws SDKException {
String occiId = getOcciId(headers);
log.debug("Received status request for instance " + occiId);
if (occiId != null) {
Stack stack = stacks.get(occiId);
if (Objects.equals(stack.getStatus(), "CREATE_COMPLETE")) {
for (VirtualNetworkFunctionRecord record : stack.getVirtualNFRs()) {
// TODO: proper formatting, this may also go in the return header!
String attributePrefix = occiProperties.getPrefix() + ".";
String endpoint = "";
for (VirtualDeploymentUnit vdu : record.getVdu()) {
for (VNFCInstance vnfc : vdu.getVnfc_instance()) {
// Get all private Ip's
for (Ip privateIp : vnfc.getIps()) {
response.addHeader("X-OCCI-Attribute", attributePrefix + record.getName() + "." +
privateIp.getNetName() + ".private=\"" + privateIp.getIp() + "\"");
endpoint = "\"" + privateIp.getIp() + "\"";
}
// Get all public Ip's
for (Ip publicIp : vnfc.getFloatingIps()) {
response.addHeader("X-OCCI-Attribute", attributePrefix + record.getName() + "." +
publicIp.getNetName() + ".public=\"" + publicIp.getIp() + "\"");
endpoint = "\"" + publicIp.getIp() + "\"";
}
}
}
// Set "endpoint" Ip, private if no public Ip's were found, public otherwise.
response.addHeader("X-OCCI-Attribute", attributePrefix + record.getName() + "=" + endpoint);
}
}
response.addHeader("X-OCCI-Attribute", "occi.stack.state=\"" + stack.getStatus() + "\"");
response.addHeader("X-OCCI-Attribute", "occi.stack.id=\"" + stack.getCount() + "\"");
response.addHeader("X-OCCI-Attribute", "occi.core.id=\"" + apiPath + "default\"");
}
return "OK";
}
示例12: getRawMeasurementResults
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
public synchronized List<Item> getRawMeasurementResults(
VirtualNetworkFunctionRecord vnfr, String metric, String period)
throws MonitoringException, NotFoundException {
if (monitor == null) {
initializeMonitor();
}
ArrayList<Item> measurementResults = new ArrayList<Item>();
ArrayList<String> hostnames = new ArrayList<String>();
ArrayList<String> metrics = new ArrayList<String>();
metrics.add(metric);
log.debug(
"Getting all measurement results for vnfr " + vnfr.getId() + " on metric " + metric + ".");
for (VirtualDeploymentUnit vdu : vnfr.getVdu()) {
for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) {
if (vnfcInstance.getState() == null
|| vnfcInstance.getState().toLowerCase().equals("active")) {
hostnames.add(vnfcInstance.getHostname());
}
}
}
log.trace(
"Getting all measurement results for hostnames "
+ hostnames
+ " on metric "
+ metric
+ ".");
measurementResults.addAll(monitor.queryPMJob(hostnames, metrics, period));
if (hostnames.size() != measurementResults.size()) {
throw new MonitoringException(
"Requested amount of measurements is greater than the received amount of measurements -> "
+ hostnames.size()
+ ">"
+ measurementResults.size());
}
log.debug(
"Got all measurement results for vnfr "
+ vnfr.getId()
+ " on metric "
+ metric
+ " -> "
+ measurementResults
+ ".");
return measurementResults;
}
示例13: heal
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@Override
public VirtualNetworkFunctionRecord heal(
VirtualNetworkFunctionRecord virtualNetworkFunctionRecord,
VNFCInstance component,
String cause)
throws Exception {
if ("switchToStandby".equals(cause)) {
for (VirtualDeploymentUnit virtualDeploymentUnit : virtualNetworkFunctionRecord.getVdu()) {
for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) {
if (vnfcInstance.getId().equals(component.getId())
&& "standby".equalsIgnoreCase(vnfcInstance.getState())) {
log.debug("Activation of the standby component");
if (VnfmUtils.getLifecycleEvent(
virtualNetworkFunctionRecord.getLifecycle_event(), Event.START)
!= null) {
log.debug(
"Executed scripts for event START "
+ lcm.executeScriptsForEvent(
virtualNetworkFunctionRecord, component, Event.START));
}
log.debug("Changing the status from standby to active");
//This is inside the vnfr
vnfcInstance.setState("ACTIVE");
// This is a copy of the object received as parameter and modified.
// It will be sent to the orchestrator
component.setState("ACTIVE");
break;
}
}
}
} else if (VnfmUtils.getLifecycleEvent(
virtualNetworkFunctionRecord.getLifecycle_event(), Event.HEAL)
!= null) {
if (VnfmUtils.getLifecycleEvent(virtualNetworkFunctionRecord.getLifecycle_event(), Event.HEAL)
.getLifecycle_events()
!= null) {
log.debug("Heal method started");
log.info("-----------------------------------------------------------------------");
StringBuilder output = new StringBuilder("\n--------------------\n--------------------\n");
for (String result :
lcm.executeScriptsForEvent(
virtualNetworkFunctionRecord, component, Event.HEAL, cause)) {
output.append(JsonUtils.parse(result));
output.append("\n--------------------\n");
}
output.append("\n--------------------\n");
log.info("Executed script for HEAL. Output was: \n\n" + output);
log.info("-----------------------------------------------------------------------");
}
}
return virtualNetworkFunctionRecord;
}
示例14: executeScriptsForEvent
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
public Iterable<String> executeScriptsForEvent(
VirtualNetworkFunctionRecord virtualNetworkFunctionRecord, Event event)
throws Exception { //TODO make it parallel
Map<String, String> env = getMap(virtualNetworkFunctionRecord);
Collection<String> res = new ArrayList<>();
LifecycleEvent le =
VnfmUtils.getLifecycleEvent(virtualNetworkFunctionRecord.getLifecycle_event(), event);
if (le != null) {
log.trace(
"The number of scripts for "
+ virtualNetworkFunctionRecord.getName()
+ " are: "
+ le.getLifecycle_events());
for (String script : le.getLifecycle_events()) {
log.info(
"Sending script: "
+ script
+ " to VirtualNetworkFunctionRecord: "
+ virtualNetworkFunctionRecord.getName());
for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) {
for (VNFCInstance vnfcInstance : vdu.getVnfc_instance()) {
Map<String, String> tempEnv = new HashMap<>();
for (Ip ip : vnfcInstance.getIps()) {
log.debug("Adding net: " + ip.getNetName() + " with value: " + ip.getIp());
tempEnv.put(ip.getNetName(), ip.getIp());
}
log.debug("adding floatingIp: " + vnfcInstance.getFloatingIps());
for (Ip fip : vnfcInstance.getFloatingIps()) {
tempEnv.put(fip.getNetName() + "_floatingIp", fip.getIp());
}
tempEnv.put("hostname", vnfcInstance.getHostname());
tempEnv = modifyUnsafeEnvVarNames(tempEnv);
env.putAll(tempEnv);
log.info("Environment Variables are: " + env);
String command = JsonUtils.getJsonObject("EXECUTE", script, env).toString();
String output =
ems.executeActionOnEMS(
vnfcInstance.getHostname(),
command,
virtualNetworkFunctionRecord,
vnfcInstance);
res.add(output);
log.debug("Saving log to file...");
logUtils.saveLogToFile(virtualNetworkFunctionRecord, script, vnfcInstance, output);
for (String key : tempEnv.keySet()) {
env.remove(key);
}
}
}
}
}
return res;
}
示例15: startStopVNFCInstance
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
private void startStopVNFCInstance(
String id, String idVnf, String idVdu, String idVNFCI, String projectId, Action action)
throws NotFoundException, BadFormatException, ExecutionException, InterruptedException {
NetworkServiceRecord networkServiceRecord = getNetworkServiceRecordInAnyState(id, projectId);
VirtualNetworkFunctionRecord virtualNetworkFunctionRecord =
getVirtualNetworkFunctionRecord(idVnf, networkServiceRecord);
if (!virtualNetworkFunctionRecord.getProjectId().equals(projectId)) {
throw new UnauthorizedUserException(
"VNFR not under the project chosen, are you trying to hack us? Just kidding, it's a bug :)");
}
VirtualDeploymentUnit virtualDeploymentUnit =
getVirtualDeploymentUnit(idVdu, virtualNetworkFunctionRecord);
if (virtualDeploymentUnit.getProjectId() != null
&& !virtualDeploymentUnit.getProjectId().equals(projectId)) {
throw new UnauthorizedUserException(
"VDU not under the project chosen, are you trying to hack us? Just kidding, it's a bug :)");
}
VNFCInstance vnfcInstanceToStartStop = null;
for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) {
log.debug(
"VNFCInstance: (ID: "
+ vnfcInstance.getId()
+ " - HOSTNAME: "
+ vnfcInstance.getHostname()
+ " - STATE: "
+ vnfcInstance.getState()
+ ")");
if (vnfcInstance.getId().equals(idVNFCI)) {
vnfcInstanceToStartStop = vnfcInstance;
switch (action) {
case START:
log.debug(
"VNFCInstance to be started: "
+ vnfcInstanceToStartStop.getId()
+ " - "
+ vnfcInstanceToStartStop.getHostname());
break;
case STOP:
log.debug(
"VNFCInstance to be stopped: "
+ vnfcInstanceToStartStop.getId()
+ " - "
+ vnfcInstanceToStartStop.getHostname());
break;
}
}
}
if (vnfcInstanceToStartStop == null) {
switch (action) {
case START:
throw new NotFoundException("VNFCInstance to be started NOT FOUND");
case STOP:
throw new NotFoundException("VNFCInstance to be stopped NOT FOUND");
}
}
OrVnfmStartStopMessage startStopMessage =
new OrVnfmStartStopMessage(virtualNetworkFunctionRecord, vnfcInstanceToStartStop);
switch (action) {
case START:
startStopMessage.setAction(Action.START);
break;
case STOP:
startStopMessage.setAction(Action.STOP);
break;
}
vnfStateHandler.sendMessageToVNFR(virtualNetworkFunctionRecord, startStopMessage);
}