Search in sources :

Example 1 with CapabilityAssignment

use of org.onap.sdc.toscaparser.api.CapabilityAssignment 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 2 with CapabilityAssignment

use of org.onap.sdc.toscaparser.api.CapabilityAssignment in project so by onap.

the class ToscaResourceInstaller method createVnfResourceCustomization.

protected VnfResourceCustomization createVnfResourceCustomization(IEntityDetails entityDetails, ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
    VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
    vnfResourceCustomization.setModelCustomizationUUID(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
    vnfResourceCustomization.setModelInstanceName(entityDetails.getName());
    vnfResourceCustomization.setNfFunction(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
    vnfResourceCustomization.setNfNamingCode(getLeafPropertyValue(entityDetails, "nf_naming_code"));
    vnfResourceCustomization.setNfRole(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE));
    vnfResourceCustomization.setNfType(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
    vnfResourceCustomization.setMultiStageDesign(getLeafPropertyValue(entityDetails, MULTI_STAGE_DESIGN));
    vnfResourceCustomization.setBlueprintName(getLeafPropertyValue(entityDetails, SDNC_MODEL_NAME));
    vnfResourceCustomization.setBlueprintVersion(getLeafPropertyValue(entityDetails, SDNC_MODEL_VERSION));
    String skipPostInstConfText = getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF);
    if (skipPostInstConfText != null) {
        vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF)));
    }
    vnfResourceCustomization.setControllerActor(getLeafPropertyValue(entityDetails, CONTROLLER_ACTOR));
    vnfResourceCustomization.setVnfResources(vnfResource);
    vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
    List<CapabilityAssignment> capAssignList = entityDetails.getCapabilities();
    if (capAssignList != null) {
        for (CapabilityAssignment capAssign : capAssignList) {
            if (capAssign != null) {
                String capabilityName = capAssign.getName();
                if (capabilityName.equalsIgnoreCase(SCALABLE)) {
                    vnfResourceCustomization.setMinInstances(Integer.getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
                    vnfResourceCustomization.setMaxInstances(Integer.getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
                }
            }
        }
    }
    if (vnfResourceCustomization.getMinInstances() == null && vnfResourceCustomization.getMaxInstances() == null) {
        vnfResourceCustomization.setMinInstances(Integer.getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
        vnfResourceCustomization.setMaxInstances(Integer.getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
    }
    toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
    return vnfResourceCustomization;
}
Also used : CapabilityAssignment(org.onap.sdc.toscaparser.api.CapabilityAssignment) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Aggregations

CapabilityAssignment (org.onap.sdc.toscaparser.api.CapabilityAssignment)2 IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)1 EntityQuery (org.onap.sdc.tosca.parser.elements.queries.EntityQuery)1 TopologyTemplateQuery (org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery)1 AllottedResourceCustomization (org.onap.so.db.catalog.beans.AllottedResourceCustomization)1 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)1