use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class GeneralTopologyObjectMapperTest method buildVfModuleInformationTest_withNoModelNoRequestParameters.
@Test
public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("TestVfModuleId");
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("TestVnfId");
RequestContext requestContext = new RequestContext();
GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
try {
gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
} catch (MapperException ex) {
}
assertNotNull(gcRequestInput);
assertNull(vfModule.getModelInfoVfModule());
assertNull(gcRequestInput.getOnapModelInformation());
assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
assertNotNull(gcRequestInput.getVfModuleId());
assertTrue(gcRequestInput.getFromPreload());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class DeleteVfModuleTest method prepareVmModule.
private VfModule prepareVmModule() {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId(VF_MODULE_ID);
vfModule.setHeatStackId(HEAT_STACK_ID);
return vfModule;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VnfAdapterCreateTasks method createVfModule.
/**
* This method is used for creating the request for the VfModule.
*
* @param execution
* @return
*/
public void createVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = null;
try {
volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
} catch (BBObjectNotFoundException bbException) {
logger.info("Volume Group not found in GBB. ");
}
CloudRegion cloudRegion = gBBInput.getCloudRegion();
RequestContext requestContext = gBBInput.getRequestContext();
OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VnfAdapterCreateTasks method createVolumeGroupRequest.
/**
* This method is used for creating the request for the VolumeGroup.
*
* @param execution
* @return
*/
public void createVolumeGroupRequest(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
VfModule vfModule;
String sdncVfModuleQueryResponse = null;
try {
vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
} else {
throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
}
} catch (BBObjectNotFoundException bbException) {
logger.error("Exception occurred", bbException);
// If there is not a vf module in the general building block (in aLaCarte case),
// we will not retrieve
// the SDNCQueryResponse and proceed as normal without throwing an error
}
CreateVolumeGroupRequest createVolumeGroupRequest = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
execution.setVariable(VNFREST_REQUEST, createVolumeGroupRequest.toXmlString());
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VnfAdapterImpl method processVfModuleOutputs.
private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String, String> vfModuleOutputs) {
if (vfModuleOutputs == null) {
return;
}
try {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
List<String> contrailNetworkPolicyFqdnList = new ArrayList<>();
Iterator<String> keys = vfModuleOutputs.keySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
if (key.equals("contrail-service-instance-fqdn")) {
String contrailServiceInstanceFqdn = vfModuleOutputs.get(key);
logger.debug("Obtained contrailServiceInstanceFqdn: {}", contrailServiceInstanceFqdn);
vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn);
} else if (key.endsWith("contrail_network_policy_fqdn")) {
String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key);
logger.debug("Obtained contrailNetworkPolicyFqdn: {}", contrailNetworkPolicyFqdn);
contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn);
} else if (key.equals("oam_management_v4_address")) {
String oamManagementV4Address = vfModuleOutputs.get(key);
logger.debug("Obtained oamManagementV4Address: {}", oamManagementV4Address);
genericVnf.setIpv4OamAddress(oamManagementV4Address);
execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address);
} else if (key.equals("oam_management_v6_address")) {
String oamManagementV6Address = vfModuleOutputs.get(key);
logger.debug("Obtained oamManagementV6Address: {}", oamManagementV6Address);
genericVnf.setManagementV6Address(oamManagementV6Address);
execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address);
}
if (!contrailNetworkPolicyFqdnList.isEmpty()) {
execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, String.join(",", contrailNetworkPolicyFqdnList));
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
Aggregations