Search in sources :

Example 1 with License

use of org.onap.so.bpmn.servicedecomposition.generalobjects.License in project so by onap.

the class SniroHomingV2 method processLicenseSolution.

/**
 * Processes the license solutions and sets to the corresponding generic vnf
 */
private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions) {
    List<GenericVnf> vnfs = serviceInstance.getVnfs();
    logger.debug("Processing the license solution");
    for (int i = 0; i < licenseSolutions.length(); i++) {
        JSONObject licenseSolution = licenseSolutions.getJSONObject(i);
        for (GenericVnf vnf : vnfs) {
            if (licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
                License license = new License();
                JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID");
                List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools);
                license.setEntitlementPoolUuids(entitlementPoolsList);
                JSONArray licenseKeys = licenseSolution.getJSONArray("licenseKeyGroupUUID");
                List<String> licenseKeysList = jsonUtils.StringArrayToList(licenseKeys);
                license.setLicenseKeyGroupUuids(licenseKeysList);
                vnf.setLicense(license);
            }
        }
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) JSONObject(org.json.JSONObject) License(org.onap.so.bpmn.servicedecomposition.generalobjects.License) JSONArray(org.json.JSONArray)

Example 2 with License

use of org.onap.so.bpmn.servicedecomposition.generalobjects.License 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 License

use of org.onap.so.bpmn.servicedecomposition.generalobjects.License in project so by onap.

the class OofHomingV2 method processLicenseSolution.

/**
 * Processes the license solutions and sets to the corresponding generic vnf
 */
private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions) {
    List<GenericVnf> vnfs = serviceInstance.getVnfs();
    logger.debug("Processing the license solution");
    for (int i = 0; i < licenseSolutions.length(); i++) {
        JSONObject licenseSolution = licenseSolutions.getJSONObject(i);
        for (GenericVnf vnf : vnfs) {
            if (licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
                License license = new License();
                JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID");
                List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools);
                license.setEntitlementPoolUuids(entitlementPoolsList);
                JSONArray licenseKeys = licenseSolution.getJSONArray("licenseKeyGroupUUID");
                List<String> licenseKeysList = jsonUtils.StringArrayToList(licenseKeys);
                license.setLicenseKeyGroupUuids(licenseKeysList);
                vnf.setLicense(license);
            }
        }
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) JSONObject(org.json.JSONObject) License(org.onap.so.bpmn.servicedecomposition.generalobjects.License) JSONArray(org.json.JSONArray)

Example 4 with License

use of org.onap.so.bpmn.servicedecomposition.generalobjects.License in project so by onap.

the class TestDataSetup method buildGenericVnf.

public GenericVnf buildGenericVnf() {
    genericVnfCounter++;
    GenericVnf genericVnf = new GenericVnf();
    genericVnf.setVnfId("testVnfId" + genericVnfCounter);
    genericVnf.setVnfName("testVnfName" + genericVnfCounter);
    genericVnf.setVnfType("testVnfType" + genericVnfCounter);
    genericVnf.setIpv4OamAddress("10.222.22.2");
    Platform platform = new Platform();
    platform.setPlatformName(" testPlatformName, testPlatformName2   ,   testPlatformName3   , testPlatformName4");
    genericVnf.setPlatform(platform);
    LineOfBusiness lob = new LineOfBusiness();
    lob.setLineOfBusinessName("  testLineOfBusinessName   , testLineOfBusinessName2,    testLineOfBusinessName3,   testLineOfBusinessName4");
    genericVnf.setLineOfBusiness(lob);
    ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
    modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
    modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
    modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
    modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
    modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
    modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
    genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
    License license = new License();
    List<String> array = new ArrayList<String>();
    array.add("testPoolUuid");
    license.setEntitlementPoolUuids(array);
    genericVnf.setLicense(license);
    return genericVnf;
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) License(org.onap.so.bpmn.servicedecomposition.generalobjects.License) ArrayList(java.util.ArrayList) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness)

