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());
}
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);
}
}
}
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;
}
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);
}
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());
}
Aggregations