diff options
author | 2022-02-28 11:15:20 -0500 | |
---|---|---|
committer | 2022-03-18 08:55:51 -0400 | |
commit | 7f2e4aa47f56085be6c95cb81b6a8bea8126d56d (patch) | |
tree | 74a5316fdad985051a5a824934c522089a76ddf3 /components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai | |
parent | f71b9f809b64f17ac2bedd02a1ed6cbdb7573517 (diff) |
Jakarta changes in slice-analysis-ms for IBN Cloud leased line update and CCVPN closed-loop. This commit contains work in sub-task: 1) AAI monitor thread; 2) bandwidth evaluator; 3) policy notification code.1.1.0-slice-analysis-ms
Issue-ID: DCAEGEN2-3063
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
Change-Id: I9029ffd7563e65be59f7fd76adc2a749ff624172
Signed-off-by: decheng zhang <decheng.zhang@huawei.com>
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai')
2 files changed, 36 insertions, 0 deletions
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiInterface.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiInterface.java index 87718a5c..582916aa 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiInterface.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiInterface.java @@ -3,6 +3,7 @@ * slice-analysis-ms * ================================================================================ * Copyright (C) 2021-2022 Wipro Limited. + * Copyright (C) 2022 Huawei Canada Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,4 +34,6 @@ public interface AaiInterface { public Map<String, String> fetchServiceDetails(String snssai); public Map<String, Integer> fetchCurrentConfigurationOfSlice(String snssai); + + public Map<String, Integer> fetchMaxBandwidthOfService(String serviceId); } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java index 6284ddfb..eb5d243c 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java @@ -3,6 +3,7 @@ * slice-analysis-ms * ================================================================================ * Copyright (C) 2021-2022 Wipro Limited. + * Copyright (C) 2022 Huawei Canada Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +39,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; /** @@ -347,4 +349,35 @@ public class AaiService implements AaiInterface { } + /** + * Get network bandwidth attribute of an ethernet service. These data is inside a network policy whose + * etwork-policy-fqdn equals to provided service-instance-id + * @param serviceId target service instance id + * @return Map contains maxBandwidth value of given service-instance + */ + public Map<String, Integer> fetchMaxBandwidthOfService(String serviceId){ + log.info("Fetching max-bandwidth from AAI network-policy"); + String networkPolicyUrl = aaiBaseUrl + "/network/network-policies" + "?network-policy-fqdn=" + + serviceId; + Map<String, Integer> result = new HashMap<>(); + try { + ResponseEntity<String> resp = restclient.sendGetRequest(networkPolicyUrl, new ParameterizedTypeReference<String>() { + }); + if (resp.getStatusCodeValue() == 200){ + String networkPolicy = resp.getBody(); + JSONObject networkPolicyJson = new JSONObject(networkPolicy); + JSONArray networkPolicyList = networkPolicyJson.optJSONArray("network-policy"); + if (networkPolicyList != null){ + JSONObject networkPolicyOjb = networkPolicyList.getJSONObject(0); + result.put("maxBandwidth", networkPolicyOjb.getInt("max-bandwidth")); + return result; + } + log.info("Successfully fetched max bandwidth {}: {}", serviceId, result); + } + } catch (Exception e){ + log.warn("Error encountered when fetching maxbandwidth: " + e); + + } + return null; + } } |