diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-09-06 02:43:32 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-06 02:43:32 +0000 |
commit | 4eb918d2f4b50d3817725d45385b60c0e0c707bb (patch) | |
tree | f03c02f61d6234f844562f4e85fb2d5cc3496d41 | |
parent | 62544851ea884627ee87885998cfbf9f716fce5d (diff) | |
parent | 975d6dfb430d7ab844e1d741af660b80049a4a93 (diff) |
Merge "Expose intent capabilities to A&AI"
-rw-r--r-- | vio/vio/pub/utils/restcall.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vio/vio/pub/utils/restcall.py b/vio/vio/pub/utils/restcall.py index ce1d0fd..12934ff 100644 --- a/vio/vio/pub/utils/restcall.py +++ b/vio/vio/pub/utils/restcall.py @@ -476,6 +476,12 @@ class AAIClient(object): logger.debug("basic_capabilities_info: %s" % caps_dict) hpa_caps.append(caps_dict) + # Intent capabilities + caps_dict = self._get_intent_capabilities(flavor['extra_specs']) + if len(caps_dict) > 0: + logger.debug("intent_capabilities_info: %s" % caps_dict) + hpa_caps.append(caps_dict) + # cpupining capabilities caps_dict = self._get_cpupinning_capabilities(flavor['extra_specs']) if len(caps_dict) > 0: @@ -549,6 +555,34 @@ class AAIClient(object): return basic_capability + def _get_intent_capabilities(self, extra_specs): + basic_capability = {} + feature_uuid = uuid.uuid4() + cpu_resv = extra_specs.get("quota:cpu_reservation_percent") + mem_resv = extra_specs.get("quota:memory_reservation_percent") + + if cpu_resv or mem_resv: + basic_capability['hpa-capability-id'] = str(feature_uuid) + basic_capability['hpa-feature'] = 'basicCapabilities' + basic_capability['architecture'] = 'generic' + basic_capability['hpa-version'] = 'v1' + intent_key = "Burstable QoS" + if cpu_resv == "100" and mem_resv == "100": + intent_key = "Guaranteed QoS" + basic_capability['hpa-feature-attributes'] = [{ + 'hpa-attribute-key': ('Infrastructure Resource Isolation ' + 'for VNF'), + 'hpa-attribute-value': json.dumps({'value': intent_key})}] + if intent_key == "Burstable QoS": + intent_value = int(mem_resv) if mem_resv else int(cpu_resv) + basic_capability['hpa-feature-attributes'].append({ + 'hpa-attribute-key': ('Burstable QoS Oversubscription ' + 'Percentage'), + 'hpa-attribute-value': json.dumps( + {'value': intent_value})}) + + return basic_capability + def _get_cpupinning_capabilities(self, extra_specs): cpupining_capability = {} feature_uuid = uuid.uuid4() |