Search in sources :

Example 1 with GenericResourceApiVnfrequestinputVnfRequestInput

use of org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput 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)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 GenericResourceApiParam (org.onap.sdnc.northbound.client.model.GenericResourceApiParam)1 GenericResourceApiParamParam (org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam)1 GenericResourceApiRequestinformationRequestInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation)1 GenericResourceApiSdncrequestheaderSdncRequestHeader (org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader)1 GenericResourceApiServiceinformationServiceInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation)1 GenericResourceApiVnfOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation)1 GenericResourceApiVnfinformationVnfInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation)1 GenericResourceApiVnfrequestinputVnfRequestInput (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput)1 GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds)1 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)1 License (org.onap.so.bpmn.servicedecomposition.generalobjects.License)1 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)1