Using cloud-region in vGMuxInfra flow 59/48359/2
authorRitu Sood <ritu.sood@intel.com>
Tue, 22 May 2018 02:44:48 +0000 (19:44 -0700)
committerRitu Sood <ritu.sood@intel.com>
Tue, 22 May 2018 04:14:38 +0000 (21:14 -0700)
If no pserver available for vserver use
cloud-region to get the complex information.
This patch also fixes a version issue.

Change-Id: I981941feef96e531b3ca427ec269cf810f652922
Issue-ID: OPTFRA-241
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
conductor/conductor/controller/translator.py
conductor/conductor/data/plugins/inventory_provider/aai.py

index 2913c69..7cd90f4 100644 (file)
@@ -37,7 +37,7 @@ LOG = log.getLogger(__name__)
 
 CONF = cfg.CONF
 
-VERSIONS = ["2016-11-01", "2017-10-10"]
+VERSIONS = ["2016-11-01", "2017-10-10", "2018-02-01"]
 LOCATION_KEYS = ['latitude', 'longitude', 'host_name', 'clli_code']
 INVENTORY_PROVIDERS = ['aai']
 INVENTORY_TYPES = ['cloud', 'service', 'transport']
index 2e36bf5..b556ef7 100644 (file)
@@ -1027,7 +1027,8 @@ class AAI(base.InventoryProviderBase):
                         for i in range(0, len(rl_data_list)):
                             vs_link_list.append(rl_data_list[i].get('link'))
 
-                        candidate['cloud_owner'] = rl_data.get('d_value')
+                        cloud_owner = rl_data.get('d_value')
+                        candidate['cloud_owner'] = cloud_owner
 
                         search_key = "cloud-region.cloud-region-id"
 
@@ -1163,22 +1164,38 @@ class AAI(base.InventoryProviderBase):
 
                             # Third level query to get cloud region from pserver
                             if not ps_link:
-                                LOG.error(_LE("{} pserver related link "
-                                              "not found in A&AI: {}").
+                                LOG.debug(_LE("{} pserver related link "
+                                              "not found in A&AI: {} using cloud-region ").
                                           format(name, rl_data))
-                                continue
-                            ps_path = self._get_aai_path_from_link(ps_link)
-                            if not ps_path:
-                                LOG.error(_LE("{} pserver path information "
-                                              "not found in A&AI: {}").
-                                          format(name, ps_link))
-                                continue  # move ahead with the next vnf
-                            path = self._aai_versioned_path(ps_path)
-                            response = self._request(
-                                path=path, context="PSERVER", value=ps_path)
-                            if response is None or response.status_code != 200:
-                                continue
-                            body = response.json()
+                                if not (cloud_owner and cloud_region_id):
+                                    LOG.error("{} cloud-owner or cloud-region not "
+                                              "available from A&AI".
+                                              format(name))
+                                    continue  # move ahead with the next vnf
+                                cloud_region_uri = \
+                                    '/cloud-infrastructure/cloud-regions/cloud-region' \
+                                    '/?cloud-owner=' + cloud_owner\
+                                    + '&cloud-region-id=' + cloud_region_id
+                                path = self._aai_versioned_path(cloud_region_uri)
+                                response = self._request('get',
+                                                         path=path,
+                                                         data=None)
+                                if response is None or response.status_code != 200:
+                                    continue
+                                body = response.json()
+                            else:
+                                ps_path = self._get_aai_path_from_link(ps_link)
+                                if not ps_path:
+                                    LOG.error(_LE("{} pserver path information "
+                                                  "not found in A&AI: {}").
+                                              format(name, ps_link))
+                                    continue  # move ahead with the next vnf
+                                path = self._aai_versioned_path(ps_path)
+                                response = self._request(
+                                    path=path, context="PSERVER", value=ps_path)
+                                if response is None or response.status_code != 200:
+                                    continue
+                                body = response.json()
 
                             related_to = "complex"
                             search_key = "complex.physical-location-id"
@@ -1202,6 +1219,9 @@ class AAI(base.InventoryProviderBase):
                                           "available from A&AI")
                             continue
 
+                        # In the scenario where no pserver information is available
+                        # assumption here is that cloud-region does not span across
+                        # multiple complexes
                         if len(complex_list) > 1:
                             if not self.match_vserver_attribute(complex_list):
                                 self._log_multiple_item_error(