Search in sources :

Example 1 with GenericResourceApiVnfinformationVnfInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation in project so by onap.

the class VfModuleTopologyOperationRequestMapper method reqMapper.

public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, String sdncAssignResponse, URI callbackURL) throws MapperException {
    GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation();
    boolean includeModelInformation = false;
    GenericResourceApiRequestActionEnumeration requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
    GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN;
    if (svcAction.equals(SDNCSvcAction.ACTIVATE)) {
        genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE;
        requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
        includeModelInformation = true;
    } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) {
        genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN;
        requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
        includeModelInformation = true;
    } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) {
        genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE;
        requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
        includeModelInformation = false;
    } else if (svcAction.equals(SDNCSvcAction.DELETE)) {
        genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE;
        requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
        includeModelInformation = false;
    } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) {
        genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN;
        requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
        includeModelInformation = false;
    } else if (svcAction.equals(SDNCSvcAction.CHANGE_ASSIGN)) {
        genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.CHANGEASSIGN;
        requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
        includeModelInformation = true;
    }
    String sdncReqId = UUID.randomUUID().toString();
    String msoRequestId = UUID.randomUUID().toString();
    if (requestContext != null && requestContext.getMsoRequestId() != null) {
        msoRequestId = requestContext.getMsoRequestId();
    }
    GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
    GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation);
    GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation);
    GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper.buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation);
    GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext);
    GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction, callbackURL);
    req.setRequestInformation(requestInformation);
    req.setSdncRequestHeader(sdncRequestHeader);
    req.setServiceInformation(serviceInformation);
    req.setVnfInformation(vnfInformation);
    req.setVfModuleInformation(vfModuleInformation);
    req.setVfModuleRequestInput(vfModuleRequestInput);
    return req;
}
Also used : GenericResourceApiSvcActionEnumeration(org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration) GenericResourceApiServiceinformationServiceInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation) GenericResourceApiSdncrequestheaderSdncRequestHeader(org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader) GenericResourceApiRequestActionEnumeration(org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration) GenericResourceApiVnfinformationVnfInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation) GenericResourceApiRequestinformationRequestInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation) GenericResourceApiVfmodulerequestinputVfModuleRequestInput(org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput) GenericResourceApiVfmoduleinformationVfModuleInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation) GenericResourceApiVfModuleOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation)

Example 2 with GenericResourceApiVnfinformationVnfInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation 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 3 with GenericResourceApiVnfinformationVnfInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation in project so by onap.

the class GeneralTopologyObjectMapper method buildVnfInformation.

/*
     * Build GenericResourceApiVnfinformationVnfInformation
     */
public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation) {
    GenericResourceApiVnfinformationVnfInformation vnfInformation = new GenericResourceApiVnfinformationVnfInformation();
    if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) {
        GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
        onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid());
        onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName());
        onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion());
        onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid());
        onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
        vnfInformation.setOnapModelInformation(onapModelInformation);
    }
    vnfInformation.setVnfId(vnf.getVnfId());
    vnfInformation.setVnfType(vnf.getVnfType());
    vnfInformation.setVnfName(vnf.getVnfName());
    return vnfInformation;
}
Also used : GenericResourceApiVnfinformationVnfInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation) GenericResourceApiOnapmodelinformationOnapModelInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation)

Example 4 with GenericResourceApiVnfinformationVnfInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation in project so by onap.

the class GeneralTopologyObjectMapperTest method buildVnfInformationTest_withNullData.

@Test
public void buildVnfInformationTest_withNullData() {
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("TestVnfId");
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setServiceInstanceId("serviceInstanceId");
    GenericResourceApiVnfinformationVnfInformation gcRequestInput = genObjMapper.buildVnfInformation(vnf, serviceInstance, true);
    assertNotNull(gcRequestInput);
    assertNull(vnf.getModelInfoGenericVnf());
    assertNull(gcRequestInput.getOnapModelInformation());
    assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
    assertNotNull(gcRequestInput.getVnfId());
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) GenericResourceApiVnfinformationVnfInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Aggregations

GenericResourceApiVnfinformationVnfInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation)4 GenericResourceApiRequestinformationRequestInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation)2 GenericResourceApiSdncrequestheaderSdncRequestHeader (org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader)2 GenericResourceApiServiceinformationServiceInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.Test)1 GenericResourceApiOnapmodelinformationOnapModelInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation)1 GenericResourceApiParam (org.onap.sdnc.northbound.client.model.GenericResourceApiParam)1 GenericResourceApiParamParam (org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam)1 GenericResourceApiRequestActionEnumeration (org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration)1 GenericResourceApiSvcActionEnumeration (org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration)1 GenericResourceApiVfModuleOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation)1 GenericResourceApiVfmoduleinformationVfModuleInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation)1 GenericResourceApiVfmodulerequestinputVfModuleRequestInput (org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput)1 GenericResourceApiVnfOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation)1 GenericResourceApiVnfrequestinputVnfRequestInput (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput)1 GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)1