use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class ControllerExecutionBB method getControllerActor.
/**
* this method is used to get the controller actor, there could be few places to get the actor(ordered by priority),
*
* <ol>
* <li>Execution Context, i.e, BuildingBlockExecution</li>
* <li>Resource customization table, pnf_resource_customization for PNF or vnf_resource_customization for VNF</li>
* <li>controller_selection_reference, resource_type and action will be used to fetch from this table</li>
* </ol>
*
* @param execution BuildingBlockExecution instance
* @param controllerScope controller scope, e.g, pnf, vnf, vfModule
* @param resourceCustomizationUuid resource customization UUID, e.g, pnfCustomizationUuid, vnfCustomizationUuid
* @param controllerAction controller action, e.g, configAssign, configDeploy
* @return controller actor name
*/
@Override
protected String getControllerActor(BuildingBlockExecution execution, String controllerScope, String resourceCustomizationUuid, String controllerAction) {
/**
* Firstly, check the execution context for actor parameter.
*/
String controllerActor = getParameterFromExecution(execution, CONTROLLER_ACTOR_PARAM);
/**
* If no meaningful controller actor value found in the execution context and the value is not SO-REF-DATA.
*/
if (Strings.isNullOrEmpty(controllerActor) && !isSoRefControllerActor(controllerActor)) {
/**
* For BuildingBlockExecution, we should try to get the resource information from Cached metadata.
*
* As the current cached metadata doesn't support controller actor, we use the
* {@link org.onap.so.db.catalog.client.CatalogDbClient} to fetch information. Once the change is done in
* cached metadata, this part should be refactored as well.
*/
if (isPnfResourceScope(controllerScope)) {
PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
controllerActor = pnfResourceCustomization.getControllerActor();
} else if (isServiceResourceScope(controllerScope)) {
return controllerActor;
} else if (isVnfResourceScope(controllerScope)) {
VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
controllerActor = vnfResourceCustomization.getControllerActor();
} else {
logger.warn("Unrecognized scope: {}", controllerScope);
}
}
/**
* Lastly, can NOT find the controller actor information from resource customization table or the return value
* is SO-REF-DATA.
*/
if (Strings.isNullOrEmpty(controllerActor) || isSoRefControllerActor(controllerActor)) {
String resourceType = getParameterFromExecution(execution, RESOURCE_TYPE_PARAM);
ControllerSelectionReference reference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(resourceType, controllerAction);
controllerActor = reference.getControllerName();
}
return controllerActor;
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class ToscaResourceInstaller method createVnfResource.
protected VnfResourceCustomization createVnfResource(IEntityDetails entityDetails, ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException {
VnfResourceCustomization vnfResourceCustomization = null;
if (vnfResourceCustomization == null) {
VnfResource vnfResource = findExistingVnfResource(service, entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (vnfResource == null) {
vnfResource = createVnfResource(entityDetails);
}
vnfResourceCustomization = createVnfResourceCustomization(entityDetails, toscaResourceStructure, vnfResource);
vnfResourceCustomization.setVnfResources(vnfResource);
vnfResourceCustomization.setService(service);
// setting resource input for vnf customization
vnfResourceCustomization.setResourceInput(getResourceInput(toscaResourceStructure, vnfResourceCustomization.getModelCustomizationUUID()));
}
return vnfResourceCustomization;
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class ASDCRestInterfaceTest method test_Vcpe_Infra_Distribution.
@Test
public void test_Vcpe_Infra_Distribution() throws Exception {
wireMockServer.stubFor(post(urlPathMatching("/aai/.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.ACCEPTED.value())));
String resourceLocation = "src/test/resources/resource-examples/vcpe-infra/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demovcpeinfra-notification.json"), NotificationDataImpl.class);
headers.add("resource-location", resourceLocation);
HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, String.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
Optional<ToscaCsar> toscaCsar = toscaCsarRepo.findById("144606d8-a505-4ba0-90a9-6d1c6219fc6b");
assertTrue(toscaCsar.isPresent());
assertEquals("service-Demovcpeinfra-csar.csar", toscaCsar.get().getName());
Optional<Service> service = serviceRepo.findById("8a77cbbb-9850-40bb-a42f-7aec8e3e6ab7");
assertTrue(service.isPresent());
assertEquals("demoVCPEInfra", service.get().getModelName());
Optional<NetworkResource> networkResource = networkRepo.findById("89789b26-a46b-4cee-aed0-d46e21f93a5e");
assertTrue(networkResource.isPresent());
assertEquals("Generic NeutronNet", networkResource.get().getModelName());
List<VnfResourceCustomization> vnfCustomizationResources = vnfCustRepo.findByModelCustomizationUUID("01564fe7-0541-4d92-badc-464cc35f83ba");
for (VnfResourceCustomization vnfResourceCustomization : vnfCustomizationResources) {
assertTrue(vnfResourceCustomization.getVfModuleCustomizations().stream().anyMatch(vfModuleCust -> "354b1e83-47db-4af1-8af4-9c14b03b482d".equals(vfModuleCust.getModelCustomizationUUID())));
}
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class SkipCDSBuildingBlockListener method run.
/**
* Skip the CDS Building block according to the Skip Flag.
*
* @param flowsToExecute - List of ExecuteBuildingBlock object.
* @param execution - BuildingBlockExecution object
* @param currentBB - ExecuteBuildingBlock object
*/
@Override
public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) {
String resourceKey = currentBB.getBuildingBlock().getKey();
List<Resource> resources = execution.getVariable("resources");
Resource resource = resources.stream().filter(r -> resourceKey.equals(r.getResourceId())).findFirst().orElseThrow(() -> new IllegalArgumentException("Resource not found for key:" + resourceKey));
String scope = currentBB.getBuildingBlock().getBpmnScope();
if ("SERVICE".equalsIgnoreCase(scope)) {
Service service = catalogDbClient.getServiceByID(resource.getModelVersionId());
currentSequenceSkipCheck(execution, service.getSkipPostInstConf());
} else if ("VNF".equalsIgnoreCase(scope) && containsIgnoreCaseAction(currentBB, vnfActions)) {
VnfResourceCustomization vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
if (vrc != null) {
logger.debug("getSkipPostInstConf value: " + vrc.getSkipPostInstConf());
boolean skipConfigVNF = vrc.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipConfigVNF);
}
} else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule") && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
VfModuleCustomization vfc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(resource.getModelCustomizationId());
if (null != vfc) {
logger.debug("getSkipPostInstConf value: " + vfc.getSkipPostInstConf().booleanValue());
boolean skipVfModule = vfc.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipVfModule);
}
} else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") && containsIgnoreCaseAction(currentBB, pnfActions)) {
PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resource.getModelCustomizationId());
if (null != pnfResourceCustomization) {
logger.debug("getSkipPostInstConf value: " + pnfResourceCustomization.getSkipPostInstConf());
boolean skipConfigPNF = pnfResourceCustomization.getSkipPostInstConf();
currentSequenceSkipCheck(execution, skipConfigPNF);
}
}
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class MultiStageSkipListener method run.
@Override
public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) {
String vfModuleId = currentBB.getResourceId();
String vnfId = currentBB.getWorkflowResourceIds().getVnfId();
org.onap.aai.domain.yang.VfModule vfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
if (vfModule == null) {
org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
if (vnf != null) {
VnfResourceCustomization vnfCust = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId());
if (vnfCust != null && vnfCust.getMultiStageDesign() != null && vnfCust.getMultiStageDesign().equalsIgnoreCase("true")) {
flowsToExecute.retainAll(Collections.singletonList(currentBB));
execution.setVariable(G_MULTI_STAGE_DESIGN, Boolean.valueOf(vnfCust.getMultiStageDesign()));
}
}
}
}
Aggregations