diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-09-03 14:31:48 +0800 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-09-05 10:54:35 +0800 |
commit | 975d6dfb430d7ab844e1d741af660b80049a4a93 (patch) | |
tree | 0a7a7947c52260e430bdef00ceb70cf94ee1d719 | |
parent | 0f142756b80f1c5a28bff0f68e77109447fe36e6 (diff) |
Expose intent capabilities to A&AI
This patch will registry QoS intent feature to A&AI
Change-Id: I9830887857c0b6b69ec224425a4feafec46a1907
Issue-ID: MULTICLOUD-346
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-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() |