Search in sources :

Example 1 with VFCInstanceGroup

use of org.onap.so.db.catalog.beans.VFCInstanceGroup in project so by onap.

the class QueryGroupsTest method createList.

private List<VnfcInstanceGroupCustomization> createList() {
    VnfcCustomization vnfcCustomization = new VnfcCustomization();
    vnfcCustomization.setModelCustomizationUUID("test");
    vnfcCustomization.setModelVersion("test");
    vnfcCustomization.setModelInvariantUUID("test");
    vnfcCustomization.setModelName("test");
    VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
    vfcInstanceGroup.setModelName("test");
    vfcInstanceGroup.setModelUUID("test");
    vfcInstanceGroup.setModelInvariantUUID("test");
    vfcInstanceGroup.setModelVersion("test");
    VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = new VnfcInstanceGroupCustomization();
    vnfcInstanceGroupCustomization.setVnfcCustomizations(Arrays.asList(vnfcCustomization));
    vnfcInstanceGroupCustomization.setInstanceGroup(vfcInstanceGroup);
    vfcInstanceGroup.setVnfcInstanceGroupCustomizations(Arrays.asList(vnfcInstanceGroupCustomization));
    return Arrays.asList(vnfcInstanceGroupCustomization);
}
Also used : VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) VnfcCustomization(org.onap.so.db.catalog.beans.VnfcCustomization) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)

Example 2 with VFCInstanceGroup

use of org.onap.so.db.catalog.beans.VFCInstanceGroup in project so by onap.

the class ToscaResourceInstaller method createVNFCInstanceGroup.

protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(IEntityDetails vfcInstanceEntity, IEntityDetails vfEntityDetails, VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure, Set<VnfcCustomization> existingVnfcGroupSet) {
    Metadata instanceMetadata = vfcInstanceEntity.getMetadata();
    InstanceGroup existingInstanceGroup = instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
    VFCInstanceGroup vfcInstanceGroup;
    if (existingInstanceGroup == null) {
        // Populate InstanceGroup
        vfcInstanceGroup = new VFCInstanceGroup();
        vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
        vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
        vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
        vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
        vfcInstanceGroup.setToscaNodeType(vfcInstanceEntity.getToscaType());
        // Set Role
        vfcInstanceGroup.setRole("SUB-INTERFACE");
        // Set type
        vfcInstanceGroup.setType(InstanceGroupType.VNFC);
    } else {
        vfcInstanceGroup = (VFCInstanceGroup) existingInstanceGroup;
    }
    // Populate VNFCInstanceGroupCustomization
    VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
    vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
    vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
    vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
    vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
    vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
    String getInputName = null;
    Map<String, Property> groupProperties = vfcInstanceEntity.getProperties();
    for (String key : groupProperties.keySet()) {
        Property property = groupProperties.get(key);
        String vfcName = property.getName();
        if (vfcName != null) {
            if (vfcName.equals("vfc_instance_group_function")) {
                String vfcValue = property.getValue().toString();
                int getInputIndex = vfcValue.indexOf("{get_input=");
                if (getInputIndex > -1) {
                    getInputName = vfcValue.substring(getInputIndex + 11, vfcValue.length() - 1);
                }
            }
        }
    }
    List<IEntityDetails> serviceEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VF).customizationUUID(vnfResourceCustomization.getModelCustomizationUUID()), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
    if (serviceEntityList != null && !serviceEntityList.isEmpty()) {
        vfcInstanceGroupCustom.setFunction(getLeafPropertyValue(serviceEntityList.get(0), getInputName));
    }
    vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
    List<Input> inputs = vfEntityDetails.getInputs();
    createVFCInstanceGroupMembers(vfcInstanceGroupCustom, vfcInstanceEntity, inputs, existingVnfcGroupSet);
    return vfcInstanceGroupCustom;
}
Also used : IEntityDetails(org.onap.sdc.tosca.parser.api.IEntityDetails) Input(org.onap.sdc.toscaparser.api.parameters.Input) GetInput(org.onap.sdc.toscaparser.api.functions.GetInput) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) Property(org.onap.sdc.toscaparser.api.Property) NetworkInstanceGroup(org.onap.so.db.catalog.beans.NetworkInstanceGroup) VFCInstanceGroup(org.onap.so.db.catalog.beans.VFCInstanceGroup) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)

Aggregations

VFCInstanceGroup (org.onap.so.db.catalog.beans.VFCInstanceGroup)2 VnfcInstanceGroupCustomization (org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)2 IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)1 Property (org.onap.sdc.toscaparser.api.Property)1 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)1 GetInput (org.onap.sdc.toscaparser.api.functions.GetInput)1 Input (org.onap.sdc.toscaparser.api.parameters.Input)1 InstanceGroup (org.onap.so.db.catalog.beans.InstanceGroup)1 NetworkInstanceGroup (org.onap.so.db.catalog.beans.NetworkInstanceGroup)1 VnfcCustomization (org.onap.so.db.catalog.beans.VnfcCustomization)1