summaryrefslogtreecommitdiffstats
path: root/pomba/service-decomposition
diff options
context:
space:
mode:
Diffstat (limited to 'pomba/service-decomposition')
-rw-r--r--pomba/service-decomposition/config/application.properties7
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/AAIConfiguration.java9
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java5
-rw-r--r--pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java62
-rw-r--r--pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/test/ServiceDecompositionTest.java18
5 files changed, 59 insertions, 42 deletions
diff --git a/pomba/service-decomposition/config/application.properties b/pomba/service-decomposition/config/application.properties
index c43baac..012285f 100644
--- a/pomba/service-decomposition/config/application.properties
+++ b/pomba/service-decomposition/config/application.properties
@@ -19,8 +19,8 @@ basicAuth.username=admin
basicAuth.password=OBF:1u2a1toa1w8v1tok1u30
# AAI REST Client Configuration
-aai.serviceName=10.12.6.118
-aai.servicePort=8443
+aai.serviceName=10.147.112.153
+aai.servicePort=30233
# AAI APIs authentication mode. Valid values: [basic_auth, client_cert]
aai.authentication=basic_auth
aai.trustStorePath=n/a
@@ -32,7 +32,8 @@ aai.httpProtocol=https
aai.securityProtocol=TLS
aai.connectionTimeout=15000
aai.readTimeout=15000
-aai.resourceList=vnfc,vserver,l3-network
+aai.resourceList=vnfc,vserver,l3-network,pserver
+aai.urlDepth=2
aai.serviceInstancePath=/aai/v13/nodes/service-instance/{0}
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/AAIConfiguration.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/AAIConfiguration.java
index 9ef29a5..243fa45 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/AAIConfiguration.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/AAIConfiguration.java
@@ -69,6 +69,10 @@ public class AAIConfiguration {
@Value("${aai.resourceList}")
private String resourceList;
+ @Value("${aai.urlDepth}")
+ private String urlDepth;
+
+
@Value("${basicAuth.username:admin}")
private String username;
@@ -113,6 +117,11 @@ public class AAIConfiguration {
return this.httpProtocol + "://" + this.host + ":" + this.port;
}
+ @Bean(name="aaiUrlDepth")
+ public String getUrlDepth() {
+ return this.urlDepth;
+ }
+
@Bean(name="aaiServiceInstancePath")
public String getServiceInstancePath() {
return this.serviceInstancePath;
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java
index 22a7d4a..d6ba6e8 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/service/SpringServiceImpl.java
@@ -39,6 +39,9 @@ public class SpringServiceImpl implements SpringService {
private String aaiBaseUrl;
@Autowired
+ private String aaiUrlDepth;
+
+ @Autowired
private String aaiBasicAuthorization;
@Autowired
@@ -53,7 +56,7 @@ public class SpringServiceImpl implements SpringService {
log.info("Querying A&AI for service instance {}", serviceInstanceId);
- JSONObject serviceInstance = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiBasicAuthorization,
+ JSONObject serviceInstance = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiUrlDepth, aaiBasicAuthorization,
aaiServiceInstancePath, aaiResourceList, transactionId, serviceInstanceId);
return serviceInstance.toString();
}
diff --git a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java
index af2f7be..944237d 100644
--- a/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java
+++ b/pomba/service-decomposition/src/main/java/org/onap/sdnc/apps/pomba/servicedecomposition/util/RestUtil.java
@@ -45,8 +45,8 @@ import org.slf4j.LoggerFactory;
public class RestUtil {
-
-
+
+
private static final String RELATIONSHIP_KEY = "relationship";
private static final String RELATIONSHIP_LIST_KEY = "relationship-list";
// Parameters for Query AAI Model Data API
@@ -59,6 +59,7 @@ public class RestUtil {
private static final Resource GENERIC_VNF = new Resource("generic-vnf");
private static final Resource VF_MODULE = new Resource("vf-module");
private static final Resource L3_NETWORK = new Resource("l3-network");
+ private static final Resource PNF = new Resource("pnf");
public static class Resource {
private String resourceName;
@@ -88,7 +89,6 @@ public class RestUtil {
private static final String EMPTY_JSON_STRING = "{}";
- private static final String DEPTH = "?depth=2";
private static Logger logger = LoggerFactory.getLogger(RestUtil.class);
private RestUtil() {
@@ -123,14 +123,14 @@ public class RestUtil {
* @return
* @throws DiscoveryException
*/
- public static JSONObject retrieveAAIModelData(RestClient aaiClient, String baseURL, String aaiBasicAuthorization, String aaiServiceInstancePath, String aaiResourceList,
+ public static JSONObject retrieveAAIModelData(RestClient aaiClient, String baseURL, String depth, String aaiBasicAuthorization, String aaiServiceInstancePath, String aaiResourceList,
String transactionId, String serviceInstanceId) throws DiscoveryException {
// Follow two variables for transform purpose
String url = baseURL + generateServiceInstanceURL(aaiServiceInstancePath, serviceInstanceId);
// Response from service instance API call
JSONObject serviceInstancePayload = new JSONObject(
- getResource(aaiClient, url, aaiBasicAuthorization, transactionId));
+ getResource(aaiClient, url, depth, aaiBasicAuthorization, transactionId));
// Handle the case if the service instance is not found in AAI
if (serviceInstancePayload.length() == 0) {
logger.info("Service Instance {} is not found from AAI", serviceInstanceId);
@@ -142,16 +142,25 @@ public class RestUtil {
logger.info("The number of the relationship types for service instance id {} is: {}", serviceInstanceId,
relationMap.size());
- JSONObject response = processVNFRelationMap(aaiClient, aaiResourceList, baseURL, aaiBasicAuthorization, transactionId, relationMap, serviceInstancePayload);
-
+ JSONObject response = processVNFRelationMap(aaiClient, aaiResourceList, baseURL, depth, aaiBasicAuthorization, transactionId, relationMap, serviceInstancePayload);
+
if (relationMap.containsKey(L3_NETWORK.getResourceName())) {
- List<String> l3NetworkRelatedLinks = relationMap.get(L3_NETWORK.getResourceName());
- List<JSONObject> l3networkPayload = processResourceList(aaiClient, baseURL, aaiBasicAuthorization, transactionId,
+ List<String> l3NetworkRelatedLinks = relationMap.get(L3_NETWORK.getResourceName());
+ List<JSONObject> l3networkPayload = processResourceList(aaiClient, baseURL, depth, aaiBasicAuthorization, transactionId,
L3_NETWORK.getResourceName(), l3NetworkRelatedLinks);
-
+
response.put(L3_NETWORK.getCollectionName(), l3networkPayload);
}
+ if (relationMap.containsKey(PNF.getResourceName())) {
+ List<String> l3NetworkRelatedLinks = relationMap.get(PNF.getResourceName());
+ List<JSONObject> l3networkPayload = processResourceList(aaiClient, baseURL, depth, aaiBasicAuthorization, transactionId,
+ PNF.getResourceName(), l3NetworkRelatedLinks);
+
+ response.put(PNF.getCollectionName(), l3networkPayload);
+ }
+
+
return response;
}
@@ -163,7 +172,7 @@ public class RestUtil {
* @param relationMap
* @throws DiscoveryException
*/
- private static JSONObject processVNFRelationMap(RestClient aaiClient, String aaiResourceList, String baseURL, String aaiBasicAuthorization, String transactionId,
+ private static JSONObject processVNFRelationMap(RestClient aaiClient, String aaiResourceList, String baseURL, String depth, String aaiBasicAuthorization, String transactionId,
Map<String, List<String>> relationMap, JSONObject serviceInstancePayload) throws DiscoveryException {
List<JSONObject> vnfLst = new ArrayList<>(); // List of the VNF JSON along with related resources
@@ -172,7 +181,7 @@ public class RestUtil {
List<Resource> resourceTypes = getResourceTypes(aaiResourceList);
if (relationMap.get(GENERIC_VNF.getResourceName()) != null) {
- List<JSONObject> vnfList = processResourceList(aaiClient, baseURL, aaiBasicAuthorization, transactionId,
+ List<JSONObject> vnfList = processResourceList(aaiClient, baseURL, depth, aaiBasicAuthorization, transactionId,
GENERIC_VNF.getResourceName(), relationMap.get(GENERIC_VNF.getResourceName()));
// Logic to Create the Generic VNF JSON and extract further relationships
for (JSONObject vnfPayload : vnfList) {
@@ -189,13 +198,13 @@ public class RestUtil {
logger.info("Number of relationships found for generic-vnf '{}', resource type '{}' are: {}", vnfId,
resourceType.getResourceName(), vnfcLinkLst.size());
- List<JSONObject> vnfcList = processResourceList(aaiClient, baseURL, aaiBasicAuthorization,
+ List<JSONObject> vnfcList = processResourceList(aaiClient, baseURL, depth, aaiBasicAuthorization,
transactionId, resourceType.getResourceName(), vnfcLinkLst);
vnfPayload.put(resourceType.getCollectionName(), vnfcList);
}
// Process vf-module looking for l3-network:
- processVfModuleList(aaiClient, baseURL, aaiBasicAuthorization, transactionId, vnfPayload);
+ processVfModuleList(aaiClient, baseURL, depth, aaiBasicAuthorization, transactionId, vnfPayload);
// Add final vnf payload to list
vnfLst.add(vnfPayload);
}
@@ -212,7 +221,7 @@ public class RestUtil {
}
- private static void processVfModuleList(RestClient aaiClient, String baseURL, String aaiBasicAuthorization, String transactionId,
+ private static void processVfModuleList(RestClient aaiClient, String baseURL, String depth, String aaiBasicAuthorization, String transactionId,
JSONObject vnfPayload) throws DiscoveryException {
if (!vnfPayload.has(VF_MODULE.getCollectionName())) {
@@ -224,7 +233,7 @@ public class RestUtil {
if (!vfmoduleCollection.has(VF_MODULE.getResourceName())) {
return;
}
-
+
JSONArray vfModuleList = vfmoduleCollection.getJSONArray(VF_MODULE.getResourceName());
for (int i = 0; i < vfModuleList.length(); i++) {
@@ -233,11 +242,11 @@ public class RestUtil {
logger.error("VF Module not found for vnf-id {}", vnfPayload.opt("vnf-id"));
continue;
}
- processVfModule(aaiClient, baseURL, aaiBasicAuthorization, transactionId, vfModulePayload);
- }
+ processVfModule(aaiClient, baseURL, depth, aaiBasicAuthorization, transactionId, vfModulePayload);
+ }
}
- private static void processVfModule(RestClient aaiClient, String baseURL, String aaiBasicAuthorization,
+ private static void processVfModule(RestClient aaiClient, String baseURL, String depth, String aaiBasicAuthorization,
String transactionId, JSONObject vfModulePayload) throws DiscoveryException {
Map<String, List<String>> relationMap = extractRelationships(vfModulePayload);
@@ -252,7 +261,7 @@ public class RestUtil {
logger.info("Number of relationships found for vf-module '{}', resource type '{}' are: {}", vfModuleId, L3_NETWORK.getResourceName(), l3NetworkRelatedLinks.size());
- List<JSONObject> l3NetworkObjects = processResourceList(aaiClient, baseURL, aaiBasicAuthorization,
+ List<JSONObject> l3NetworkObjects = processResourceList(aaiClient, baseURL, depth, aaiBasicAuthorization,
transactionId, L3_NETWORK.getResourceName(), l3NetworkRelatedLinks);
// Add l3-network with related resource payload to the vfModulePayload:
@@ -268,20 +277,15 @@ public class RestUtil {
* @return
* @throws DiscoveryException
*/
- private static List<JSONObject> processResourceList(RestClient aaiClient, String aaiBaseURL, String aaiBasicAuthorization, String transactionId,
+ private static List<JSONObject> processResourceList(RestClient aaiClient, String aaiBaseURL, String depth, String aaiBasicAuthorization, String transactionId,
String resourceType, List<String> resourceList) throws DiscoveryException {
List<JSONObject> resourcePayloadList = new ArrayList<>();
for (String resourceLink : resourceList) {
String resourceURL = aaiBaseURL + resourceLink;
- // With latest AAI development, in order to retrieve the both generic VNF + vf_module, we can use
- // one API call but with depth=2
- if (resourceType.equals(GENERIC_VNF.getResourceName())) {
- resourceURL += DEPTH;
- }
// Response from generic VNF API call
JSONObject resourcePayload = new JSONObject(
- getResource(aaiClient, resourceURL, aaiBasicAuthorization, transactionId));
+ getResource(aaiClient, resourceURL, depth, aaiBasicAuthorization, transactionId));
if (resourcePayload.length() == 0) {
logger.info("Resource with url {} is not found from AAI", resourceLink);
} else {
@@ -352,9 +356,9 @@ public class RestUtil {
* @return
* @throws DiscoveryException
*/
- private static String getResource(RestClient client, String url, String aaiBasicAuthorization, String transId)
+ private static String getResource(RestClient client, String url, String depth, String aaiBasicAuthorization, String transId)
throws DiscoveryException {
- OperationResult result = client.get(url, buildHeaders(aaiBasicAuthorization, transId), MediaType.valueOf(MediaType.APPLICATION_JSON));
+ OperationResult result = client.get((url + ((null != depth) ? ("?depth=" +depth) : "")), buildHeaders(aaiBasicAuthorization, transId), MediaType.valueOf(MediaType.APPLICATION_JSON));
if (result.wasSuccessful()) {
return result.getResult();
diff --git a/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/test/ServiceDecompositionTest.java b/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/test/ServiceDecompositionTest.java
index 0680842..9881d6b 100644
--- a/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/test/ServiceDecompositionTest.java
+++ b/pomba/service-decomposition/src/test/java/org/onap/sdnc/apps/pomba/servicedecomposition/test/ServiceDecompositionTest.java
@@ -97,7 +97,7 @@ public class ServiceDecompositionTest {
public void testDemoFirewallService() throws Exception {
// setup A&AI responses
addResponse(
- "/aai/v13/nodes/service-instance/c6456519-6acf-4adb-997c-3c363dd4caaf",
+ "/aai/v13/nodes/service-instance/c6456519-6acf-4adb-997c-3c363dd4caaf?depth=2",
"junit/aai-service-instance.json");
addResponse(
"/aai/v13/network/generic-vnfs/generic-vnf/6700c313-fbb7-4cf9-ac70-0293ec56df68?depth=2",
@@ -107,13 +107,13 @@ public class ServiceDecompositionTest {
"junit/aai-generic-vnf2.json");
addResponse(
"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant"
- + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a",
+ + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a?depth=2",
"junit/aai-vserver.json");
addResponse(
- "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870",
+ "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870?depth=2",
"junit/aai-l3-network1.json");
addResponse(
- "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872",
+ "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872?depth=2",
"junit/aai-l3-network2.json");
final String serviceInstanceId = "c6456519-6acf-4adb-997c-3c363dd4caaf";
@@ -157,7 +157,7 @@ public class ServiceDecompositionTest {
public void testDemoFirewallServiceWithL3Networks() throws Exception {
// setup A&AI responses
addResponse(
- "/aai/v13/nodes/service-instance/c6456519-6acf-4adb-997c-3c363dd4caaf",
+ "/aai/v13/nodes/service-instance/c6456519-6acf-4adb-997c-3c363dd4caaf?depth=2",
"junit/aai-service-instance2.json");
addResponse(
"/aai/v13/network/generic-vnfs/generic-vnf/6700c313-fbb7-4cf9-ac70-0293ec56df68?depth=2",
@@ -167,13 +167,13 @@ public class ServiceDecompositionTest {
"junit/aai-generic-vnf2.json");
addResponse(
"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant"
- + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a",
+ + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a?depth=2",
"junit/aai-vserver.json");
addResponse(
- "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870",
+ "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870?depth=2",
"junit/aai-l3-network1.json");
addResponse(
- "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872",
+ "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872?depth=2",
"junit/aai-l3-network2.json");
final String serviceInstanceId = "c6456519-6acf-4adb-997c-3c363dd4caaf";
@@ -277,7 +277,7 @@ public class ServiceDecompositionTest {
/** Unknown service-instance-id return HTTP 404. */
@Test
public void testInvalidServiceId() throws Exception {
- aai.stubFor(get("/aai/v13/nodes/service-instance/noSuchServiceId").willReturn(notFound()));
+ aai.stubFor(get("/aai/v13/nodes/service-instance/noSuchServiceId?depth=2").willReturn(notFound()));
Response response =
this.service.getContext(httpRequest, AUTH, "junit", null, "noSuchServiceId");