summaryrefslogtreecommitdiffstats
path: root/conductor
diff options
context:
space:
mode:
authorDileep Ranganathan <dileep.ranganathan@intel.com>2018-03-16 11:45:18 -0700
committerDileep Ranganathan <dileep.ranganathan@intel.com>2018-03-16 11:58:32 -0700
commit4b9fda38ad56178ac1813c57759f6afab8099d46 (patch)
treee74789358aeeba7d677d6f84483e9c33897485bd /conductor
parent589264e69c389524b390c2daa0dc33539e9b929b (diff)
Added vim-id attribute for Homing Candidates
Added vim-id attribute to both cloud and service candidate Updated unit tests for aai.py Change-Id: I3e1faf89c0490690b3988bb6d466dfbd534e37b6 Issue-ID: OPTFRA-187 Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
Diffstat (limited to 'conductor')
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/aai.py15
-rw-r--r--conductor/conductor/solver/service.py1
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py31
3 files changed, 39 insertions, 8 deletions
diff --git a/conductor/conductor/data/plugins/inventory_provider/aai.py b/conductor/conductor/data/plugins/inventory_provider/aai.py
index f35b495..f25557f 100644
--- a/conductor/conductor/data/plugins/inventory_provider/aai.py
+++ b/conductor/conductor/data/plugins/inventory_provider/aai.py
@@ -21,13 +21,11 @@ import re
import time
import uuid
-
-from oslo_config import cfg
-from oslo_log import log
-
from conductor.common import rest
from conductor.data.plugins.inventory_provider import base
from conductor.i18n import _LE, _LI
+from oslo_config import cfg
+from oslo_log import log
LOG = log.getLogger(__name__)
@@ -821,6 +819,11 @@ class AAI(base.InventoryProviderBase):
region['cloud_region_version'])
candidate['cloud_owner'] = \
region['cloud_owner']
+
+ # Added vim-id for short-term workaround
+ candidate['vim-id'] = \
+ region['cloud_owner'] + '_' + region_id
+
candidate['physical_location_id'] = \
region['complex']['complex_id']
candidate['complex_name'] = \
@@ -992,6 +995,10 @@ class AAI(base.InventoryProviderBase):
cloud_region_id = rl_data.get('d_value')
candidate['location_id'] = cloud_region_id
+ # Added vim-id for short-term workaround
+ candidate['vim-id'] = \
+ candidate['cloud_owner'] + '_' + cloud_region_id
+
# get AIC version for service candidate
if cloud_region_id:
cloud_region_uri = '/cloud-infrastructure/cloud-regions' \
diff --git a/conductor/conductor/solver/service.py b/conductor/conductor/solver/service.py
index c54c180..f0bdb81 100644
--- a/conductor/conductor/solver/service.py
+++ b/conductor/conductor/solver/service.py
@@ -335,6 +335,7 @@ class SolverService(cotyledon.Service):
"location_type": resource.get("location_type"),
"location_id": location_id,
"is_rehome": is_rehome,
+ "vim-id": resource.get("vim-id"),
},
"attributes": {
"physical-location-id":
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
index 802168f..6b985a5 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
@@ -18,12 +18,13 @@
#
import json
import unittest
-import mock
+
import conductor.data.plugins.inventory_provider.aai as aai
+import mock
from conductor.data.plugins.inventory_provider.aai import AAI
-from conductor.common import rest
from oslo_config import cfg
+
class TestAAI(unittest.TestCase):
def setUp(self):
@@ -138,8 +139,30 @@ class TestAAI(unittest.TestCase):
self.mock_get_complex.start()
self.maxDiff = None
- self.assertEqual({u'demand_name': [{'candidate_id': u'service-instance-id','city': None,'cloud_owner': u'cloud-owner','cloud_region_version': '','complex_name': None,'cost': 1.0,'country': u'USA','existing_placement': 'false','host_id': u'vnf-name','inventory_provider': 'aai','inventory_type': 'service','latitude': u'28.543251','location_id': u'cloud-region-id','location_type': 'att_aic','longitude': u'-81.377112','physical_location_id': 'test-id','region': u'SE','service_resource_id': '','sriov_automation': 'false','state': None},{'candidate_id': u'region-name','city': u'Middletown','cloud_owner': u'cloud-owner','cloud_region_version': u'1.0','complex_name': u'complex-name','cost': 2.0,'country': u'USA','existing_placement': 'false','inventory_provider': 'aai','inventory_type': 'cloud','latitude': u'50.34','location_id': u'region-name','location_type': 'att_aic','longitude': u'30.12','physical_location_id': u'complex-id','region': u'USA','service_resource_id': u'service-resource-id-123','sriov_automation': 'false','state': u'NJ'}]} ,
- self.aai_ep.resolve_demands(demands_list))
+ self.assertEqual({u'demand_name': [
+ {'candidate_id': u'service-instance-id', 'city': None,
+ 'cloud_owner': u'cloud-owner',
+ 'vim-id': 'cloud-owner_cloud-region-id',
+ 'cloud_region_version': '', 'complex_name': None, 'cost': 1.0,
+ 'country': u'USA', 'existing_placement': 'false',
+ 'host_id': u'vnf-name', 'inventory_provider': 'aai',
+ 'inventory_type': 'service', 'latitude': u'28.543251',
+ 'location_id': u'cloud-region-id', 'location_type': 'att_aic',
+ 'longitude': u'-81.377112', 'physical_location_id': 'test-id',
+ 'region': u'SE', 'service_resource_id': '',
+ 'sriov_automation': 'false', 'state': None},
+ {'candidate_id': u'region-name', 'city': u'Middletown',
+ 'cloud_owner': u'cloud-owner',
+ 'vim-id': 'cloud-owner_region-name',
+ 'cloud_region_version': u'1.0', 'complex_name': u'complex-name',
+ 'cost': 2.0, 'country': u'USA', 'existing_placement': 'false',
+ 'inventory_provider': 'aai', 'inventory_type': 'cloud',
+ 'latitude': u'50.34', 'location_id': u'region-name',
+ 'location_type': 'att_aic', 'longitude': u'30.12',
+ 'physical_location_id': u'complex-id', 'region': u'USA',
+ 'service_resource_id': u'service-resource-id-123',
+ 'sriov_automation': 'false', 'state': u'NJ'}]},
+ self.aai_ep.resolve_demands(demands_list))
def test_get_complex(self):