diff options
author | Haibin Huang <haibin.huang@intel.com> | 2018-11-09 13:13:46 +0800 |
---|---|---|
committer | Haibin Huang <haibin.huang@intel.com> | 2018-11-09 13:28:18 +0800 |
commit | 5eea270e67a262e9ace8637cb54307c23d247066 (patch) | |
tree | 8751b23ea7f625d200ed3cfcff9887f1eb6a6133 | |
parent | 0131c1da98740d02ade2007416e7f1c7c729b9e8 (diff) |
Fixed SRIOV-NIC extra-specs format3.0.0-ONAP1.2.1
Change-Id: I479a30ca663dd9c23fab6556dc32e8dc06400489
Issue-ID: MULTICLOUD-400
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
-rw-r--r-- | share/newton_base/registration/registration.py | 7 | ||||
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration.py | 39 |
2 files changed, 43 insertions, 3 deletions
diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py index d2f0a2bf..54b1d48c 100644 --- a/share/newton_base/registration/registration.py +++ b/share/newton_base/registration/registration.py @@ -269,6 +269,7 @@ class Registry(APIView): self._logger.debug("ovsdpdk_capabilities_info: %s" % caps_dict) hpa_caps.append(caps_dict) + logger.debug("hpa_caps:%s" % hpa_caps) return hpa_caps def _get_hpa_basic_capabilities(self, flavor): @@ -512,9 +513,9 @@ class Registry(APIView): feature_uuid = uuid.uuid4() try: - if extra_specs.has_key('sriov_nic'): - value1 = extra_specs['sriov_nic'].split(':') - value2 = value1[0].split('-') + if extra_specs.has_key('aggregate_instance_extra_specs:sriov_nic'): + value1 = extra_specs['aggregate_instance_extra_specs:sriov_nic'].split(':') + value2 = value1[0].split('-', 5) sriov_capability['hpa-capability-id'] = str(feature_uuid) sriov_capability['hpa-feature'] = 'sriovNICNetwork' diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index 375ce291..38a6beed 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -196,6 +196,15 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS6_RESPONSE = { } } +# HPA UT7: sriov-nic +MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS7_RESPONSE = { + "extra_specs": { + "aggregate_instance_extra_specs:sriov_nic": "sriov-nic-intel-8086-15b3-physnet-1:1", + "capabilities:cpu_info:model": "Haswell" + } +} + + class TestRegistration(test_base.TestRequest): def setUp(self): @@ -449,3 +458,33 @@ class TestRegistration(test_base.TestRequest): self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code) + @mock.patch.object(VimDriverUtils, 'get_session') + @mock.patch.object(VimDriverUtils, 'get_vim_info') + def test_register_sriovnic_successfully( + self, mock_get_vim_info, mock_get_session): + restcall.req_to_aai = mock.Mock() + restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) + mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO + mock_get_session.return_value = test_base.get_mock_session( + ["get"], { + "side_effect": [ + self._get_mock_response(MOCK_GET_TENANT_RESPONSE), + self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE), + self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS7_RESPONSE), + self._get_mock_response(MOCK_GET_IMAGE_RESPONSE), + self._get_mock_response(), + self._get_mock_response(MOCK_GET_AZ_RESPONSE), + self._get_mock_response(MOCK_HYPERVISOR_RESPONSE), + self._get_mock_response(MOCK_GET_SNAPSHOT_RESPONSE), + self._get_mock_response(MOCK_GET_HYPERVISOR_RESPONSE) + ] + }) + + response = self.client.post(( + "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "registry"), TEST_REGISTER_ENDPOINT_REQUEST, + HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) + + self.assertEquals(status.HTTP_202_ACCEPTED, + response.status_code) + |