Search in sources :

Example 1 with TopologyTemplateQuery

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);
        }
    }
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) ISdcCsarHelper(org.onap.sdc.tosca.parser.api.ISdcCsarHelper) PnfResource(org.onap.so.db.catalog.beans.PnfResource) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery)

Example 2 with TopologyTemplateQuery

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;
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization)

Example 3 with TopologyTemplateQuery

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;
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) TopologyTemplateQuery(org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery) EntityQuery(org.onap.sdc.tosca.parser.elements.queries.EntityQuery)

Aggregations

IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)3 EntityQuery (org.onap.sdc.tosca.parser.elements.queries.EntityQuery)3 TopologyTemplateQuery (org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery)3 ISdcCsarHelper (org.onap.sdc.tosca.parser.api.ISdcCsarHelper)1 CapabilityAssignment (org.onap.sdc.toscaparser.api.CapabilityAssignment)1 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)1 AllottedResourceCustomization (org.onap.so.db.catalog.beans.AllottedResourceCustomization)1 PnfResource (org.onap.so.db.catalog.beans.PnfResource)1 PnfResourceCustomization (org.onap.so.db.catalog.beans.PnfResourceCustomization)1