use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.
the class GeneratePayloadForCdsTest method testBuildCdsPropertiesBeanCreateService.
@Test
public void testBuildCdsPropertiesBeanCreateService() throws Exception {
// given
final String servicePayload = "{\"create-request\":{\"resolution-key\":\"test-service-instance\",\"create-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\"}}}";
setScopeAndAction(SERVICE_SCOPE, SERVICE_ACTION);
doReturn(Optional.of(servicePayload)).when(serviceCDSRequestProvider).buildRequestPayload(SERVICE_ACTION);
// when
AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
// verify
assertNotNull(propertyBean);
String payload = propertyBean.getRequestObject();
assertThat(servicePayload.equals(payload));
assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
assertThat(propertyBean.getOriginatorId().equals("SO"));
assertNotNull(propertyBean.getSubRequestId());
assertThat(propertyBean.getActionName().equals(SERVICE_ACTION));
assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
}
use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.
the class GenericCDSProcessingBB method prepare.
@Override
public void prepare(ControllerContext<BuildingBlockExecution> context) {
BuildingBlockExecution buildingBlockExecution = context.getExecution();
try {
AbstractCDSPropertiesBean abstractCDSPropertiesBean = generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
} catch (Exception ex) {
logger.error("An exception occurred when creating payload for CDS request", ex);
exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex);
}
}
use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.
the class ConfigAssignVnf method preProcessAbstractCDSProcessing.
/**
* Getting the vnf data, blueprint name, blueprint version etc and setting them in execution object and calling the
* subprocess.
*/
public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
logger.info("Start preProcessAbstractCDSProcessing ");
try {
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf();
configAssignPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
configAssignPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
configAssignPropertiesForVnf.setVnfCustomizationUuid(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid());
configAssignPropertiesForVnf.setVnfId(genericVnf.getVnfId());
configAssignPropertiesForVnf.setVnfName(genericVnf.getVnfName());
setUserParamsInConfigAssignPropertiesForVnf(configAssignPropertiesForVnf, execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams(), genericVnf);
ConfigAssignRequestVnf configAssignRequestVnf = new ConfigAssignRequestVnf();
configAssignRequestVnf.setResolutionKey(genericVnf.getVnfName());
configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf);
String blueprintName = genericVnf.getModelInfoGenericVnf().getBlueprintName();
String blueprintVersion = genericVnf.getModelInfoGenericVnf().getBlueprintVersion();
logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion);
AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
abstractCDSPropertiesBean.setBlueprintName(blueprintName);
abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
abstractCDSPropertiesBean.setRequestObject(configAssignRequestVnf.toString());
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
abstractCDSPropertiesBean.setActionName(ACTION_NAME);
abstractCDSPropertiesBean.setMode(MODE);
execution.setVariable("executionObject", abstractCDSPropertiesBean);
} catch (Exception ex) {
logger.error("An exception occurred when creating ConfigAssignPropertiesForVnf for CDS request", ex);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.
the class ConfigDeployVnf method preProcessAbstractCDSProcessing.
/**
* Getting the vnf object and set in execution object
*
* @param execution
*/
public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
logger.info("Start preProcessAbstractCDSProcessing");
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf();
configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
configDeployPropertiesForVnf.setVnfId(vnf.getVnfId());
configDeployPropertiesForVnf.setVnfName(vnf.getVnfName());
ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf();
configDeployRequestVnf.setResolutionKey(vnf.getVnfName());
configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf);
String blueprintName = vnf.getModelInfoGenericVnf().getBlueprintName();
String blueprintVersion = vnf.getModelInfoGenericVnf().getBlueprintVersion();
logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion);
AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
abstractCDSPropertiesBean.setBlueprintName(blueprintName);
abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
abstractCDSPropertiesBean.setActionName(ACTION_NAME);
abstractCDSPropertiesBean.setMode(MODE);
execution.setVariable("executionObject", abstractCDSPropertiesBean);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.
the class GenericPnfCDSControllerRunnableBB method prepareAndSetCdsPropertyBean.
private AbstractCDSPropertiesBean prepareAndSetCdsPropertyBean(BuildingBlockExecution buildingBlockExecution) {
final AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
final String action = getAction(buildingBlockExecution);
if (action == null) {
exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, "Action is null!", ONAPComponents.SO);
}
abstractCDSPropertiesBean.setRequestObject(this.buildRequestPayload(action, buildingBlockExecution));
abstractCDSPropertiesBean.setBlueprintName(buildingBlockExecution.getVariable(PRC_BLUEPRINT_NAME));
abstractCDSPropertiesBean.setBlueprintVersion(buildingBlockExecution.getVariable(PRC_BLUEPRINT_VERSION));
abstractCDSPropertiesBean.setRequestId(buildingBlockExecution.getVariable(MSO_REQUEST_ID));
abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
abstractCDSPropertiesBean.setActionName(action);
abstractCDSPropertiesBean.setMode(DEFAULT_SYNC_MODE);
return abstractCDSPropertiesBean;
}
Aggregations