From a9f86b8996c3dfb880098691048686a37ac40dd0 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 11 Jan 2019 21:07:06 -0500 Subject: get subnet sequence number from A&AI Add AAIQuery for subnet block to CreateNetwork bpmn MSO shall get subnet sequence number. Change-Id: I5cf73d1b5344f41ac98a51274948822322e3591b Issue-ID: SO-1378 Signed-off-by: Benjamin, Max (mb388a) --- .../infrastructure/aai/tasks/AAIQueryTasks.java | 25 ++++++++++++++++++++++ .../network/mapper/NetworkAdapterObjectMapper.java | 1 + .../client/orchestration/AAINetworkResources.java | 4 ++++ 3 files changed, 30 insertions(+) (limited to 'bpmn/so-bpmn-tasks/src/main') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java index 0079b351f2..46ff8495f9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java @@ -29,6 +29,7 @@ import org.modelmapper.PropertyMap; import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.aai.domain.yang.RouteTableReference; import org.onap.aai.domain.yang.RouteTargets; +import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.VpnBinding; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -222,4 +223,28 @@ public class AAIQueryTasks { } return mappedRouteTargets; } + + public void querySubnet(BuildingBlockExecution execution) { + try { + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); + Optional networkRelationships = aaiResultWrapper.getRelationships(); + if (!networkRelationships.isPresent()) { + throw (new Exception(ERROR_MSG)); + } + List subnetsUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.SUBNET); + + if(!subnetsUriList.isEmpty()) { + for(AAIResourceUri subnetUri : subnetsUriList) { + Optional oSubnet = aaiNetworkResources.getSubnet(subnetUri); + if(oSubnet.isPresent()) { + l3network.getSubnets().add(modelMapper.map(oSubnet.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class)); + } + } + } + } catch(Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 4abb0a1b2c..3081ab86d8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -260,6 +260,7 @@ public class NetworkAdapterObjectMapper { map(source.getGatewayAddress(), destination.getGatewayIp()); map(source.getIpVersion(), destination.getIpVersion()); map(source.isDhcpEnabled(), destination.getEnableDHCP()); + map(source.getSubnetSequence(), destination.getSubnetSequence()); } }; modelMapper.addMappings(personMap); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index 16d5e8e1db..d2bf95a28e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -84,6 +84,10 @@ public class AAINetworkResources { public Optional getNetworkPolicy(AAIResourceUri netPolicyUri) { return injectionHelper.getAaiClient().get(netPolicyUri).asBean(NetworkPolicy.class); } + + public Optional getSubnet(AAIResourceUri subnetUri) { + return injectionHelper.getAaiClient().get(subnetUri).asBean(org.onap.aai.domain.yang.Subnet.class); + } public Optional getRouteTable(AAIResourceUri rTableUri) { return injectionHelper.getAaiClient().get(rTableUri).asBean(RouteTableReference.class); -- cgit 1.2.3-korg