aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-11-20 16:44:12 -0500
committerJim Hahn <jrh3@att.com>2021-02-17 13:17:50 -0500
commitb2e63077887295b402a327692b2ab91cdecd3ef6 (patch)
tree345df6492b1341d1939d4ff92e404d88527126d4
parent9f0fbd02f184071c2de30c944bec311741e6180e (diff)
Use new version of A&AI APIs
Just changed the version numbers; the APIs appear to be the same otherwise. Also removed unused APIs from the A&AI simulator. Issue-ID: POLICY-2788 Change-Id: I8c0ae11c1e42f487b34286d5dfd4ca536bb2c07b Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java8
-rw-r--r--models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java8
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java186
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java4
4 files changed, 11 insertions, 195 deletions
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
index 76817dfc6..16ee887af 100644
--- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
+++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* aai
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* ================================================================================
@@ -59,10 +59,10 @@ public final class AaiManager {
private final RestManager restManager;
/** custom query and other AAI resource URLs. */
- private static final String CQ_URL = "/aai/v16/query?format=resource";
- private static final String TENANT_URL = "/aai/v16/search/nodes-query?"
+ private static final String CQ_URL = "/aai/v21/query?format=resource";
+ private static final String TENANT_URL = "/aai/v21/search/nodes-query?"
+ "search-node-type=vserver&filter=vserver-name:EQUALS:";
- private static final String PREFIX = "/aai/v16";
+ private static final String PREFIX = "/aai/v21";
private static final String PNF_URL = PREFIX + "/network/pnfs/pnf/";
private static final String AAI_DEPTH_SUFFIX = "?depth=0";
diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
index 33934d937..9b20fe92a 100644
--- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
+++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* aai
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -94,9 +94,6 @@ public class AaiManagerTest {
when(restManagerMock.put(eq(""), eq("Foo"), eq("Bar"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponseErr0);
- when(restManagerMock.get(eq("/aai/v11/query?format=resource"), eq("Foo"), eq("Bar"), anyMap()))
- .thenReturn(httpResponseErr0);
-
AaiCqResponse aaiCqResponseNull =
aaiManager.getCustomQueryResponse("", "Foo", "Bar", vserverNameRequestId, "Foo");
assertNull(aaiCqResponseNull);
@@ -105,9 +102,6 @@ public class AaiManagerTest {
when(restManagerMock.put(eq("Error"), eq("Foo"), eq("Bar"), anyMap(), anyString(), anyString()))
.thenReturn(httpResponseErr1);
- when(restManagerMock.get(eq("Error/aai/v11/query?format=resource"), eq("Foo"), eq("Bar"), anyMap()))
- .thenReturn(httpResponseErr1);
-
AaiCqResponse aaiCqResponseErr =
aaiManager.getCustomQueryResponse("Error", "Foo", "Bar", vserverNameRequestId, "Foo");
assertNull(aaiCqResponseErr);
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index 27afb7b73..adfa6d4fa 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* simulators
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,6 @@ package org.onap.policy.simulators;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
@@ -37,33 +36,15 @@ import org.apache.commons.io.IOUtils;
@Path("/aai")
public class AaiSimulatorJaxRs {
- private static final String DISABLE_CLOSEDLOOP = "disableClosedLoop";
- private static final String ERROR = "error";
private static final String GETFAIL = "getFail";
/**
* A&AI get query.
*
- * @param vnfId the VNF Id
* @return the result
*/
@GET
- @Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String aaiGetQuery(@PathParam("vnfId") final String vnfId) {
- return "{\"relationship-list\": {\"relationship\":[{\"related-to-property\": [{\"property-key\": "
- + "\"service-instance.service-instance-name\"}]},{\"related-to-property\": [ {\"property-key\": "
- + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
- }
-
- /**
- * A&AI get query.
- *
- * @return the result
- */
- @GET
- @Path("/v16/search/nodes-query")
+ @Path("/{version:v16|v21}/search/nodes-query")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String aaiGetVserverQuery(@QueryParam("filter") final String filter) {
@@ -88,7 +69,7 @@ public class AaiSimulatorJaxRs {
* @throws IOException if a response file cannot be read
*/
@PUT
- @Path("/v16/query")
+ @Path("/{version:v16|v21}/query")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String aaiPutQuery(final String req) throws IOException {
@@ -103,7 +84,7 @@ public class AaiSimulatorJaxRs {
* @throws IOException if a response file cannot be read
*/
@GET
- @Path("/v16/network/pnfs/pnf/{pnfName}")
+ @Path("/{version:v16|v21}/network/pnfs/pnf/{pnfName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String aaiGetPnfQuery(@PathParam("pnfName") final String pnfName) throws IOException {
@@ -114,163 +95,4 @@ public class AaiSimulatorJaxRs {
return IOUtils.toString(getClass().getResource("aai/AaiGetPnfResponse.json"),
StandardCharsets.UTF_8);
}
-
- /**
- * Get by VNF name.
- *
- * @param vnfName the VNF name
- * @return the response
- */
- @GET
- @Path("/v11/network/generic-vnfs/generic-vnf")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getByVnfName(@QueryParam("vnf-name") final String vnfName) {
- if (GETFAIL.equals(vnfName)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not"
- + " found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
- + "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs"
- + "/generic-vnf\",\"ERR.5.4.6114\"]}}}";
- }
- final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfName);
- if (ERROR.equals(vnfName)) {
- return "{ \"vnf-id\": \"error\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
- + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \""
- + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
- + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
- + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
- + "\"is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
- + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/"
- + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
- + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
- + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
- + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
- + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
- + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01"
- + "\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name"
- + "\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/"
- + "cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/"
- + "USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45"
- + "\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \""
- + "relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id"
- + "\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id"
- + "\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \""
- + "vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \""
- + "related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \""
- + "USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
-
- }
- final String vnfId = getUuidValue(vnfName, "5e49ca06-2972-4532-9ed4-6d071588d792");
- return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
- + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT"
- + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
- + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
- + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", "
- + "\"is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
- + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer"
- + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
- + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \""
- + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \""
- + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type"
- + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \""
- + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \""
- + "related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \""
- + "related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
- + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
- + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
- + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
- + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
- + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
- + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
- + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
- }
-
- /**
- * Get by VNF Id.
- *
- * @param vnfId the VNF Id
- * @return the response
- */
- @GET
- @Path("/v11/network/generic-vnfs/generic-vnf/{vnfId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getByVnfId(@PathParam("vnfId") final String vnfId) {
- if (GETFAIL.equals(vnfId)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
- + "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/"
- + "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}";
- }
- final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfId);
- final String vnfName = getUuidValue(vnfId, "USUCP0PCOIL0110UJRT01");
- return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
- + "\", \"vnf-type\": \"RT\", \"service-id\": \""
- + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status"
- + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \""
- + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345"
- + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, "
- + "\"prov-status\":\"ACTIVE\", \"" + "" + "is-closed-loop-disabled\": " + isDisabled
- + ", \"resource-version\": \"1493389458092\", \""
- + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link"
- + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions"
- + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \""
- + "relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \""
- + "relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \""
- + "service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key"
- + "\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} "
- + "], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},"
- + "{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/"
- + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver"
- + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \""
- + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \""
- + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \""
- + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \""
- + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \""
- + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \""
- + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
- }
-
- /**
- * Get by VServer name.
- *
- * @param vserverName the VServer name
- * @return the response
- */
- @GET
- @Path("/v11/nodes/vservers")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces("application/json")
- public String getByVserverName(@QueryParam("vserver-name") final String vserverName) {
- if (GETFAIL.equals(vserverName)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
- + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not"
- + " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}";
- }
- final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vserverName);
- final String vserverId = getUuidValue(vserverName, "d0668d4f-c25e-4a1b-87c4-83845c01efd8");
- return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \""
- + vserverName
- + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": "
- + isDisabled + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", "
- + "\"relationship-list\": {\"relationship\":[{ \"related-to"
- + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/"
- + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \""
- + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \""
- + "related-to-property\": [ {\"property-key\": \"generic-vnf.vnf-name\",\"property-value\": \""
- + "USMSO1SX7NJ0103UJSW01\" }]},{ \"related-to\": \"pserver\", \"related-link\": \"/aai/v11/"
- + "cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01\", \"relationship-data\": [ {\""
- + "relationship-key\": \"pserver.hostname\",\"relationship-value\": \"USMSO1SX7NJ0103UJZZ01\" }], \""
- + "related-to-property\": [{\"property-key\": \"pserver.pserver-name2\"}]} ]}}]}";
- }
-
- private String getUuidValue(final String value, final String defaultValue) {
- return value != null ? UUID.nameUUIDFromBytes(value.getBytes()).toString() : defaultValue;
- }
-
}
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
index 1f52ed124..bb4fa7c5a 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
@@ -145,11 +145,11 @@ public class MainTest {
.allowSelfSignedCerts(true).basePath("aai").build();
HttpClient client = HttpClientFactoryInstance.getClientFactory().build(params);
- Response response = client.get("/v8/network/generic-vnfs/generic-vnf/my-vnf");
+ Response response = client.get("/v21/network/pnfs/pnf/demo-pnf");
assertEquals(200, response.getStatus());
String result = response.readEntity(String.class);
- assertThat(result).contains("USUCP0PCOIL0110UJZZ01-vsrx");
+ assertThat(result).contains("model-123456");
}
/**