Search in sources :

Example 16 with InstanceGroup

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

the class AAIObjectMapperTest method testMapInstanceGroup.

@Test
public void testMapInstanceGroup() {
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setId("test-id");
    instanceGroup.setDescription("test-description");
    instanceGroup.setInstanceGroupName("test-instanceGroupName");
    instanceGroup.setResourceVersion("test-resourceVersion");
    ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
    model.setFunction("test-function");
    model.setInstanceGroupRole("SUB-INTERFACE");
    model.setType("VNFC");
    model.setModelInvariantUUID("modelInvariantUUID-000");
    model.setModelUUID("modelUUID-000");
    model.setDescription("test-description");
    model.setInstanceGroupRole("SUB-INTERFACE");
    instanceGroup.setModelInfoInstanceGroup(model);
    org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
    try {
        com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
        String json = mapper.writeValueAsString(aaiInstanceGroup);
        System.out.println("GGG - json:\n" + json);
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(aaiInstanceGroup.getId(), instanceGroup.getId());
    assertEquals(aaiInstanceGroup.getDescription(), instanceGroup.getDescription());
    assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
    assertEquals(aaiInstanceGroup.getModelInvariantId(), instanceGroup.getModelInfoInstanceGroup().getModelInvariantUUID());
    assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
    assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
    assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
    assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 17 with InstanceGroup

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

the class BBInputSetup method mapVnfcCollectionInstanceGroup.

protected void mapVnfcCollectionInstanceGroup(GenericVnf genericVnf, ModelInfo modelInfo, Service service) {
    VnfResourceCustomization vnfResourceCustomization = getVnfResourceCustomizationFromService(modelInfo, service);
    if (vnfResourceCustomization != null) {
        List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = vnfResourceCustomization.getVnfcInstanceGroupCustomizations();
        for (VnfcInstanceGroupCustomization vnfcInstanceGroupCust : vnfcInstanceGroups) {
            InstanceGroup instanceGroup = this.createInstanceGroup();
            org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = bbInputSetupUtils.getCatalogInstanceGroup(vnfcInstanceGroupCust.getInstanceGroup().getModelUUID());
            instanceGroup.setModelInfoInstanceGroup(this.mapperLayer.mapCatalogInstanceGroupToInstanceGroup(null, catalogInstanceGroup));
            instanceGroup.getModelInfoInstanceGroup().setFunction(vnfcInstanceGroupCust.getFunction());
            instanceGroup.getModelInfoInstanceGroup().setDescription(vnfcInstanceGroupCust.getDescription());
            genericVnf.getInstanceGroups().add(instanceGroup);
        }
    }
}
Also used : VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 18 with InstanceGroup

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

the class BBInputSetup method mapInstanceGroup.

protected InstanceGroup mapInstanceGroup(AAIResultWrapper instanceGroupWrapper) {
    Optional<org.onap.aai.domain.yang.InstanceGroup> aaiInstanceGroupOp = instanceGroupWrapper.asBean(org.onap.aai.domain.yang.InstanceGroup.class);
    org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = null;
    if (!aaiInstanceGroupOp.isPresent()) {
        return null;
    }
    aaiInstanceGroup = aaiInstanceGroupOp.get();
    InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
    instanceGroup.setModelInfoInstanceGroup(this.mapperLayer.mapCatalogInstanceGroupToInstanceGroup(null, this.bbInputSetupUtils.getCatalogInstanceGroup(aaiInstanceGroup.getModelVersionId())));
    return instanceGroup;
}
Also used : InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 19 with InstanceGroup

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

the class BBInputSetup method getGBBCM.

protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
    ServiceInstance serviceInstance = new ServiceInstance();
    String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
    serviceInstance.setServiceInstanceId(serviceInstanceId);
    Customer customer = new Customer();
    List<GenericVnf> genericVnfs = serviceInstance.getVnfs();
    String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
    if (vnfId != null) {
        org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
        GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
        genericVnfs.add(genericVnf);
    }
    String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID);
    if (instanceGroupId != null && !instanceGroupId.isEmpty()) {
        org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
        InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup);
        instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
        if (serviceInstanceId == null) {
            Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
            if (aaiServiceInstanceOpt.isPresent()) {
                org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get();
                serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance);
                WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds();
                workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId());
                lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId());
            } else {
                throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI.");
            }
        }
        RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
        if (relatedInstanceList != null) {
            for (RelatedInstanceList relatedInstList : relatedInstanceList) {
                RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
                if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
                    org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId());
                    GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf);
                    instanceGroup.getVnfs().add(vnf);
                }
            }
        }
        serviceInstance.getInstanceGroups().add(instanceGroup);
        customer.setServiceSubscription(new ServiceSubscription());
    }
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
    return this.populateGBBWithSIAndAdditionalInfo(parameter);
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)

Example 20 with InstanceGroup

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

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