Update the ns's description processing in ns_db.NSPluginDb.create_ns().
Co-Authored-By: Dharmendra Kushwaha<dharmendra.kushwaha@nectechnologies.in> Closes-Bug: #1709226 Change-Id: I240ffcce13737bc62e0a6f42b713c484102823d4
This commit is contained in:
committed by
dharmendra kushwaha
parent
82250ba7b4
commit
eeb5c52052
4
releasenotes/notes/bug-1709226-ccb892eafc82cf9b.yaml
Normal file
4
releasenotes/notes/bug-1709226-ccb892eafc82cf9b.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Support to change ns's description using "tacker ns-create --description".
|
||||||
@@ -255,14 +255,19 @@ class NSPluginDb(network_service.NSPluginBase, db_base.CommonDbMixin):
|
|||||||
vim_id = ns['vim_id']
|
vim_id = ns['vim_id']
|
||||||
name = ns.get('name')
|
name = ns.get('name')
|
||||||
ns_id = uuidutils.generate_uuid()
|
ns_id = uuidutils.generate_uuid()
|
||||||
|
description = None
|
||||||
|
if 'description' in ns:
|
||||||
|
description = ns.get('description')
|
||||||
try:
|
try:
|
||||||
with context.session.begin(subtransactions=True):
|
with context.session.begin(subtransactions=True):
|
||||||
nsd_db = self._get_resource(context, NSD,
|
if description is None:
|
||||||
nsd_id)
|
nsd_db = self._get_resource(context, NSD,
|
||||||
|
nsd_id)
|
||||||
|
description = nsd_db.description
|
||||||
ns_db = NS(id=ns_id,
|
ns_db = NS(id=ns_id,
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
name=name,
|
name=name,
|
||||||
description=nsd_db.description,
|
description=description,
|
||||||
vnf_ids=None,
|
vnf_ids=None,
|
||||||
status=constants.PENDING_CREATE,
|
status=constants.PENDING_CREATE,
|
||||||
mgmt_urls=None,
|
mgmt_urls=None,
|
||||||
|
|||||||
@@ -696,7 +696,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'description': {
|
'description': {
|
||||||
'allow_post': True,
|
'allow_post': True,
|
||||||
'allow_put': True,
|
'allow_put': True,
|
||||||
'validate': {'type:string': None},
|
'validate': {'type:string': NAME_MAX_LEN},
|
||||||
'is_visible': True,
|
'is_visible': True,
|
||||||
'default': '',
|
'default': '',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -881,6 +881,31 @@ class TestNfvoPlugin(db_base.SqlTestCase):
|
|||||||
self.assertIn('status', result)
|
self.assertIn('status', result)
|
||||||
self.assertIn('tenant_id', result)
|
self.assertIn('tenant_id', result)
|
||||||
|
|
||||||
|
@mock.patch.object(nfvo_plugin.NfvoPlugin, 'get_auth_dict')
|
||||||
|
@mock.patch.object(vim_client.VimClient, 'get_vim')
|
||||||
|
@mock.patch.object(nfvo_plugin.NfvoPlugin, '_get_by_name')
|
||||||
|
def test_create_ns_empty_description(self, mock_get_by_name,
|
||||||
|
mock_get_vimi, mock_auth_dict):
|
||||||
|
self._insert_dummy_ns_template()
|
||||||
|
self._insert_dummy_vim()
|
||||||
|
mock_auth_dict.return_value = {
|
||||||
|
'auth_url': 'http://127.0.0.1',
|
||||||
|
'token': 'DummyToken',
|
||||||
|
'project_domain_name': 'dummy_domain',
|
||||||
|
'project_name': 'dummy_project'
|
||||||
|
}
|
||||||
|
with patch.object(TackerManager, 'get_service_plugins') as \
|
||||||
|
mock_plugins:
|
||||||
|
mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()}
|
||||||
|
mock_get_by_name.return_value = get_by_name()
|
||||||
|
|
||||||
|
ns_obj = utils.get_dummy_ns_obj()
|
||||||
|
ns_obj['ns']['description'] = ''
|
||||||
|
result = self.nfvo_plugin.create_ns(self.context, ns_obj)
|
||||||
|
self.assertIn('id', result)
|
||||||
|
self.assertEqual(ns_obj['ns']['name'], result['name'])
|
||||||
|
self.assertEqual('', result['description'])
|
||||||
|
|
||||||
@mock.patch('tacker.nfvo.nfvo_plugin.NfvoPlugin.create_nsd')
|
@mock.patch('tacker.nfvo.nfvo_plugin.NfvoPlugin.create_nsd')
|
||||||
@mock.patch.object(nfvo_plugin.NfvoPlugin, 'get_auth_dict')
|
@mock.patch.object(nfvo_plugin.NfvoPlugin, 'get_auth_dict')
|
||||||
@mock.patch.object(vim_client.VimClient, 'get_vim')
|
@mock.patch.object(vim_client.VimClient, 'get_vim')
|
||||||
|
|||||||
Reference in New Issue
Block a user