summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--newton/newton/extensions/views/epacaps.py2
-rw-r--r--newton/newton/extensions/views/extensions.py2
-rw-r--r--newton/newton/proxy/tests/test_identity_proxy.py43
-rw-r--r--newton/newton/proxy/views/identityV3.py2
-rw-r--r--newton/newton/proxy/views/services.py2
-rw-r--r--newton/newton/registration/views/registration.py2
-rw-r--r--newton/newton/settings.py2
-rw-r--r--ocata/ocata/proxy/tests/test_identity_proxy.py43
-rw-r--r--ocata/ocata/registration/views/registration.py247
-rw-r--r--windriver/titanium_cloud/extensions/views/epacaps.py2
-rw-r--r--windriver/titanium_cloud/extensions/views/extensions.py2
-rw-r--r--windriver/titanium_cloud/extensions/views/fcaps.py2
-rw-r--r--windriver/titanium_cloud/proxy/tests/test_identity_proxy.py42
-rw-r--r--windriver/titanium_cloud/proxy/views/identityV3.py2
-rw-r--r--windriver/titanium_cloud/proxy/views/services.py2
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration.py10
-rw-r--r--windriver/titanium_cloud/registration/views/registration.py111
-rw-r--r--windriver/titanium_cloud/resource/views/capacity.py16
-rw-r--r--windriver/titanium_cloud/settings.py2
19 files changed, 404 insertions, 132 deletions
diff --git a/newton/newton/extensions/views/epacaps.py b/newton/newton/extensions/views/epacaps.py
index 7efb71a6..025d55df 100644
--- a/newton/newton/extensions/views/epacaps.py
+++ b/newton/newton/extensions/views/epacaps.py
@@ -23,7 +23,7 @@ from newton_base.extensions import epacaps as newton_epacaps
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class EpaCaps(newton_epacaps.EpaCaps):
diff --git a/newton/newton/extensions/views/extensions.py b/newton/newton/extensions/views/extensions.py
index a40ccdd3..bfff7104 100644
--- a/newton/newton/extensions/views/extensions.py
+++ b/newton/newton/extensions/views/extensions.py
@@ -19,7 +19,7 @@ from newton_base.extensions import extensions as newton_extensions
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Extensions(newton_extensions.Extensions):
diff --git a/newton/newton/proxy/tests/test_identity_proxy.py b/newton/newton/proxy/tests/test_identity_proxy.py
index f61ba699..adece80b 100644
--- a/newton/newton/proxy/tests/test_identity_proxy.py
+++ b/newton/newton/proxy/tests/test_identity_proxy.py
@@ -514,3 +514,46 @@ class TestIdentityService(unittest.TestCase):
self.assertEqual(mock_info.MOCK_TOKEN_ID,
response['X-Subject-Token'])
self.assertIsNotNone(context['token']['catalog'])
+
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_tokensV2(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(mock_auth_state)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ data = {}
+ response = self.client.post(
+ "/api/%s/v0/windriver-hudson-dc_RegionOne/identity/v2.0/"
+ "tokens" % test_base.MULTIVIM_VERSION,
+ data=data, format='json')
+ self.failUnlessEqual(status.HTTP_200_OK,
+ response.status_code)
+ context = response.json()
+
+ self.assertIsNotNone(context['access']['token'])
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ context['access']['token']["id"])
+ self.assertIsNotNone(context['access']['serviceCatalog']) \ No newline at end of file
diff --git a/newton/newton/proxy/views/identityV3.py b/newton/newton/proxy/views/identityV3.py
index c831d017..eaeeca47 100644
--- a/newton/newton/proxy/views/identityV3.py
+++ b/newton/newton/proxy/views/identityV3.py
@@ -19,7 +19,7 @@ from newton_base.proxy import identityV3 as newton_identityV3
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Tokens(newton_identityV3.Tokens):
diff --git a/newton/newton/proxy/views/services.py b/newton/newton/proxy/views/services.py
index c1d4f194..d7c1dc05 100644
--- a/newton/newton/proxy/views/services.py
+++ b/newton/newton/proxy/views/services.py
@@ -21,7 +21,7 @@ from newton_base.proxy import services as newton_services
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Services(newton_services.Services):
diff --git a/newton/newton/registration/views/registration.py b/newton/newton/registration/views/registration.py
index f07428a1..6b231a6d 100644
--- a/newton/newton/registration/views/registration.py
+++ b/newton/newton/registration/views/registration.py
@@ -26,7 +26,7 @@ from newton_base.openoapi.flavor import Flavors
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Registry(newton_registration.Registry):
diff --git a/newton/newton/settings.py b/newton/newton/settings.py
index 4a78f98b..bb7bd042 100644
--- a/newton/newton/settings.py
+++ b/newton/newton/settings.py
@@ -38,7 +38,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
# SECURITY WARNING: don't run with debug turned on in production!
-#DEBUG = True
+# DEBUG = True
ALLOWED_HOSTS = ['*']
diff --git a/ocata/ocata/proxy/tests/test_identity_proxy.py b/ocata/ocata/proxy/tests/test_identity_proxy.py
index 774b0ffb..eeabd987 100644
--- a/ocata/ocata/proxy/tests/test_identity_proxy.py
+++ b/ocata/ocata/proxy/tests/test_identity_proxy.py
@@ -25,6 +25,7 @@ from keystoneauth1.exceptions import HttpError
from newton_base.util import VimDriverUtils
from ocata.proxy.views.identityV3 import Tokens
+from newton_base.tests import mock_info
mock_viminfo = {
"createTime": "2017-04-01 02:22:27",
@@ -532,3 +533,45 @@ class TestIdentityService(unittest.TestCase):
self.assertTrue(response['X-Subject-Token'] == mock_token_id)
self.assertTrue(context['token']['catalog'] != None)
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_tokensV2(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(mock_auth_state)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ data = {}
+ response = self.client.post(
+ "/api/multicloud-ocata/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens",
+ data=data, format='json')
+ self.failUnlessEqual(status.HTTP_200_OK,
+ response.status_code)
+ context = response.json()
+
+ self.assertIsNotNone(context['access']['token'])
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ context['access']['token']["id"])
+ self.assertIsNotNone(context['access']['serviceCatalog'])
+
diff --git a/ocata/ocata/registration/views/registration.py b/ocata/ocata/registration/views/registration.py
index ddd856b5..d824b88e 100644
--- a/ocata/ocata/registration/views/registration.py
+++ b/ocata/ocata/registration/views/registration.py
@@ -38,6 +38,11 @@ class Registry(newton_registration.Registry):
def _discover_flavors(self, vimid="", session=None, viminfo=None):
try:
cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
+ cloud_extra_info_str = viminfo.get('cloud_extra_info')
+ if cloud_extra_info_str:
+ cloud_extra_info = json.loads(cloud_extra_info_str)
+ cloud_dpdk_info = cloud_extra_info.get("ovsDpdk")
+
hpa_caps = []
hpa_caps.append("[")
for flavor in self._get_list_resources(
@@ -65,164 +70,174 @@ class Registry(newton_registration.Registry):
if (flavor['name'].find('onap.') == -1):
continue
- properties = flavor['properties'].split(', ')
- uuid4 = uuid.uuid4()
- # add hpa capability cpu pinning
- if (flavor['name'].find('onap.cpu_pinning') != -1):
- hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
- hpa_caps.append("'hpaFeature': 'cpuPinning', ")
- hpa_caps.append("'hardwareArchitecture': 'generic', ")
- hpa_caps.append("'version': 'v1', ")
-
- if len(properties):
- flavor_info['flavor-properties'] = flavor['properties']
- hpa_caps.append("[")
- for p in range(len(properties)):
- value = properties[p].split('=')[1]
- if (properties[p].find("hw:cpu_policy") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'logicalCpuThreadPinningPolicy', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
- if (properties[p].find("hw:cpu_thread_policy") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'logicalCpuPinningPolicy', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
- hpa_caps.append("]")
- hpa_caps.append("},")
+ if (flavor['extra_specs'] == ""):
+ continue
- elif (flavor['name'].find('onap.cpu_topology') != -1):
- hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
- hpa_caps.append("'hpaFeature': 'cpuTopology', ")
- hpa_caps.append("'hardwareArchitecture': 'generic', ")
- hpa_caps.append("'version': 'v1', ")
+ flavor_info['extra_specs'] = flavor['extra_specs']
+ extra_specs = flavor['extra_specs']
+ extra_arr = extra_specs.split(', ')
+ uuid4 = uuid.uuid4()
- if len(properties):
- flavor_info['flavor-properties'] = flavor['properties']
- hpa_caps.append("[")
- for p in range(len(properties)):
- value = properties[p].split('=')[1]
- if (properties[p].find("hw:cpu_sockets") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'numCpuSockets', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
- if (properties[p].find("hw:cpu_cores") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'numCpuCores', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
- if (properties[p].find("hw:cpu_threads") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'numCpuThreads', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
- hpa_caps.append("]")
- hpa_caps.append("},")
+ # add ovs dpdk
+ hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
+ hpa_caps.append("'hpaFeature': 'ovsDpdk', ")
+ hpa_caps.append("'hardwareArchitecture': '" + cloud_dpdk_info.get("arch") + "', ")
+ hpa_caps.append("'version': '" + cloud_dpdk_info.get("version") + "', ")
+ hpa_caps.append("[")
+ hpa_caps.append("{'hpa-attribute-key':'"+ cloud_dpdk_info.get("libname") + "', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + cloud_dpdk_info.get("libvalue") + "'}}, ")
+ hpa_caps.append("]")
+ hpa_caps.append("},")
+
+ # add basic Capabilities
+ hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
+ hpa_caps.append("'hpaFeature': 'baseCapabilities', ")
+ hpa_caps.append("'hardwareArchitecture': 'generic', ")
+ hpa_caps.append("'version': 'v1', ")
+ hpa_caps.append("[")
+ hpa_caps.append("{'hpa-attribute-key':'numVirtualCpu', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + str(flavor_info['vcpus']) + "'}}, ")
+ hpa_caps.append("{'hpa-attribute-key':'virtualMemSize', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['mem']) + ", unit:'MB'}}, ")
+ hpa_caps.append("]")
+ hpa_caps.append("},")
+
+ # add local storage
+ hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
+ hpa_caps.append("'hpaFeature': 'localStorage', ")
+ hpa_caps.append("'hardwareArchitecture': 'generic', ")
+ hpa_caps.append("'version': 'v1', ")
+ hpa_caps.append("[")
+ hpa_caps.append("{'hpa-attribute-key':'diskSize', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['disk']) + ", unit:'MB'}}, ")
+ hpa_caps.append("{'hpa-attribute-key':'ephemeralDiskSize', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['OS-FLV-EXT-DATA:ephemeral']) + ", unit:'MB'}}, ")
+ hpa_caps.append("{'hpa-attribute-key':'swapMemSize', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['swap']) + ", unit:'MB'}}, ")
+ hpa_caps.append("]")
+ hpa_caps.append("},")
- elif (flavor['name'].find('onap.base_capabilities') != -1):
+ # add hpa capability cpu pinning
+ if (extra_specs.find('hw:cpu_policy') != -1):
hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
- hpa_caps.append("'hpaFeature': 'baseCapabilities', ")
+ hpa_caps.append("'hpaFeature': 'cpuPinning', ")
hpa_caps.append("'hardwareArchitecture': 'generic', ")
hpa_caps.append("'version': 'v1', ")
-
hpa_caps.append("[")
- hpa_caps.append("{'hpa-attribute-key':'numVirtualCpu', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + str(flavor_info['vcpus']) + "'}}, ")
- hpa_caps.append("{'hpa-attribute-key':'virtualMemSize', ")
- hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['mem']) + ", unit:'MB'}}, ")
+ for p in range(len(extra_arr)):
+ if (extra_arr[p].find("hw:cpu_policy") != -1) :
+ value = extra_arr[p].split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'logicalCpuThreadPinningPolicy', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
+ if (extra_arr[p].find("hw:cpu_thread_policy") != -1) :
+ value = extra_arr[p].split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'logicalCpuPinningPolicy', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
hpa_caps.append("]")
hpa_caps.append("},")
- elif (flavor['name'].find('onap.local_storage') != -1):
+ # add cpu topology
+ if (extra_specs.find('hw:cpu_sockets') != -1):
hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
- hpa_caps.append("'hpaFeature': 'localStorage', ")
+ hpa_caps.append("'hpaFeature': 'cpuTopology', ")
hpa_caps.append("'hardwareArchitecture': 'generic', ")
hpa_caps.append("'version': 'v1', ")
-
hpa_caps.append("[")
- hpa_caps.append("{'hpa-attribute-key':'diskSize', ")
- hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['disk']) + ", unit:'MB'}}, ")
- hpa_caps.append("{'hpa-attribute-key':'ephemeralDiskSize', ")
- hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['OS-FLV-EXT-DATA:ephemeral']) + ", unit:'MB'}}, ")
- hpa_caps.append("{'hpa-attribute-key':'swapMemSize', ")
- hpa_caps.append("'hpa-attribute-value': {'value':" + str(flavor_info['swap']) + ", unit:'MB'}}, ")
+ for p in range(len(extra_arr)):
+ if (extra_arr[p].find("hw:cpu_sockets") != -1) :
+ value = extra_specs[p].split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'numCpuSockets', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
+ if (extra_arr[p].find("hw:cpu_cores") != -1) :
+ value = extra_specs[p].split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'numCpuCores', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
+ if (extra_arr[p].find("hw:cpu_threads") != -1) :
+ value = extra_specs[p].split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'numCpuThreads', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
hpa_caps.append("]")
hpa_caps.append("},")
- elif (flavor['name'].find('onap.numa') != -1):
+ # add numa
+ if (extra_specs.find('hw:numa_nodes') != -1):
hpa_caps.append("{'hpaCapabilityID': '" + str(uuid4) + "', ")
hpa_caps.append("'hpaFeature': 'numa', ")
hpa_caps.append("'hardwareArchitecture': 'generic', ")
hpa_caps.append("'version': 'v1', ")
-
- if len(properties):
- flavor_info['flavor-properties'] = flavor['properties']
- hpa_caps.append("[")
- for p in range(len(properties)):
- p_arr = properties[p].split('=')
+ hpa_caps.append("[")
+ for p in range(len(extra_arr)):
+ if (extra_arr[p].find("hw:numa_nodes") != -1) :
+ p_arr = extra_arr[p].split('=')
+ value = p_arr[1]
+ hpa_caps.append("{'hpa-attribute-key':'numNodes', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
+ if (extra_arr[p].find("hw:numa_cpus") != -1) :
+ p_arr = extra_arr[p].split('=')
value = p_arr[1]
index = p_arr[0].split('.')[1]
- if (properties[p].find("hw:numa_nodes") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'numNodes', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
- if (properties[p].find("hw:numa_cpus") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'numaCpus-" + index + "', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'[" + value + "]'}}, ")
- if (properties[p] == ("hw:numa_mem") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'numaMem-"+ index +"', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value + ", unit:'MB'}}, ")
- hpa_caps.append("]")
+ hpa_caps.append("{'hpa-attribute-key':'numaCpus-" + index + "', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'[" + value + "]'}}, ")
+ if (extra_arr[p] == ("hw:numa_mem") != -1) :
+ p_arr = extra_arr[p].split('=')
+ value = p_arr[1]
+ index = p_arr[0].split('.')[1]
+ hpa_caps.append("{'hpa-attribute-key':'numaMem-"+ index +"', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + ", unit:'MB'}}, ")
+ hpa_caps.append("]")
hpa_caps.append("},")
- elif (flavor['name'].find('onap.huge_page') != -1):
+ # add huge page
+ if (extra_specs.find('hw:mem_page_size') != -1):
hpa_caps.append("{'hpaCapabilityId': '" + str(uuid4) + "', ")
hpa_caps.append("'hpaFeature': 'hugePages', ")
hpa_caps.append("'hardwareArchitecture': 'generic', ")
hpa_caps.append("'version': 'v1', ")
-
- if len(properties):
- flavor_info['flavor-properties'] = flavor['properties']
- hpa_caps.append("[")
- values = flavor['name'].split('_')
- for p in range(len(properties)):
- if (properties[p] == "hw:mem_page_size") :
- hpa_caps.append("{'hpa-attribute-key':'memoryPageSize', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + values[2] + "'}}, ")
- hpa_caps.append("]")
+ hpa_caps.append("[")
+ for p in range(len(extra_arr)):
+ if (extra_arr[p] == "hw:mem_page_size") :
+ value = extra_specs[p].split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'memoryPageSize', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value + "'}}, ")
+ hpa_caps.append("]")
hpa_caps.append("},")
- elif (flavor['name'].find('onap.iax') != -1):
+ # add instruction set externsions
+ if (extra_specs.find('w:capabilities:cpu_info:features') != -1):
hpa_caps.append("{'hpaCapabilityId': '" + str(uuid4) + "', ")
hpa_caps.append("'hpaFeature': 'instructionSetExtensions', ")
hpa_caps.append("'hardwareArchitecture': 'Intel64', ")
hpa_caps.append("'version': 'v1', ")
-
- if len(properties):
- flavor_info['flavor-properties'] = flavor['properties']
- hpa_caps.append("[")
- value = flavor['properties'].split('=')[1]
- for p in range(len(properties)):
- if (properties[p].find("hw:capabilities:cpu_info:features") != -1) :
- hpa_caps.append("{'hpa-attribute-key':'instructionSetExtensions', ")
- hpa_caps.append("'hpa-attribute-value': {'value':[" + value + "]}}, ")
- hpa_caps.append("]")
+ hpa_caps.append("[")
+ for p in range(len(extra_arr)):
+ if (extra_arr[p].find("hw:capabilities:cpu_info:features") != -1) :
+ value = extra_arr.split('=')[1]
+ hpa_caps.append("{'hpa-attribute-key':'instructionSetExtensions', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':[" + value + "]}}, ")
+ hpa_caps.append("]")
hpa_caps.append("},")
- elif (flavor['name'].find('onap.pci_passthrough') != -1) :
+ # add pci device passthrough
+ if (extra_specs.find('pci_passthrough:alias') != -1) :
hpa_caps.append("{'hpaCapabilityId': '" + str(uuid4) + "', ")
hpa_caps.append("'hpaFeature': 'pciPassthrough', ")
hpa_caps.append("'version': 'v1', ")
- if len(properties):
- values = properties[0].split('-')
- hpa_caps.append("'hardwareArchitecture': '" + values[2] + "', ")
-
- flavor_info['flavor-properties'] = flavor['properties']
- hpa_caps.append("[")
- value = values[4].split(':')
- hpa_caps.append("{'hpa-attribute-key':'pciCount', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value[1] + "'}}, ")
- hpa_caps.append("{'hpa-attribute-key':'pciVendorId', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + values[3] + "'}}, ")
- hpa_caps.append("{'hpa-attribute-key':'pciDeviceId', ")
- hpa_caps.append("'hpa-attribute-value': {'value':'" + value[0] + "'}}, ")
- hpa_caps.append("]")
+ hpa_caps.append("[")
+ for p in range(len(extra_arr)):
+ if (extra_arr[p] == "pci_passthrough:alias") :
+ values = extra_arr[0].split('-')
+ value = values[4].split(':')
+ hpa_caps.append("{'hpa-attribute-key':'pciCount', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value[1] + "'}}, ")
+ hpa_caps.append("{'hpa-attribute-key':'pciVendorId', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + values[3] + "'}}, ")
+ hpa_caps.append("{'hpa-attribute-key':'pciDeviceId', ")
+ hpa_caps.append("'hpa-attribute-value': {'value':'" + value[0] + "'}}, ")
+ hpa_caps.append("]")
hpa_caps.append("},")
+ hpa_caps.append("]")
+ hpa_caps.append("'hardwareArchitecture': '" + values[2] + "', ")
- else:
- self._logger.info("can not support this flavor type")
- hpa_caps.append("]")
str_hpa_caps = ''
flavor_info['hpa_capabilities'] = str_hpa_caps.join(hpa_caps)
self._logger.debug("flavor_info: %s" % flavor_info)
diff --git a/windriver/titanium_cloud/extensions/views/epacaps.py b/windriver/titanium_cloud/extensions/views/epacaps.py
index 7efb71a6..025d55df 100644
--- a/windriver/titanium_cloud/extensions/views/epacaps.py
+++ b/windriver/titanium_cloud/extensions/views/epacaps.py
@@ -23,7 +23,7 @@ from newton_base.extensions import epacaps as newton_epacaps
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class EpaCaps(newton_epacaps.EpaCaps):
diff --git a/windriver/titanium_cloud/extensions/views/extensions.py b/windriver/titanium_cloud/extensions/views/extensions.py
index d331b7b5..2cd91bf5 100644
--- a/windriver/titanium_cloud/extensions/views/extensions.py
+++ b/windriver/titanium_cloud/extensions/views/extensions.py
@@ -27,7 +27,7 @@ from newton_base.extensions import extensions as newton_extensions
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Extensions(newton_extensions.Extensions):
diff --git a/windriver/titanium_cloud/extensions/views/fcaps.py b/windriver/titanium_cloud/extensions/views/fcaps.py
index c36b2642..a093a361 100644
--- a/windriver/titanium_cloud/extensions/views/fcaps.py
+++ b/windriver/titanium_cloud/extensions/views/fcaps.py
@@ -35,7 +35,7 @@ from common.msapi import extsys
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
#dict to store running worker threads
running_threads = {}
diff --git a/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py b/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py
index 5dc061fa..cd7dd23c 100644
--- a/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py
+++ b/windriver/titanium_cloud/proxy/tests/test_identity_proxy.py
@@ -25,6 +25,7 @@ from keystoneauth1.exceptions import HttpError
from newton_base.util import VimDriverUtils
from titanium_cloud.proxy.views.identityV3 import Tokens
+from newton_base.tests import mock_info
mock_viminfo = {
"createTime": "2017-04-01 02:22:27",
@@ -532,3 +533,44 @@ class TestIdentityService(unittest.TestCase):
self.assertTrue(response['X-Subject-Token'] == mock_token_id)
self.assertTrue(context['token']['catalog'] != None)
+
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_auth_state')
+ @mock.patch.object(VimDriverUtils, 'update_token_cache')
+ def test_tokensV2(self, mock_update_token_cache, mock_get_auth_state,
+ mock_get_session, mock_get_vim_info):
+ '''
+ test API: get token
+ :param mock_update_token_cache:
+ :param mock_get_auth_state:
+ :param mock_get_session:
+ :param mock_get_vim_info:
+ :return:
+ '''
+
+ # mock VimDriverUtils APIs
+ mock_session_specs = ["get"]
+ mock_session_get_response = {'status': 200}
+ mock_session = mock.Mock(name='mock_session',
+ spec=mock_session_specs)
+ mock_session.get.return_value = mock_session_get_response
+
+ mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
+ mock_get_session.return_value = mock_session
+ mock_get_auth_state.return_value = json.dumps(mock_auth_state)
+ mock_update_token_cache.return_value = mock_info.MOCK_TOKEN_ID
+
+ # simulate client to make the request
+ data = {}
+ response = self.client.post(
+ "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/identity/v2.0/tokens",
+ data=data, format='json')
+ self.failUnlessEqual(status.HTTP_200_OK,
+ response.status_code)
+ context = response.json()
+
+ self.assertIsNotNone(context['access']['token'])
+ self.assertEqual(mock_info.MOCK_TOKEN_ID,
+ context['access']['token']["id"])
+ self.assertIsNotNone(context['access']['serviceCatalog'])
diff --git a/windriver/titanium_cloud/proxy/views/identityV3.py b/windriver/titanium_cloud/proxy/views/identityV3.py
index c831d017..eaeeca47 100644
--- a/windriver/titanium_cloud/proxy/views/identityV3.py
+++ b/windriver/titanium_cloud/proxy/views/identityV3.py
@@ -19,7 +19,7 @@ from newton_base.proxy import identityV3 as newton_identityV3
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Tokens(newton_identityV3.Tokens):
diff --git a/windriver/titanium_cloud/proxy/views/services.py b/windriver/titanium_cloud/proxy/views/services.py
index c1d4f194..d7c1dc05 100644
--- a/windriver/titanium_cloud/proxy/views/services.py
+++ b/windriver/titanium_cloud/proxy/views/services.py
@@ -21,7 +21,7 @@ from newton_base.proxy import services as newton_services
logger = logging.getLogger(__name__)
-#DEBUG=True
+# DEBUG=True
class Services(newton_services.Services):
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py
index 231a4358..0b3a516d 100644
--- a/windriver/titanium_cloud/registration/tests/test_registration.py
+++ b/windriver/titanium_cloud/registration/tests/test_registration.py
@@ -54,7 +54,15 @@ MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE = {
"hw:cpu_sockets" : "2",
"hw:cpu_cores" : "4",
"hw:cpu_threads" : "16",
- "hw:mem_page_size" : "large"
+ "hw:mem_page_size" : "large",
+ "hw:numa_nodes" : "2",
+ "hw:numa_cpus.0" : "0,1",
+ "hw:numa_cpus.1" : "2,3,4,5",
+ "hw:numa_mem.0" : "2048",
+ "hw:numa_mem.1" : "2048",
+ "hw:capabilities:cpu_info:features":"avx,acpi",
+ "pci_passthrough:alias":"sriov-vf-intel-8086-15b3:4"
+
}
}
diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py
index 7fce48a6..769040ff 100644
--- a/windriver/titanium_cloud/registration/views/registration.py
+++ b/windriver/titanium_cloud/registration/views/registration.py
@@ -26,7 +26,7 @@ from keystoneauth1.exceptions import HttpError
logger = logging.getLogger(__name__)
-DEBUG=True
+# DEBUG=True
class Registry(newton_registration.Registry):
@@ -106,6 +106,30 @@ class Registry(newton_registration.Registry):
self._logger.debug("hugepages_capabilities_info: %s" % caps_dict)
hpa_caps.append(caps_dict)
+ # numa capabilities
+ caps_dict = self._get_numa_capabilities(extra_specs)
+ if len(caps_dict) > 0:
+ self._logger.debug("numa_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
+ # storage capabilities
+ caps_dict = self._get_storage_capabilities(flavor)
+ if len(caps_dict) > 0:
+ self._logger.debug("storage_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
+ # CPU instruction set extension capabilities
+ caps_dict = self._get_instruction_set_capabilities(extra_specs)
+ if len(caps_dict) > 0:
+ self._logger.debug("instruction_set_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
+ # PCI passthrough capabilities
+ caps_dict = self._get_pci_passthrough_capabilities(extra_specs)
+ if len(caps_dict) > 0:
+ self._logger.debug("pci_passthrough_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
return hpa_caps
def _get_hpa_basic_capabilities(self, flavor):
@@ -182,3 +206,88 @@ class Registry(newton_registration.Registry):
hugepages_capability['attributes'].append({'hpa-attribute-key': 'memoryPageSize',
'hpa-attribute-value':{'value': str(extra_specs['hw:mem_page_size'])}})
return hugepages_capability
+
+ def _get_numa_capabilities(self, extra_specs):
+ numa_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ if extra_specs.has_key('hw:numa_nodes'):
+ numa_capability['hpaCapabilityID'] = str(feature_uuid)
+ numa_capability['hpaFeature'] = 'numa'
+ numa_capability['hardwareArchitecture'] = 'generic'
+ numa_capability['version'] = 'v1'
+
+ numa_capability['attributes'] = []
+ numa_capability['attributes'].append({'hpa-attribute-key': 'numaNodes',
+ 'hpa-attribute-value':{'value': str(extra_specs['hw:numa_nodes'])}})
+
+ for num in range(0, int(extra_specs['hw:numa_nodes'])):
+ numa_cpu_node = "hw:numa_cpus.%s" % num
+ numa_mem_node = "hw:numa_mem.%s" % num
+ numacpu_key = "numaCpu-%s" % num
+ numamem_key = "numaMem-%s" % num
+
+ if extra_specs.has_key(numa_cpu_node) and extra_specs.has_key(numa_mem_node):
+ numa_capability['attributes'].append({'hpa-attribute-key': numacpu_key,
+ 'hpa-attribute-value':{'value': str(extra_specs[numa_cpu_node])}})
+ numa_capability['attributes'].append({'hpa-attribute-key': numamem_key,
+ 'hpa-attribute-value':{'value': str(extra_specs[numa_mem_node]),'unit':'MB'}})
+
+ return numa_capability
+
+ def _get_storage_capabilities(self, flavor):
+ storage_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ storage_capability['hpaCapabilityID'] = str(feature_uuid)
+ storage_capability['hpaFeature'] = 'localStorage'
+ storage_capability['hardwareArchitecture'] = 'generic'
+ storage_capability['version'] = 'v1'
+
+ storage_capability['attributes'] = []
+ storage_capability['attributes'].append({'hpa-attribute-key': 'diskSize',
+ 'hpa-attribute-value':{'value': str(flavor['disk']), 'unit':'GB'}})
+ storage_capability['attributes'].append({'hpa-attribute-key': 'swapMemSize',
+ 'hpa-attribute-value':{'value': str(flavor['swap']), 'unit':'MB'}})
+ storage_capability['attributes'].append({'hpa-attribute-key': 'ephemeralDiskSize',
+ 'hpa-attribute-value':{'value': str(flavor['OS-FLV-EXT-DATA:ephemeral']), 'unit':'GB'}})
+ return storage_capability
+
+ def _get_instruction_set_capabilities(self, extra_specs):
+ instruction_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ if extra_specs.has_key('hw:capabilities:cpu_info:features'):
+ instruction_capability['hpaCapabilityID'] = str(feature_uuid)
+ instruction_capability['hpaFeature'] = 'instructionSetExtensions'
+ instruction_capability['hardwareArchitecture'] = 'Intel64'
+ instruction_capability['version'] = 'v1'
+
+ instruction_capability['attributes'] = []
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'instructionSetExtensions',
+ 'hpa-attribute-value':{'value': str(extra_specs['hw:capabilities:cpu_info:features'])}})
+ return instruction_capability
+
+ def _get_pci_passthrough_capabilities(self, extra_specs):
+ instruction_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ if extra_specs.has_key('pci_passthrough:alias'):
+ value1 = extra_specs['pci_passthrough:alias'].split(':')
+ value2 = value1[0].split('-')
+
+ instruction_capability['hpaCapabilityID'] = str(feature_uuid)
+ instruction_capability['hpaFeature'] = 'pciePassthrough'
+ instruction_capability['hardwareArchitecture'] = str(value2[2])
+ instruction_capability['version'] = 'v1'
+
+
+ instruction_capability['attributes'] = []
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'pciCount',
+ 'hpa-attribute-value':{'value': str(value1[1])}})
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'pciVendorId',
+ 'hpa-attribute-value':{'value': str(value2[3])}})
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'pciDeviceId',
+ 'hpa-attribute-value':{'value': str(value2[4])}})
+
+ return instruction_capability
diff --git a/windriver/titanium_cloud/resource/views/capacity.py b/windriver/titanium_cloud/resource/views/capacity.py
index d73cc0fb..0d44d0c4 100644
--- a/windriver/titanium_cloud/resource/views/capacity.py
+++ b/windriver/titanium_cloud/resource/views/capacity.py
@@ -38,8 +38,8 @@ class CapacityCheck(APIView):
self._logger = logger
def post(self, request, vimid=""):
- self._logger.info("CapacityCheck--post::vimid, data> %s, %s" % (vimid, request.data))
- self._logger.debug("CapacityCheck--post::META> %s" % request.META)
+ self._logger.info("vimid, data> %s, %s" % (vimid, request.data))
+ self._logger.debug("META> %s" % request.META)
hasEnoughResource = False
try :
@@ -58,22 +58,31 @@ class CapacityCheck(APIView):
#get limit for this tenant
req_resouce = "/limits"
+ self._logger.info("check limits> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check limits> status:%s" % resp.status_code)
content = resp.json()
compute_limits = content['limits']['absolute']
+ self._logger.debug("check limits> resp data:%s" % content)
#get total resource of this cloud region
req_resouce = "/os-hypervisors/statistics"
+ self._logger.info("check os-hypervisors statistics> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check os-hypervisors statistics> status:%s" % resp.status_code)
content = resp.json()
hypervisor_statistics = content['hypervisor_statistics']
+ self._logger.debug("check os-hypervisors statistics> resp data:%s" % content)
#get storage limit for this tenant
service['service_type'] = 'volumev2'
req_resouce = "/limits"
+ self._logger.info("check volumev2 limits> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check volumev2> status:%s" % resp.status_code)
content = resp.json()
storage_limits = content['limits']['absolute']
+ self._logger.debug("check volumev2> resp data:%s" % content)
# compute actual available resource for this tenant
remainVCPU = compute_limits['maxTotalCores'] - compute_limits['totalCoresUsed']
@@ -102,8 +111,11 @@ class CapacityCheck(APIView):
else:
hasEnoughResource = True
+ self._logger.info("RESP with data> result:%s" % hasEnoughResource)
return Response(data={'result': hasEnoughResource}, status=status.HTTP_200_OK)
except VimDriverNewtonException as e:
+ self._logger.error("Plugin exception> status:%s,error:%s"
+ % (e.status_code, e.content))
return Response(data={'result': hasEnoughResource,'error': e.content}, status=e.status_code)
except HttpError as e:
self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
diff --git a/windriver/titanium_cloud/settings.py b/windriver/titanium_cloud/settings.py
index f05991a9..c3da724f 100644
--- a/windriver/titanium_cloud/settings.py
+++ b/windriver/titanium_cloud/settings.py
@@ -32,7 +32,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
# SECURITY WARNING: don't run with debug turned on in production!
-#DEBUG = True
+# DEBUG = True
ALLOWED_HOSTS = ['*']