diff --git a/releasenotes/notes/vnfd-vnf-vim-name-mandatory-in-tacker-cb657fd11d725781.yaml b/releasenotes/notes/vnfd-vnf-vim-name-mandatory-in-tacker-cb657fd11d725781.yaml new file mode 100644 index 000000000..3e11efa04 --- /dev/null +++ b/releasenotes/notes/vnfd-vnf-vim-name-mandatory-in-tacker-cb657fd11d725781.yaml @@ -0,0 +1,4 @@ +--- +features: + - Made VNFD/VNF/VIM names mandatory in tacker. + diff --git a/tacker/db/migration/alembic_migrations/versions/5f88e86b35c7_make_vnfd_vnf_vim_name_mandatory.py b/tacker/db/migration/alembic_migrations/versions/5f88e86b35c7_make_vnfd_vnf_vim_name_mandatory.py new file mode 100644 index 000000000..012ef0ad9 --- /dev/null +++ b/tacker/db/migration/alembic_migrations/versions/5f88e86b35c7_make_vnfd_vnf_vim_name_mandatory.py @@ -0,0 +1,41 @@ +# Copyright 2016 OpenStack Foundation +# +# 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. +# + +"""make VNFD/VNF/VIM name mandatory + +Revision ID: 5f88e86b35c7 +Revises: 354de64ba129 +Create Date: 2016-06-14 11:16:16.303343 + +""" + +# revision identifiers, used by Alembic. +revision = '5f88e86b35c7' +down_revision = '354de64ba129' + +from alembic import op +from sqlalchemy.dialects import mysql + + +def upgrade(active_plugins=None, options=None): + op.alter_column('devices', 'name', + existing_type=mysql.VARCHAR(length=255), + nullable=False) + op.alter_column('devicetemplates', 'name', + existing_type=mysql.VARCHAR(length=255), + nullable=False) + op.alter_column('vims', 'name', + existing_type=mysql.VARCHAR(length=255), + nullable=False) diff --git a/tacker/db/migration/alembic_migrations/versions/HEAD b/tacker/db/migration/alembic_migrations/versions/HEAD index 805a0df7f..916d863da 100644 --- a/tacker/db/migration/alembic_migrations/versions/HEAD +++ b/tacker/db/migration/alembic_migrations/versions/HEAD @@ -1 +1 @@ -354de64ba129 +5f88e86b35c7 \ No newline at end of file diff --git a/tacker/db/nfvo/nfvo_db.py b/tacker/db/nfvo/nfvo_db.py index 4711f9827..8a0a4f411 100644 --- a/tacker/db/nfvo/nfvo_db.py +++ b/tacker/db/nfvo/nfvo_db.py @@ -38,7 +38,7 @@ VIM_AUTH_ATTRIBUTES = ('auth_url', 'vim_project', 'password', 'auth_cred') class Vim(model_base.BASE, models_v1.HasId, models_v1.HasTenant): type = sa.Column(sa.String(64), nullable=False) - name = sa.Column(sa.String(255), nullable=True) + name = sa.Column(sa.String(255), nullable=False) description = sa.Column(sa.Text, nullable=True) placement_attr = sa.Column(types.Json, nullable=True) shared = sa.Column(sa.Boolean, default=True, server_default=sql.true( diff --git a/tacker/db/vm/vm_db.py b/tacker/db/vm/vm_db.py index 30ec89c18..51a0bf628 100644 --- a/tacker/db/vm/vm_db.py +++ b/tacker/db/vm/vm_db.py @@ -46,7 +46,7 @@ class DeviceTemplate(model_base.BASE, models_v1.HasId, models_v1.HasTenant): """Represents template to create hosting device.""" # Descriptive name - name = sa.Column(sa.String(255)) + name = sa.Column(sa.String(255), nullable=False) description = sa.Column(sa.Text) # service type that this service vm provides. @@ -98,7 +98,7 @@ class Device(model_base.BASE, models_v1.HasId, models_v1.HasTenant): template_id = sa.Column(types.Uuid, sa.ForeignKey('devicetemplates.id')) template = orm.relationship('DeviceTemplate') - name = sa.Column(sa.String(255), nullable=True) + name = sa.Column(sa.String(255), nullable=False) description = sa.Column(sa.Text, nullable=True) # sufficient information to uniquely identify hosting device. diff --git a/tacker/extensions/nfvo.py b/tacker/extensions/nfvo.py index 557d65098..354d83e2b 100644 --- a/tacker/extensions/nfvo.py +++ b/tacker/extensions/nfvo.py @@ -112,7 +112,6 @@ RESOURCE_ATTRIBUTE_MAP = { 'allow_put': True, 'validate': {'type:string': None}, 'is_visible': True, - 'default': '', }, 'description': { 'allow_post': True, diff --git a/tacker/extensions/vnfm.py b/tacker/extensions/vnfm.py index a56a05b33..82af19fdc 100644 --- a/tacker/extensions/vnfm.py +++ b/tacker/extensions/vnfm.py @@ -184,7 +184,6 @@ RESOURCE_ATTRIBUTE_MAP = { 'allow_put': True, 'validate': {'type:string': None}, 'is_visible': True, - 'default': '', }, 'description': { 'allow_post': True, @@ -258,7 +257,6 @@ RESOURCE_ATTRIBUTE_MAP = { 'allow_put': True, 'validate': {'type:string': None}, 'is_visible': True, - 'default': '', }, 'description': { 'allow_post': True, diff --git a/tacker/tests/functional/vnfm/test_tosca_vnf.py b/tacker/tests/functional/vnfm/test_tosca_vnf.py index 29d0318f2..59b422ccb 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnf.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnf.py @@ -28,8 +28,10 @@ class VnfTestToscaCreate(base.BaseTackerTest): def test_create_delete_vnf_tosca_no_monitoring(self): data = dict() data['tosca'] = read_file('sample-tosca-vnfd.yaml') + vnfd_name = 'test_tosca_vnf_with_cirros_no_monitoring' toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + tosca_arg = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} # Create vnfd with tosca template vnfd_instance = self.client.create_vnfd(body=tosca_arg) diff --git a/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py b/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py index f966d941a..10c83aeeb 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py @@ -30,7 +30,9 @@ class VnfTestToscaMultipleVDU(base.BaseTackerTest): input_yaml = read_file('sample-tosca-vnfd-multi-vdu.yaml') data['tosca'] = input_yaml toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + vnfd_name = 'sample-tosca-vnfd-multi-vdu' + tosca_arg = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} # Create vnfd with tosca template vnfd_instance = self.client.create_vnfd(body=tosca_arg) diff --git a/tacker/tests/functional/vnfm/test_tosca_vnfd.py b/tacker/tests/functional/vnfm/test_tosca_vnfd.py index 18c9b593e..3f61eb523 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnfd.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnfd.py @@ -25,7 +25,9 @@ class VnfdTestCreate(base.BaseTackerTest): data = dict() data['tosca'] = read_file(tosca_vnfd_file) toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + vnfd_name = 'sample-tosca-vnfd' + tosca_arg = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} vnfd_instance = self.client.create_vnfd(body=tosca_arg) self.assertIsNotNone(vnfd_instance) diff --git a/tacker/tests/functional/vnfm/test_vnf.py b/tacker/tests/functional/vnfm/test_vnf.py index a54b5ae1a..92337e16f 100644 --- a/tacker/tests/functional/vnfm/test_vnf.py +++ b/tacker/tests/functional/vnfm/test_vnf.py @@ -26,8 +26,10 @@ class VnfTestCreate(base.BaseTackerTest): def _test_create_delete_vnf(self, vnf_name, vim_id=None): data = dict() data['tosca'] = read_file('sample_cirros_vnf_no_monitoring.yaml') + vnfd_name = 'sample_cirros_vnf_no_monitoring' toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + tosca_arg = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} # Create vnfd with tosca template vnfd_instance = self.client.create_vnfd(body=tosca_arg) diff --git a/tacker/tests/functional/vnfm/test_vnf_monitoring.py b/tacker/tests/functional/vnfm/test_vnf_monitoring.py index 243cdc544..e9db28b23 100644 --- a/tacker/tests/functional/vnfm/test_vnf_monitoring.py +++ b/tacker/tests/functional/vnfm/test_vnf_monitoring.py @@ -23,7 +23,8 @@ class VnfTestPingMonitor(base.BaseTackerTest): data = dict() data['tosca'] = read_file(vnfd_file) toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + tosca_arg = {'vnfd': {'name': vnf_name, + 'attributes': {'vnfd': toscal}}} # Create vnfd with tosca template vnfd_instance = self.client.create_vnfd(body=tosca_arg) diff --git a/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py b/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py index 7ca57e864..452cbca00 100644 --- a/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py +++ b/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py @@ -28,7 +28,9 @@ class VnfTestMultipleVDU(base.BaseTackerTest): input_yaml = read_file('sample-vnfd-multi-vdu.yaml') data['tosca'] = input_yaml toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + vnfd_name = 'sample-vnfd-multi-vdu' + tosca_arg = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} # Create vnfd with tosca template vnfd_instance = self.client.create_vnfd(body=tosca_arg) diff --git a/tacker/tests/functional/vnfm/test_vnfd.py b/tacker/tests/functional/vnfm/test_vnfd.py index 64f96142e..6c323a0bf 100644 --- a/tacker/tests/functional/vnfm/test_vnfd.py +++ b/tacker/tests/functional/vnfm/test_vnfd.py @@ -25,7 +25,9 @@ class VnfdTestCreate(base.BaseTackerTest): data = dict() data['tosca'] = read_file(vnfd_file) toscal = data['tosca'] - tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}} + vnfd_name = 'sample_cirros_vnf' + tosca_arg = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} vnfd_instance = self.client.create_vnfd(body=tosca_arg) self.assertIsNotNone(vnfd_instance) diff --git a/tacker/tests/functional/vnfm/test_vnfm_param.py b/tacker/tests/functional/vnfm/test_vnfm_param.py index 0a1f4e37f..d3d00ef71 100644 --- a/tacker/tests/functional/vnfm/test_vnfm_param.py +++ b/tacker/tests/functional/vnfm/test_vnfm_param.py @@ -23,8 +23,10 @@ class VnfmTestParam(base.BaseTackerTest): def _test_vnfd_create(self, vnfd_file): yaml_input = dict() yaml_input['tosca'] = read_file(vnfd_file) + vnfd_name = 'sample_cirros_vnf' toscal = yaml_input['tosca'] - req_dict = {'vnfd': {'attributes': {'vnfd': toscal}}} + req_dict = {'vnfd': {'name': vnfd_name, + 'attributes': {'vnfd': toscal}}} # Create vnfd vnfd_instance = self.client.create_vnfd(body=req_dict)