summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/main/java/org
diff options
context:
space:
mode:
authorrama-huawei <rama.subba.reddy.s@huawei.com>2018-09-07 17:37:19 +0530
committerrama-huawei <rama.subba.reddy.s@huawei.com>2018-09-07 18:53:29 +0530
commit904bb036bbcf1fb0e2ac5bc30cde7bfa94dd5de0 (patch)
treeeda6eba40c9ac0b6b4561e3f8b6a9a099ee59771 /holmes-actions/src/main/java/org
parent310a77fb3e99c4057b80098d0bcec7ecda62680d (diff)
Fixed integration issues for CCVPN usecase
1) Currently holmes is updating the AAI record without resource-version 2) Also corrected some of the AAI URL's Issue-ID: HOLMES-164 Change-Id: I7b0ba5cc786e57a282ee917bed07030dd9e74678 Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
Diffstat (limited to 'holmes-actions/src/main/java/org')
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java26
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/config/AaiConfig.java18
2 files changed, 26 insertions, 18 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java
index 3e056d5..d2208a3 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java
@@ -95,7 +95,7 @@ public class AaiQuery4Ccvpn {
"vpn-binding.vpn-id");
JSONObject connectivityInfo = getConnectivityInfo(vpnBindingId);
String connectivityId = extractValueFromJsonArray(connectivityInfo.getJSONArray("relationship-data"),
- "connectivity. connectivity-id");
+ "connectivity.connectivity-id");
JSONObject serviceInstanceInfo = getServiceInstanceByConn(connectivityId);
String serviceInstancePath = serviceInstanceInfo.getString("related-link");
serviceInstancePath = serviceInstancePath.substring(0, serviceInstancePath.lastIndexOf('/'));
@@ -133,14 +133,19 @@ public class AaiQuery4Ccvpn {
params.put("networkId", networkId);
params.put("pnfName", pnfName);
params.put("ifName", ifName);
- patch(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_TP_UPDATE, params), body);
+ Response r = get(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_TP_UPDATE, params));
+ JSONObject jsonObject = JSONObject.parseObject(r.readEntity(String.class));
+ body.put("resource-version", jsonObject.get("resource-version").toString());
+
+ put(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_TP_UPDATE, params), body);
}
public void updateLogicLinkStatus(String linkName, Map<String, Object> body) throws CorrelationException {
- patch(getHostAddr(),
- getPath(AaiConfig.MsbConsts.AAI_TP_UPDATE, "linkName", linkName), body);
+ Response r = get(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_LINK_UPDATE, "linkName", linkName));
+ JSONObject jsonObject = JSONObject.parseObject(r.readEntity(String.class));
+ body.put("resource-version", jsonObject.get("resource-version").toString());
+ put(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_LINK_UPDATE, "linkName", linkName), body);
}
-
private JSONObject getVpnBindingInfo(String networkId, String pnfName,
String ifName, String status) throws CorrelationException {
Map<String, String> params = new HashMap();
@@ -213,11 +218,11 @@ public class AaiQuery4Ccvpn {
}
}
- private void patch(String host, String path, Map<String, Object> body) throws CorrelationException {
+ private void put(String host, String path, Map<String, Object> body) throws CorrelationException {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(host).path(path);
try {
- Response response = target.request().headers(getAaiHeaders()).build("PATCH", Entity.json(body))
+ Response response = target.request().headers(getAaiHeaders()).build("PUT", Entity.json(body))
.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true).invoke();
if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
throw new CorrelationException("Failed to connect to AAI. \nCause: "
@@ -233,8 +238,11 @@ public class AaiQuery4Ccvpn {
}
private JSONObject getInfo(String response, String pField, String field) {
- JSONArray results = extractJsonArray(JSONObject.parseObject(response), "results");
- JSONObject pInterface = extractJsonObject(results.getJSONObject(0), pField);
+ JSONObject jObject = JSONObject.parseObject(response);
+ JSONObject pInterface = extractJsonObject(jObject, pField);
+ if (pInterface == null) {
+ pInterface = jObject;
+ }
JSONObject relationshipList = extractJsonObject(pInterface, "relationship-list");
JSONArray relationShip = extractJsonArray(relationshipList, "relationship");
if (relationShip != null) {
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/config/AaiConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/config/AaiConfig.java
index f1b3e21..c16dd24 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/config/AaiConfig.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/config/AaiConfig.java
@@ -37,17 +37,17 @@ public class AaiConfig {
public static final String AAI_VNF_ADDR = AAI_PREF + AAI_API_VERSION + "/network/generic-vnfs/generic-vnf";
- public static final String AAI_TP_UPDATE = AAI_PREF + AAI_API_VERSION + "/network/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
+ public static final String AAI_TP_UPDATE = AAI_PREF + AAI_API_VERSION + "/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
- public static final String AAI_LINK_QUERY = AAI_PREF + AAI_API_VERSION + "/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces?interface-name={ifName}";
+ public static final String AAI_LINK_QUERY = AAI_PREF + AAI_API_VERSION + "/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
public static final String AAI_LINK_UPDATE = AAI_PREF + AAI_API_VERSION + "/network/logical-links/logical-link/{linkName}";
public static final String AAI_TP_ADDR = AAI_PREF + AAI_API_VERSION + "/network/pnfs/pnf/{node-Id}/p-interfaces/p-interface/{tp-id}";
- public static final String AAI_VPN_ADDR = AAI_PREF + AAI_API_VERSION + "/network/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces?interface-name={ifName}&operational-status={status}";
+ public static final String AAI_VPN_ADDR = AAI_PREF + AAI_API_VERSION + "/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
- public static final String AAI_CONN_ADDR =AAI_PREF + AAI_API_VERSION + "/network/vpn-bindings?vpn-id={vpnId}";
+ public static final String AAI_CONN_ADDR = AAI_PREF + AAI_API_VERSION + "/network/vpn-bindings/vpn-binding/{vpnId}";
public static final String AAI_SERVICE_INSTANCE_ADDR_4_CCVPN = AAI_PREF + AAI_API_VERSION + "/network/connectivities/connectivity/{connectivityId}";
@@ -69,19 +69,19 @@ public class AaiConfig {
public static final String AAI_VNF_ADDR = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/generic-vnfs/generic-vnf";
- public static final String AAI_TP_UPDATE = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
+ public static final String AAI_TP_UPDATE = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
- public static final String AAI_LINK_QUERY = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces?interface-name={ifName}";
+ public static final String AAI_LINK_QUERY = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
public static final String AAI_LINK_UPDATE = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/logical-links/logical-link/{linkName}";
public static final String AAI_TP_ADDR = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/pnfs/pnf/{node-Id}/p-interfaces/p-interface/{tp-id}";
- public static final String AAI_VPN_ADDR = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces?interface-name={ifName}&operational-status={status}";
+ public static final String AAI_VPN_ADDR = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{ifName}";
- public static final String AAI_CONN_ADDR =AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/vpn-bindings?vpn-id={vpnId}";
+ public static final String AAI_CONN_ADDR = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network/vpn-bindings/vpn-binding/{vpnId}";
- public static final String AAI_SERVICE_INSTANCE_ADDR_4_CCVPN = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/connectivities/connectivity/{connectivityId}";
+ public static final String AAI_SERVICE_INSTANCE_ADDR_4_CCVPN = AAI_MSB_PREF + AAI_NETWORK + AAI_API_VERSION + "/network/connectivities/connectivity/{connectivityId}";
public static final String AAI_SERVICE_INSTANCES_ADDR_4_CCVPN = AAI_MSB_PREF + AAI_BUSINESS + AAI_API_VERSION + "/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}";