use of org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery in project so by onap.
the class ToscaResourceInstaller method processPnfResources.
/**
* This is used to process the PNF specific resource, including resource and resource_customization.
* {@link IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for
* details.
*/
protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service, PnfResourceStructure resourceStructure) throws Exception {
logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
for (IEntityDetails entityDetails : entityDetailsList) {
Metadata metadata = entityDetails.getMetadata();
String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}", customizationUUID, notifCustomizationUUID);
if (checkExistingPnfResourceCutomization(customizationUUID)) {
logger.info("Resource customization UUID: {} already deployed", customizationUUID);
} else {
PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
if (pnfResource == null) {
pnfResource = createPnfResource(entityDetails);
}
PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails, pnfResource);
pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
service.getPnfCustomizations().add(pnfResourceCustomization);
}
} else {
logger.warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}", customizationUUID, notifCustomizationUUID);
}
}
}
use of org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery in project so by onap.
the class ToscaResourceInstaller method createAllottedResourceCustomization.
protected AllottedResourceCustomization createAllottedResourceCustomization(IEntityDetails arEntity, ToscaResourceStructure toscaResourceStructure) {
AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
allottedResourceCustomization.setModelCustomizationUUID(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
allottedResourceCustomization.setModelInstanceName(arEntity.getName());
allottedResourceCustomization.setNfFunction(getLeafPropertyValue(arEntity, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
allottedResourceCustomization.setNfNamingCode(getLeafPropertyValue(arEntity, "nf_naming_code"));
allottedResourceCustomization.setNfRole(getLeafPropertyValue(arEntity, SdcPropertyNames.PROPERTY_NAME_NFROLE));
allottedResourceCustomization.setNfType(getLeafPropertyValue(arEntity, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.VFC).build();
TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(allottedResourceCustomization.getModelCustomizationUUID()).build();
List<IEntityDetails> vfcEntities = toscaResourceStructure.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, false);
if (vfcEntities != null) {
for (IEntityDetails vfcEntity : vfcEntities) {
allottedResourceCustomization.setProvidingServiceModelUUID(getLeafPropertyValue(vfcEntity, "providing_service_uuid"));
allottedResourceCustomization.setProvidingServiceModelInvariantUUID(getLeafPropertyValue(vfcEntity, "providing_service_invariant_uuid"));
allottedResourceCustomization.setProvidingServiceModelName(getLeafPropertyValue(vfcEntity, "providing_service_name"));
}
}
List<CapabilityAssignment> capAssignmentList = arEntity.getCapabilities();
if (capAssignmentList != null) {
for (CapabilityAssignment arCapability : capAssignmentList) {
if (arCapability != null) {
String capabilityName = arCapability.getName();
if (capabilityName.equals(SCALABLE)) {
allottedResourceCustomization.setMinInstances(Integer.getInteger(getCapabilityLeafPropertyValue(arCapability, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
allottedResourceCustomization.setMinInstances(Integer.getInteger(getCapabilityLeafPropertyValue(arCapability, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
}
}
}
}
return allottedResourceCustomization;
}
use of org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery in project so by onap.
the class ToscaResourceInstaller method getEntityDetails.
public List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, EntityQueryBuilder entityType, TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) {
EntityQuery entityQuery = entityType.build();
TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build();
List<IEntityDetails> entityDetails = toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
return entityDetails;
}
Aggregations