Browse Source

Add endpoint information in interfaceInfo

This patch will fix the issue about the missing endpoint
information in the interfaceInfo of vimConnectionInfo.

Closes-Bug: #1923425
Change-Id: I364ab27ad14f0af06a1befed28196bd1b027e909
changes/50/786350/1
Aldinson Esto 3 months ago
parent
commit
c137b0ddfe
  1. 4
      tacker/tests/unit/vnflcm/fakes.py
  2. 41
      tacker/tests/unit/vnflcm/test_controller.py
  3. 3
      tacker/vnflcm/utils.py

4
tacker/tests/unit/vnflcm/fakes.py

@ -274,14 +274,14 @@ def _fake_vnf_instance_not_instantiated_response(
def fake_vnf_instance_response(
instantiated_state=fields.VnfInstanceState.NOT_INSTANTIATED,
api_version=None, **updates):
api_version=None, vimConnectionInfo=[], **updates):
if instantiated_state == fields.VnfInstanceState.NOT_INSTANTIATED:
data = _fake_vnf_instance_not_instantiated_response(**updates)
else:
data = _fake_vnf_instance_not_instantiated_response(**updates)
data['_links'] = _instantiated_vnf_links(uuidsentinel.vnf_instance_id)
data['instantiationState'] = instantiated_state
data['vimConnectionInfo'] = []
data['vimConnectionInfo'] = vimConnectionInfo
def _instantiated_vnf_info():
inst_vnf_info = {}

41
tacker/tests/unit/vnflcm/test_controller.py

@ -31,6 +31,7 @@ from tacker.api.views import vnf_subscriptions as vnf_subscription_view
from tacker.api.vnflcm.v1 import controller
from tacker.api.vnflcm.v1 import sync_resource
from tacker.common import exceptions
from tacker.common import utils as common_utils
import tacker.conductor.conductorrpc.vnf_lcm_rpc as vnf_lcm_rpc
from tacker import context
import tacker.db.vnfm.vnfm_db
@ -1207,6 +1208,46 @@ class TestController(base.TestCase):
res_dict = self.controller.show(req, uuidsentinel.instance_id)
self.assertEqual(expected_result, res_dict)
@mock.patch.object(TackerManager, 'get_service_plugins',
return_value={'VNFM':
test_nfvo_plugin.FakeVNFMPlugin()})
@mock.patch.object(objects.VnfInstance, "get_by_id")
def test_show_vnf_instantiated_with_vim_info(
self, mock_vnf_by_id, mock_get_service_plugins):
req = fake_request.HTTPRequest.blank(
'/vnf_instances/%s' % uuidsentinel.instance_id)
vim_info = {
"id": "7d24979f-491e-4fa3-8da1-4a374fe28d55",
"vim_id": None,
"vim_type": "ETSINFV.OPENSTACK_KEYSTONE.v_2",
"interface_info": {"endpoint": "http://127.0.0.1/identity"},
"access_info": {
"username": "nfv_user",
"region": "RegionOne",
"password": "devstack",
"tenant": "85d12da99f8246dfae350dbc7334a473",
}
}
vim_connection_info = objects.VimConnectionInfo(
id=vim_info['id'], vim_id=vim_info['vim_id'],
vim_type=vim_info['vim_type'],
access_info=vim_info['access_info'],
interface_info=vim_info['interface_info'])
mock_vnf_by_id.return_value = fakes.return_vnf_instance(
fields.VnfInstanceState.INSTANTIATED,
vim_connection_info=[vim_connection_info])
vim_info = common_utils.convert_snakecase_to_camelcase(vim_info)
expected_result = fakes.fake_vnf_instance_response(
fields.VnfInstanceState.INSTANTIATED,
vimConnectionInfo=[vim_info])
res_dict = self.controller.show(req, uuidsentinel.instance_id)
self.assertEqual(expected_result, res_dict)
@mock.patch.object(TackerManager, 'get_service_plugins',
return_value={'VNFM':
test_nfvo_plugin.FakeVNFMPlugin()})

3
tacker/vnflcm/utils.py

@ -510,7 +510,8 @@ def _get_vim_connection_info_from_vnf_req(vnf_instance, instantiate_vnf_req):
for vim_connection in instantiate_vnf_req.vim_connection_info:
vim_conn = objects.VimConnectionInfo(id=vim_connection.id,
vim_id=vim_connection.vim_id, vim_type=vim_connection.vim_type,
access_info=vim_connection.access_info)
access_info=vim_connection.access_info,
interface_info=vim_connection.interface_info)
vim_connection_obj_list.append(vim_conn)

Loading…
Cancel
Save