From 975d6dfb430d7ab844e1d741af660b80049a4a93 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Mon, 3 Sep 2018 14:31:48 +0800 Subject: 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 --- vio/vio/pub/utils/restcall.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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() -- cgit 1.2.3-korg