Example 5 with License

use of org.onap.so.bpmn.servicedecomposition.generalobjects.License in project so by onap.

the class VnfTopologyOperationRequestMapperTest method reqMapperTest.

@Test
public void reqMapperTest() throws Exception {
    // prepare and set service instance
    ServiceInstance serviceInstance = new ServiceInstance();
    ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
    modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
    modelInfoServiceInstance.setModelName("modelName");
    modelInfoServiceInstance.setModelUuid("modelUuid");
    modelInfoServiceInstance.setModelVersion("modelVersion");
    serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
    // prepare VNF
    ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf();
    genericVnf.setModelInvariantUuid("vnfModelInvariantUUID");
    genericVnf.setModelVersion("vnfModelVersion");
    genericVnf.setModelName("vnfModelName");
    genericVnf.setModelUuid("vnfModelUUID");
    genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
    ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
    modelL3Network.setType("L3-NETWORK");
    InstanceGroup instanceGroup1 = new InstanceGroup();
    instanceGroup1.setId("l3-network-ig-111");
    instanceGroup1.setModelInfoInstanceGroup(modelL3Network);
    InstanceGroup instanceGroup2 = new InstanceGroup();
    instanceGroup2.setId("l3-network-ig-222");
    instanceGroup2.setModelInfoInstanceGroup(modelL3Network);
    GenericVnf vnf = new GenericVnf();
    vnf.setModelInfoGenericVnf(genericVnf);
    vnf.setVnfId("vnfId");
    vnf.setVnfType("vnfType");
    vnf.getInstanceGroups().add(instanceGroup1);
    vnf.getInstanceGroups().add(instanceGroup2);
    License license = new License();
    List<String> entitlementPoolUuids = new ArrayList<>();
    entitlementPoolUuids.add("entitlementPoolUuid");
    List<String> licenseKeyGroupUuids = new ArrayList<>();
    licenseKeyGroupUuids.add("licenseKeyGroupUuid");
    license.setEntitlementPoolUuids(entitlementPoolUuids);
    license.setLicenseKeyGroupUuids(licenseKeyGroupUuids);
    vnf.setLicense(license);
    // prepare Customer object
    Customer customer = new Customer();
    customer.setGlobalCustomerId("globalCustomerId");
    ServiceSubscription serviceSubscription = new ServiceSubscription();
    serviceSubscription.setServiceType("productFamilyId");
    customer.setServiceSubscription(serviceSubscription);
    // set Customer on service instance
    customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
    // prepare RequestContext
    RequestContext requestContext = new RequestContext();
    Map<String, Object> userParams = new HashMap<>();
    userParams.put("key1", "value1");
    requestContext.setUserParams(userParams);
    requestContext.setProductFamilyId("productFamilyId");
    requestContext.setMsoRequestId("MsoRequestId");
    CloudRegion cloudRegion = new CloudRegion();
    GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, true, new URI("http://localhost:8080"));
    GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, null, true, new URI("http://localhost:8080"));
    assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
    assertEquals("vnfModelCustomizationUUID", vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
    assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size());
    assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0).getVnfNetworkInstanceGroupId());
    assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1).getVnfNetworkInstanceGroupId());
    assertEquals("entitlementPoolUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
    assertEquals("licenseKeyGroupUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
    assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
    assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) License(org.onap.so.bpmn.servicedecomposition.generalobjects.License) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) URI(java.net.URI) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) GenericResourceApiVnfOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Aggregations

License (org.onap.so.bpmn.servicedecomposition.generalobjects.License)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 ArrayList (java.util.ArrayList)3 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 GenericResourceApiVnfOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation)2 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)2 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)2 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)2 URI (java.net.URI)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)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 GenericResourceApiVnfinformationVnfInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation)1 GenericResourceApiVnfrequestinputVnfRequestInput (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput)1