Search in sources :

Example 31 with InstanceGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.

the class VnfTopologyOperationRequestMapper method reqMapper.

/**
 * This method is used for creating the vnf request.
 *
 * By these parameter it will get he detailas and prepare the request.
 *
 * @param svcOperation
 * @param svcAction
 * @param requestAction
 * @param vnf
 * @param serviceInstance
 * @param customer
 * @param cloudRegion
 * @param requestContext
 * @param homing
 * @return request
 */
public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, URI callbackUrl) {
    String sdncReqId = UUID.randomUUID().toString();
    String msoRequestId = UUID.randomUUID().toString();
    if (requestContext != null && requestContext.getMsoRequestId() != null) {
        msoRequestId = requestContext.getMsoRequestId();
    }
    GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation();
    GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString());
    GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
    GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
    GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, true);
    GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput = new GenericResourceApiVnfrequestinputVnfRequestInput();
    vnfRequestInput.setTenant(cloudRegion.getTenantId());
    vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
    vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
    if (StringUtils.isNotBlank(vnf.getVnfName())) {
        vnfRequestInput.setVnfName(vnf.getVnfName());
    }
    req.setRequestInformation(requestInformation);
    req.setSdncRequestHeader(sdncRequestHeader);
    req.setServiceInformation(serviceInformation);
    req.setVnfInformation(vnfInformation);
    GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam();
    if (requestContext != null && requestContext.getUserParams() != null) {
        for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
            GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
            paramItem.setName(entry.getKey());
            paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
            vnfInputParameters.addParamItem(paramItem);
            vnfRequestInput.setVnfInputParameters(vnfInputParameters);
        }
    }
    if (vnf.getCloudParams() != null) {
        for (Map.Entry<String, String> entry : vnf.getCloudParams().entrySet()) {
            GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
            paramItem.setName(entry.getKey());
            paramItem.setValue(entry.getValue());
            vnfInputParameters.addParamItem(paramItem);
        }
    }
    if (homing) {
        License license = vnf.getLicense();
        if (license != null) {
            if (license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) {
                String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0);
                GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
                paramItem.setName("entitlement_assignment_group_uuid");
                paramItem.setValue(entitlementPoolUuid);
                vnfInputParameters.addParamItem(paramItem);
            }
            if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) {
                String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0);
                GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam();
                paramItem2.setName("license_assignment_group_uuid");
                paramItem2.setValue(licenseKeyGroupUuid);
                vnfInputParameters.addParamItem(paramItem2);
            }
        }
    }
    List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
    List<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds> networkInstanceGroupIdList = new ArrayList<>();
    for (InstanceGroup instanceGroup : instanceGroups) {
        if (ModelInfoInstanceGroup.TYPE_L3_NETWORK.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
            GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId = new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds();
            instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId());
            networkInstanceGroupIdList.add(instanceGroupId);
        }
    }
    vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList);
    vnfRequestInput.setVnfInputParameters(vnfInputParameters);
    req.setVnfRequestInput(vnfRequestInput);
    return req;
}
Also used : GenericResourceApiServiceinformationServiceInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation) GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds) GenericResourceApiVnfinformationVnfInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation) GenericResourceApiVnfrequestinputVnfRequestInput(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput) License(org.onap.so.bpmn.servicedecomposition.generalobjects.License) ArrayList(java.util.ArrayList) GenericResourceApiParamParam(org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam) GenericResourceApiVnfOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) GenericResourceApiSdncrequestheaderSdncRequestHeader(org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader) GenericResourceApiRequestinformationRequestInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation) GenericResourceApiParam(org.onap.sdnc.northbound.client.model.GenericResourceApiParam) Map(java.util.Map)

Example 32 with InstanceGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.

the class AssignVnf method createInstanceGroups.

public void createInstanceGroups(BuildingBlockExecution execution) {
    try {
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
        for (InstanceGroup instanceGroup : instanceGroups) {
            if (ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
                instanceGroup.setInstanceGroupName(aaiObjectInstanceNameGenerator.generateInstanceGroupName(instanceGroup, vnf));
                aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
                aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
            } else if (ModelInfoInstanceGroup.TYPE_L3_NETWORK.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
                aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.USES);
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)

Aggregations

InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)32 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)14 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)13 Test (org.junit.Test)9 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)9 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)9 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)8 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)7 ArrayList (java.util.ArrayList)6 Service (org.onap.so.db.catalog.beans.Service)4 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)3 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)3 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)3 ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)3 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)3 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 GenericResourceApiVnfOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation)2 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)2