本文整理汇总了Java中org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit.getProjectId方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualDeploymentUnit.getProjectId方法的具体用法?Java VirtualDeploymentUnit.getProjectId怎么用?Java VirtualDeploymentUnit.getProjectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit
的用法示例。
在下文中一共展示了VirtualDeploymentUnit.getProjectId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteVNFCInstance
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@Override
public void deleteVNFCInstance(String id, String idVnf, String idVdu, String projectId)
throws NotFoundException, WrongStatusException, InterruptedException, ExecutionException,
VimException, PluginException, BadFormatException {
log.info("Removing VNFCInstance from VNFR with id: " + idVnf + " in vdu: " + idVdu);
NetworkServiceRecord networkServiceRecord = getNetworkServiceRecordInActiveState(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 = null;
for (VirtualDeploymentUnit vdu : virtualNetworkFunctionRecord.getVdu()) {
if (vdu.getId().equals(idVdu)
&& vdu.getProjectId() != null
&& vdu.getProjectId().equals(projectId)) {
virtualDeploymentUnit = vdu;
}
}
if (virtualDeploymentUnit == null) {
throw new NotFoundException("No VirtualDeploymentUnit found");
}
if (virtualDeploymentUnit.getVnfc_instance().size() == 1) {
throw new WrongStatusException(
"The VirtualDeploymentUnit chosen has reached the minimum number of VNFCInstance");
}
VNFCInstance vnfcInstance = getVNFCInstance(virtualDeploymentUnit, null);
networkServiceRecord.setStatus(Status.SCALING);
networkServiceRecord = nsrRepository.saveCascade(networkServiceRecord);
scaleIn(
networkServiceRecord, virtualNetworkFunctionRecord, virtualDeploymentUnit, vnfcInstance);
}
示例2: 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);
}
示例3: switchToRedundantVNFCInstance
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
@Override
public void switchToRedundantVNFCInstance(
String id,
String idVnf,
String idVdu,
String idVNFC,
String mode,
VNFCInstance failedVnfcInstance,
String projectId)
throws NotFoundException, WrongStatusException, BadFormatException, ExecutionException,
InterruptedException {
NetworkServiceRecord networkServiceRecord = getNetworkServiceRecordInActiveState(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 :)");
}
networkServiceRecord.setTask("Healing");
VNFCInstance standByVNFCInstance = null;
for (VNFCInstance vnfcInstance : virtualDeploymentUnit.getVnfc_instance()) {
log.debug("current vnfcinstance " + vnfcInstance + " in state" + vnfcInstance.getState());
if (vnfcInstance.getState() != null && vnfcInstance.getState().equalsIgnoreCase(mode)) {
standByVNFCInstance = vnfcInstance;
log.debug("VNFComponentInstance in " + mode + " mode FOUND :" + standByVNFCInstance);
}
if (vnfcInstance.getId().equals(failedVnfcInstance.getId())) {
vnfcInstance.setState("FAILED");
log.debug(
"The vnfcInstance: "
+ vnfcInstance.getHostname()
+ " is set to '"
+ vnfcInstance.getState()
+ "' state");
}
}
if (standByVNFCInstance == null) {
throw new NotFoundException(
"No VNFCInstance in "
+ mode
+ " mode found, so switch to redundant VNFC is not "
+ "possibile");
}
//save the new state of the failedVnfcInstance
nsrRepository.saveCascade(networkServiceRecord);
OrVnfmHealVNFRequestMessage healMessage = new OrVnfmHealVNFRequestMessage();
healMessage.setAction(Action.HEAL);
healMessage.setVirtualNetworkFunctionRecord(virtualNetworkFunctionRecord);
healMessage.setVnfcInstance(standByVNFCInstance);
healMessage.setCause("switchToStandby");
vnfStateHandler.sendMessageToVNFR(virtualNetworkFunctionRecord, healMessage);
}
示例4: executeAction
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit; //导入方法依赖的package包/类
/**
* Triggers the execution of an {@link org.openbaton.catalogue.nfvo.Action} on a specific
* VNFCInstance.
*
* <p>
*
* <p>
*
* <p>
*
* <p>Note: Currently only the HEAL action is supported.
*
* @param nfvMessage the NFVMessage to send
* @param nsrId the NSR id
* @param idVnf the VNFR id
* @param idVdu the VDU id
* @param idVNFCI the VNFCInstance id
* @param projectId the current project id
* @throws NotFoundException if something is not found
*/
@Override
public void executeAction(
NFVMessage nfvMessage,
String nsrId,
String idVnf,
String idVdu,
String idVNFCI,
String projectId)
throws NotFoundException, BadFormatException, ExecutionException, InterruptedException {
log.info("Executing action: " + nfvMessage.getAction() + " on VNF with id: " + idVnf);
NetworkServiceRecord networkServiceRecord =
nsrRepository.findFirstByIdAndProjectId(nsrId, projectId);
if (networkServiceRecord == null) {
throw new NotFoundException("No NSR found with ID " + nsrId);
}
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 vnfcInstance = getVNFCInstance(virtualDeploymentUnit, idVNFCI);
switch (nfvMessage.getAction()) {
case HEAL:
// Note: when we get a HEAL message from the API, it contains only the cause (no vnfr or vnfcInstance).
// Here the vnfr and the vnfcInstance are set into the message, since they are updated.
VnfmOrHealedMessage VnfmOrHealVNFRequestMessage = (VnfmOrHealedMessage) nfvMessage;
log.debug("Received Heal message: " + VnfmOrHealVNFRequestMessage);
VnfmOrHealVNFRequestMessage.setVirtualNetworkFunctionRecord(virtualNetworkFunctionRecord);
VnfmOrHealVNFRequestMessage.setVnfcInstance(vnfcInstance);
vnfStateHandler.sendMessageToVNFR(
virtualNetworkFunctionRecord, VnfmOrHealVNFRequestMessage);
break;
}
}