Remove EPA property from multicloud as it is repaced by HPA attributes.
Change-Id: I96e2ebcc60ac55cb0f0559607de919da410f66b1
Issue-ID: AAI-1150
Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
+++ /dev/null
-# Copyright (c) 2017 Intel Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-import mock
-from django.test import Client
-from rest_framework import status
-import unittest
-
-from newton_base.tests import test_base
-from newton_base.tests import mock_info
-from newton_base.util import VimDriverUtils
-
-
-class TestEpaCaps(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_epa_caps_info(self, mock_get_vim_info):
- mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO
- cloud_owner = "windriver-hudson-dc"
- cloud_region_id = "RegionOne"
- vimid = cloud_owner + "_" + cloud_region_id
-
- response = self.client.get(
- "/api/%s/v0/%s/extensions/epa-caps" % (
- test_base.MULTIVIM_VERSION,
- vimid))
- json_content = response.json()
-
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertEquals(4, len(json_content.keys()))
- self.assertEquals(cloud_owner, json_content["cloud-owner"])
- self.assertEquals(cloud_region_id,
- json_content["cloud-region-id"])
- self.assertEquals(vimid, json_content["vimid"])
- self.assertEquals(
- json.loads(mock_info.MOCK_VIM_INFO['cloud_epa_caps']),
- json_content["cloud-epa-caps"])
self.assertEquals(cloud_region_id,
json_content["cloud-region-id"])
self.assertEquals(vimid, json_content["vimid"])
-
- self.assertEquals("epa-caps",
- json_content["extensions"][0]["alias"])
- self.assertEquals("Multiple network support",
- json_content["extensions"][0][
- "description"])
- self.assertEquals("EPACapsQuery",
- json_content["extensions"][0]["name"])
- self.assertEquals(
- "http://127.0.0.1:80/api/%s/v0/%s/extensions/epa-caps" % (
- test_base.MULTIVIM_VERSION, vimid),
- json_content["extensions"][0]["url"])
- self.assertEquals("", json_content["extensions"][0]["spec"])
from rest_framework.urlpatterns import format_suffix_patterns
from newton.extensions.views import extensions
-from newton.extensions.views import epacaps
urlpatterns = [
url(r'^sions/?$', extensions.Extensions.as_view()),
- url(r'^sions/epa-caps/?$', epacaps.EpaCaps.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-
-from django.conf import settings
-
-
-from newton_base.extensions import epacaps as newton_epacaps
-
-logger = logging.getLogger(__name__)
-
-# DEBUG=True
-
-
-class EpaCaps(newton_epacaps.EpaCaps):
-
- def __init__(self):
- self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-import mock
-from django.test import Client
-from rest_framework import status
-import unittest
-
-from newton_base.util import VimDriverUtils
-
-MOCK_VIM_INFO = {
- "createTime": "2017-04-01 02:22:27",
- "domain": "Default",
- "name": "TiS_R4",
- "password": "admin",
- "tenant": "admin",
- "type": "openstack",
- "url": "http://128.224.180.14:5000/v3",
- "userName": "admin",
- "vendor": "WindRiver",
- "version": "ocata",
- "vimId": "windriver-hudson-dc_RegionOne",
- 'cloud_owner':'windriver-hudson-dc',
- 'cloud_region_id':'RegionOne',
- 'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
- 'insecure':'True',
-}
-
-
-class TestEpaCaps(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_epa_caps_info(self, mock_get_vim_info):
- mock_get_vim_info.return_value = MOCK_VIM_INFO
- cloud_owner = "windriver-hudson-dc"
- cloud_region_id = "RegionOne"
- vimid = cloud_owner + "_" + cloud_region_id
-
- response = self.client.get(
- "/api/multicloud-ocata/v0/" + vimid + "/extensions/epa-caps")
- json_content = response.json()
-
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertEquals(4, len(json_content.keys()))
- self.assertEquals(cloud_owner, json_content["cloud-owner"])
- self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
- self.assertEquals(vimid, json_content["vimid"])
- self.assertEquals(json.loads(MOCK_VIM_INFO['cloud_epa_caps']),
- json_content["cloud-epa-caps"])
self.assertEquals(cloud_owner, json_content["cloud-owner"])
self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
self.assertEquals(vimid, json_content["vimid"])
-
- self.assertEquals("epa-caps", json_content["extensions"][0]["alias"])
- self.assertEquals("Multiple network support", json_content["extensions"][0]["description"])
- self.assertEquals("EPACapsQuery", json_content["extensions"][0]["name"])
- self.assertEquals("http://127.0.0.1:80/api/multicloud-ocata/v0/%s/extensions/epa-caps" % vimid,
- json_content["extensions"][0]["url"])
- self.assertEquals("", json_content["extensions"][0]["spec"])
from rest_framework.urlpatterns import format_suffix_patterns
from ocata.extensions.views import extensions
-from ocata.extensions.views import epacaps
urlpatterns = [
url(r'^sions/?$', extensions.Extensions.as_view()),
- url(r'^sions/epa-caps/?$', epacaps.EpaCaps.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-
-from django.conf import settings
-
-
-from newton_base.extensions import epacaps as newton_epacaps
-
-logger = logging.getLogger(__name__)
-
-# DEBUG=True
-
-
-class EpaCaps(newton_epacaps.EpaCaps):
-
- def __init__(self):
- self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
'cloud_owner':'windriver-hudson-dc',
'cloud_region_id':'RegionOne',
'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
'insecure':'True',
}
'cloud_owner':'windriver-hudson-dc',
'cloud_region_id':'RegionOne',
'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
'insecure':'True',
}
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '{"vesagent_config":{"backlogs":[{"source":"onap-aaf","domain":"fault","type":"vm","tenant":"VIM"}],"poll_interval_default":10,"ves_subscription":{"username":"user","password":"password","endpoint":"http://127.0.0.1:9005/sample"}}}',
- 'cloud_epa_caps': '',
'insecure': 'True',
}
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '{"vesagent_config":{"backlogs":[{"source":"onap-aaf","domain":"fault","type":"vm","tenant":"VIM"}],"poll_interval_default":10,"ves_subscription":{"username":"user","password":"password","endpoint":"http://127.0.0.1:9005/sample"}}}',
- 'cloud_epa_caps': '',
'insecure': 'True',
}
'cloud_owner':'openstack-hudson-dc',
'cloud_region_id':'RegionOne',
'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
'insecure':'True',
}
viminfo['name'] = tmp_viminfo['complex-name']
viminfo['version'] = tmp_viminfo['cloud-region-version']
viminfo['cloud_extra_info'] = tmp_viminfo['cloud-extra-info']
- viminfo['cloud_epa_caps'] = tmp_viminfo['cloud-epa-caps']
if tmp_authinfo:
viminfo['userName'] = tmp_authinfo['user-name']
MULTICLOUD_PLUGIN_ENDPOINT=http://172.16.77.40:9006/api/multicloud-ocata/v0/openstack-hudson-dc_RegionOne
curl -v -s -H "Content-Type: application/json" -X GET $MULTICLOUD_PLUGIN_ENDPOINT/extensions
-curl -v -s -H "Content-Type: application/json" -X GET $MULTICLOUD_PLUGIN_ENDPOINT/extensions/epa-caps
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-import mock
-from django.test import Client
-from rest_framework import status
-import unittest
-
-from newton_base.util import VimDriverUtils
-
-MOCK_VIM_INFO = {
- "createTime": "2017-04-01 02:22:27",
- "domain": "Default",
- "name": "TiS_R4",
- "password": "admin",
- "tenant": "admin",
- "type": "openstack",
- "url": "http://128.224.180.14:5000/v3",
- "userName": "admin",
- "vendor": "WindRiver",
- "version": "pike",
- "vimId": "windriver-hudson-dc_RegionOne",
- 'cloud_owner':'windriver-hudson-dc',
- 'cloud_region_id':'RegionOne',
- 'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
- 'insecure':'True',
-}
-
-
-class TestEpaCaps(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_epa_caps_info(self, mock_get_vim_info):
- mock_get_vim_info.return_value = MOCK_VIM_INFO
- cloud_owner = "windriver-hudson-dc"
- cloud_region_id = "RegionOne"
- vimid = cloud_owner + "_" + cloud_region_id
-
- response = self.client.get(
- "/api/multicloud-pike/v0/" + vimid + "/extensions/epa-caps")
- json_content = response.json()
-
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertEquals(4, len(json_content.keys()))
- self.assertEquals(cloud_owner, json_content["cloud-owner"])
- self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
- self.assertEquals(vimid, json_content["vimid"])
- self.assertEquals(json.loads(MOCK_VIM_INFO['cloud_epa_caps']),
- json_content["cloud-epa-caps"])
self.assertEquals(cloud_owner, json_content["cloud-owner"])
self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
self.assertEquals(vimid, json_content["vimid"])
-
- self.assertEquals("epa-caps", json_content["extensions"][0]["alias"])
- self.assertEquals("Multiple network support", json_content["extensions"][0]["description"])
- self.assertEquals("EPACapsQuery", json_content["extensions"][0]["name"])
- self.assertEquals("http://127.0.0.1:80/api/multicloud-pike/v0/%s/extensions/epa-caps" % vimid,
- json_content["extensions"][0]["url"])
- self.assertEquals("", json_content["extensions"][0]["spec"])
from rest_framework.urlpatterns import format_suffix_patterns
from pike.extensions.views import extensions
-from pike.extensions.views import epacaps
urlpatterns = [
url(r'^sions/?$', extensions.Extensions.as_view()),
- url(r'^sions/epa-caps/?$', epacaps.EpaCaps.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-
-from django.conf import settings
-
-
-from newton_base.extensions import epacaps as newton_epacaps
-
-logger = logging.getLogger(__name__)
-
-# DEBUG=True
-
-
-class EpaCaps(newton_epacaps.EpaCaps):
-
- def __init__(self):
- self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
'cloud_owner':'openstack-hudson-dc',
'cloud_region_id':'RegionOne',
'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
'insecure':'True',
}
viminfo['name'] = tmp_viminfo['complex-name']
viminfo['version'] = tmp_viminfo['cloud-region-version']
viminfo['cloud_extra_info'] = tmp_viminfo['cloud-extra-info']
- viminfo['cloud_epa_caps'] = tmp_viminfo['cloud-epa-caps']
if tmp_authinfo:
viminfo['userName'] = tmp_authinfo['user-name']
MULTICLOUD_PLUGIN_ENDPOINT=http://172.16.77.40:9007/api/multicloud-pike/v0/openstack-hudson-dc_RegionOne
curl -v -s -H "Content-Type: application/json" -X GET $MULTICLOUD_PLUGIN_ENDPOINT/extensions
-curl -v -s -H "Content-Type: application/json" -X GET $MULTICLOUD_PLUGIN_ENDPOINT/extensions/epa-caps
viminfo['name'] = tmp_viminfo.get('complex-name')
viminfo['version'] = tmp_viminfo.get('cloud-region-version')
viminfo['cloud_extra_info'] = tmp_viminfo.get('cloud-extra-info')
- viminfo['cloud_epa_caps'] = tmp_viminfo.get('cloud-epa-caps')
viminfo['userName'] = tmp_authinfo['user-name']
viminfo['password'] = tmp_authinfo['password']
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-
-from keystoneauth1.exceptions import HttpError
-from rest_framework import status
-from rest_framework.response import Response
-from rest_framework.views import APIView
-
-from common.exceptions import VimDriverNewtonException
-from newton_base.util import VimDriverUtils
-from common.msapi import extsys
-
-logger = logging.getLogger(__name__)
-
-
-class EpaCaps(APIView):
-
- def __init__(self):
- self.proxy_prefix = "multicloud"
- self._logger = logger
-
- def get(self, request, vimid=""):
- logger.debug("EpaCaps--get::data> %s" % request.data)
- logger.debug("EpaCaps--get::vimid> %s"
- % vimid)
- try:
-
- vim = VimDriverUtils.get_vim_info(vimid)
- caps_json = json.loads(vim['cloud_epa_caps'])
-
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- content = {
- "cloud-owner":cloud_owner,
- "cloud-region-id":cloud_region_id,
- "vimid":vimid,
- "cloud-epa-caps": caps_json,
- }
- return Response(data=content, status=status.HTTP_200_OK)
- except VimDriverNewtonException as e:
- return Response(data={'error': e.content}, status=e.status_code)
- except HttpError as e:
- logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return Response(data=e.response.json(), status=e.http_status)
- except Exception as e:
- logger.error(traceback.format_exc())
- return Response(data={'error': str(e)},
- status=status.HTTP_500_INTERNAL_SERVER_ERROR)
% vimid)
try:
cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- registered_extensions = \
- [
- {
- "alias": "epa-caps",
- "description": "Multiple network support",
- "name": "EPACapsQuery",
- "url": self.proxy_prefix + "/%s/extensions/epa-caps" \
- % (vimid),
- "spec": ""
- }
- ]
+ registered_extensions = []
content = {
"cloud-owner":cloud_owner,
self._logger.error(traceback.format_exc())
return
- def _update_epa_caps(self, cloud_owner, cloud_region_id, epa_caps_info):
- '''
- populate cloud EPA Capabilities information into AAI
- :param cloud_owner:
- :param cloud_region_id:
- :param epa_caps_info: dict of meta data about cloud-region's epa caps
-
- :return:
- '''
-
- cloud_epa_caps = {
- 'cloud-epa-caps': json.dumps(epa_caps_info),
- }
-
- if cloud_owner and cloud_region_id:
- resource_url = "/cloud-infrastructure/cloud-regions/cloud-region/%s/%s" \
- % (cloud_owner, cloud_region_id)
-
- # get cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "GET")
-
- #add resource-version to url
- if retcode == 0 and content:
- content = json.JSONDecoder().decode(content)
- #cloud_epa_caps["resource-version"] = content["resource-version"]
- content.update(cloud_epa_caps)
- cloud_epa_caps = content
-
- #update cloud-region
- retcode, content, status_code = \
- restcall.req_to_aai(resource_url, "PUT", content=cloud_epa_caps)
-
- self._logger.debug(
- "update_epa_caps,vimid:%s_%s req_to_aai: update cloud-epa-caps, return %s, %s, %s"
- % (cloud_owner,cloud_region_id, retcode, content, status_code))
-
- return retcode
- return 1 # unknown cloud owner,region_id
-
- def _discover_epa_resources(self, vimid="", viminfo=None):
- try:
- cloud_epa_caps_info = {}
- cloud_extra_info_str = viminfo.get('cloud_extra_info')
- if cloud_extra_info_str:
- cloud_extra_info = json.loads(cloud_extra_info_str)
- cloud_epa_caps_info.update(cloud_extra_info.get("epa-caps"))
-
- cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
- ret = self._update_epa_caps(cloud_owner, cloud_region_id,
- cloud_epa_caps_info)
- if ret != 0:
- # failed to update image
- self._logger.debug("failed to populate EPA CAPs info into AAI: %s, ret:%s"
- % (vimid, ret))
-
- except VimDriverNewtonException as e:
- self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
- return
- except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
- return
- except Exception as e:
- self._logger.error(traceback.format_exc())
- return
-
def _update_proxy_identity_endpoint(self, vimid):
'''
update cloud_region's identity url
# add resource-version to url
if retcode == 0 and content:
viminfo = json.JSONDecoder().decode(content)
- # cloud_epa_caps["resource-version"] = content["resource-version"]
viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v2.0" % vimid
retcode, content, status_code = \
# discover all pservers
self._discover_pservers(vimid, sess, viminfo)
- # discover all epa resources, e.g. sriov pf and vf, etc.
- self._discover_epa_resources(vimid, viminfo)
-
return Response(status=status.HTTP_202_ACCEPTED)
except VimDriverNewtonException as e:
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '',
- 'cloud_epa_caps':
- '{'
- '"huge_page":"true",'
- '"cpu_pinning":"true",'
- '"cpu_thread_policy":"true",'
- '"numa_aware":"true",'
- '"sriov":"true",'
- '"dpdk_vswitch":"true",'
- '"rdt":"false",'
- '"numa_locality_pci":"true"'
- '}',
'insecure': 'True',
}
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-
-import mock
-from django.test import Client
-from rest_framework import status
-import unittest
-
-from newton_base.util import VimDriverUtils
-
-MOCK_VIM_INFO = {
- "createTime": "2017-04-01 02:22:27",
- "domain": "Default",
- "name": "TiS_R4",
- "password": "admin",
- "tenant": "admin",
- "type": "openstack",
- "url": "http://128.224.180.14:5000/v3",
- "userName": "admin",
- "vendor": "WindRiver",
- "version": "titanium_cloud",
- "vimId": "windriver-hudson-dc_RegionOne",
- 'cloud_owner':'windriver-hudson-dc',
- 'cloud_region_id':'RegionOne',
- 'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
- 'insecure':'True',
-}
-
-
-class TestEpaCaps(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- @mock.patch.object(VimDriverUtils, 'get_vim_info')
- def test_get_epa_caps_info(self, mock_get_vim_info):
- mock_get_vim_info.return_value = MOCK_VIM_INFO
- cloud_owner = "windriver-hudson-dc"
- cloud_region_id = "RegionOne"
- vimid = cloud_owner + "_" + cloud_region_id
-
- response = self.client.get(
- "/api/multicloud-titanium_cloud/v0/" + vimid + "/extensions/epa-caps")
- json_content = response.json()
-
- self.assertEquals(status.HTTP_200_OK, response.status_code)
- self.assertEquals(4, len(json_content.keys()))
- self.assertEquals(cloud_owner, json_content["cloud-owner"])
- self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
- self.assertEquals(vimid, json_content["vimid"])
- self.assertEquals(json.loads(MOCK_VIM_INFO['cloud_epa_caps']),
- json_content["cloud-epa-caps"])
self.assertEquals(cloud_region_id, json_content["cloud-region-id"])
self.assertEquals(vimid, json_content["vimid"])
- self.assertEquals("epa-caps", json_content["extensions"][0]["alias"])
self.assertEquals("Multiple network support", json_content["extensions"][0]["description"])
- self.assertEquals("EPACapsQuery", json_content["extensions"][0]["name"])
- self.assertEquals("http://127.0.0.1:80/api/multicloud-titanium_cloud/v0/%s/extensions/epa-caps" % vimid,
- json_content["extensions"][0]["url"])
self.assertEquals("", json_content["extensions"][0]["spec"])
from rest_framework.urlpatterns import format_suffix_patterns
from titanium_cloud.extensions.views import extensions
-from titanium_cloud.extensions.views import epacaps
urlpatterns = [
url(r'^sions/?$', extensions.Extensions.as_view()),
- url(r'^sions/epa-caps/?$', epacaps.EpaCaps.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
+++ /dev/null
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-import json
-import traceback
-
-from django.conf import settings
-
-
-from newton_base.extensions import epacaps as newton_epacaps
-
-logger = logging.getLogger(__name__)
-
-# DEBUG=True
-
-
-class EpaCaps(newton_epacaps.EpaCaps):
-
- def __init__(self):
- self.proxy_prefix = settings.MULTICLOUD_PREFIX
- self._logger = logger
cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid)
registered_extensions = \
[
- {
- "alias": "epa-caps",
- "description": "Multiple network support",
- "name": "EPACapsQuery",
- "url": self.proxy_prefix + "/%s/extensions/epa-caps" % (vimid),
- "spec": ""
- },
{
"alias": "guest-monitor",
"description": "Multiple network support",
'cloud_owner':'windriver-hudson-dc',
'cloud_region_id':'RegionOne',
'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
'insecure':'True',
}
'cloud_owner':'windriver-hudson-dc',
'cloud_region_id':'RegionOne',
'cloud_extra_info':'',
- 'cloud_epa_caps':'{"huge_page":"true","cpu_pinning":"true",\
- "cpu_thread_policy":"true","numa_aware":"true","sriov":"true",\
- "dpdk_vswitch":"true","rdt":"false","numa_locality_pci":"true"}',
'insecure':'True',
}
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '',
- 'cloud_epa_caps':
- '{'
- '"huge_page":"true",'
- '"cpu_pinning":"true",'
- '"cpu_thread_policy":"true",'
- '"numa_aware":"true",'
- '"sriov":"true",'
- '"dpdk_vswitch":"true",'
- '"rdt":"false",'
- '"numa_locality_pci":"true"'
- '}',
'insecure': 'True',
}
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '{"vesagent_config":{"backlogs":[{"source":"onap-aaf","domain":"fault","type":"vm","tenant":"VIM"}],"poll_interval_default":10,"ves_subscription":{"username":"user","password":"password","endpoint":"http://127.0.0.1:9005/sample"}}}',
- 'cloud_epa_caps': '',
'insecure': 'True',
}
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info': '{"vesagent_config":{"backlogs":[{"source":"onap-aaf","domain":"fault","type":"vm","tenant":"VIM"}],"poll_interval_default":10,"ves_subscription":{"username":"user","password":"password","endpoint":"http://127.0.0.1:9005/sample"}}}',
- 'cloud_epa_caps': '',
'insecure': 'True',
}