Remove infra and mgmt parsing logic from API

This patch removes the logic of fetching infra and mgmt driver information
from API and storing it in DB.

Change-Id: Iccf5ecf016fb7f32e8e3d7fdc4f204bb58bee670
Partial-Bug: #1630936
Depends-On: I4684e69b8993e6c35503317503dd73e2c13f44dd
This commit is contained in:
Janki 2016-12-02 06:09:19 +05:30 committed by Andy Yan
parent a7e3732db6
commit 267ba6e55a
9 changed files with 46 additions and 54 deletions

View File

@ -0,0 +1,39 @@
# 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.
#
"""remove infra_driver column
Revision ID: 8f7145914cb0
Revises: 0ae5b1ce3024
Create Date: 2016-12-08 17:28:26.609343
"""
# revision identifiers, used by Alembic.
revision = '8f7145914cb0'
down_revision = '0ae5b1ce3024'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade(active_plugins=None, options=None):
op.drop_column('vnfd', 'infra_driver')
def downgrade(active_plugins=None, options=None):
op.add_column('vnfd', sa.Column('infra_driver', mysql.VARCHAR(length=255),
nullable=True))

View File

@ -1 +1 @@
0ae5b1ce3024 8f7145914cb0

View File

@ -59,9 +59,6 @@ class VNFD(model_base.BASE, models_v1.HasId, models_v1.HasTenant,
# In future, single service VM may accomodate multiple services. # In future, single service VM may accomodate multiple services.
service_types = orm.relationship('ServiceType', backref='vnfd') service_types = orm.relationship('ServiceType', backref='vnfd')
# driver to create hosting vnf. e.g. noop, heat, etc...
infra_driver = sa.Column(sa.String(255))
# driver to communicate with service managment # driver to communicate with service managment
mgmt_driver = sa.Column(sa.String(255)) mgmt_driver = sa.Column(sa.String(255))
@ -184,8 +181,7 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
vnfd.service_types) vnfd.service_types)
} }
key_list = ('id', 'tenant_id', 'name', 'description', key_list = ('id', 'tenant_id', 'name', 'description',
'infra_driver', 'mgmt_driver', 'mgmt_driver', 'created_at', 'updated_at')
'created_at', 'updated_at')
res.update((key, vnfd[key]) for key in key_list) res.update((key, vnfd[key]) for key in key_list)
return self._fields(res, fields) return self._fields(res, fields)
@ -206,10 +202,6 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
res.update((key, vnf_db[key]) for key in key_list) res.update((key, vnf_db[key]) for key in key_list)
return self._fields(res, fields) return self._fields(res, fields)
@staticmethod
def _infra_driver_name(vnf_dict):
return vnf_dict['vnfd']['infra_driver']
@staticmethod @staticmethod
def _mgmt_driver_name(vnf_dict): def _mgmt_driver_name(vnf_dict):
return vnf_dict['vnfd']['mgmt_driver'] return vnf_dict['vnfd']['mgmt_driver']
@ -222,9 +214,8 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
vnfd = vnfd['vnfd'] vnfd = vnfd['vnfd']
LOG.debug(_('vnfd %s'), vnfd) LOG.debug(_('vnfd %s'), vnfd)
tenant_id = self._get_tenant_id_for_create(context, vnfd) tenant_id = self._get_tenant_id_for_create(context, vnfd)
infra_driver = vnfd.get('infra_driver')
mgmt_driver = vnfd.get('mgmt_driver')
service_types = vnfd.get('service_types') service_types = vnfd.get('service_types')
mgmt_driver = vnfd.get('mgmt_driver')
if (not attributes.is_attr_set(service_types)): if (not attributes.is_attr_set(service_types)):
LOG.debug(_('service types unspecified')) LOG.debug(_('service types unspecified'))
@ -237,7 +228,6 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
tenant_id=tenant_id, tenant_id=tenant_id,
name=vnfd.get('name'), name=vnfd.get('name'),
description=vnfd.get('description'), description=vnfd.get('description'),
infra_driver=infra_driver,
mgmt_driver=mgmt_driver) mgmt_driver=mgmt_driver)
context.session.add(vnfd_db) context.session.add(vnfd_db)
for (key, value) in vnfd.get('attributes', {}).items(): for (key, value) in vnfd.get('attributes', {}).items():

View File

@ -31,14 +31,6 @@ from tacker.services import service_base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class InfraDriverNotSpecified(exceptions.InvalidInput):
message = _('infra driver is not specified')
class MGMTDriverNotSpecified(exceptions.InvalidInput):
message = _('mgmt driver is not specified')
class MultipleMGMTDriversSpecified(exceptions.InvalidInput): class MultipleMGMTDriversSpecified(exceptions.InvalidInput):
message = _('More than one MGMT Driver per vnfd is not supported') message = _('More than one MGMT Driver per vnfd is not supported')
@ -219,20 +211,6 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True, 'is_visible': True,
'default': attr.ATTR_NOT_SPECIFIED, 'default': attr.ATTR_NOT_SPECIFIED,
}, },
'infra_driver': {
'allow_post': True,
'allow_put': False,
'validate': {'type:string': None},
'is_visible': True,
'default': "",
},
'mgmt_driver': {
'allow_post': True,
'allow_put': False,
'validate': {'type:string': None},
'is_visible': True,
'default': "",
},
'attributes': { 'attributes': {
'allow_post': True, 'allow_post': True,
'allow_put': False, 'allow_put': False,

View File

@ -0,0 +1,3 @@
---
fixes:
- Removed passing infa and mgmt driver in API.

View File

@ -47,7 +47,6 @@ def get_dummy_vnfd_obj():
return {u'vnfd': {u'service_types': [{u'service_type': u'vnfd'}], return {u'vnfd': {u'service_types': [{u'service_type': u'vnfd'}],
'name': 'dummy_vnfd', 'name': 'dummy_vnfd',
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
u'mgmt_driver': u'noop',
u'attributes': {u'vnfd': yaml.safe_load( u'attributes': {u'vnfd': yaml.safe_load(
tosca_vnfd_openwrt)}, tosca_vnfd_openwrt)},
'description': 'dummy_vnfd_description'}, 'description': 'dummy_vnfd_description'},

View File

@ -60,8 +60,6 @@ class TackerExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
'description': 'mytemplate0', 'description': 'mytemplate0',
'service_types': [{'service_type': 'SERVICE0'}, 'service_types': [{'service_type': 'SERVICE0'},
{'service_type': 'SERVICE1'}], {'service_type': 'SERVICE1'}],
'infra_driver': 'noop',
'mgmt_driver': 'noop',
'attributes': {'key0': 'value0', 'key1': 'value1'}, 'attributes': {'key0': 'value0', 'key1': 'value1'},
} }
} }
@ -89,8 +87,6 @@ class TackerExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
'description': 'description0', 'description': 'description0',
'service_types': [{'service_type': 'SERVICE0'}, 'service_types': [{'service_type': 'SERVICE0'},
{'service_type': 'SERVICE1'}], {'service_type': 'SERVICE1'}],
'infra_driver': 'noop',
'mgmt_driver': 'noop',
'attributes': {'key0': 'value0', 'key1': 'value1'}, 'attributes': {'key0': 'value0', 'key1': 'value1'},
}] }]
instance = self.plugin.return_value instance = self.plugin.return_value
@ -111,8 +107,6 @@ class TackerExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
'description': 'description0', 'description': 'description0',
'service_types': [{'service_type': 'SERVICE0'}, 'service_types': [{'service_type': 'SERVICE0'},
{'service_type': 'SERVICE1'}], {'service_type': 'SERVICE1'}],
'infra_driver': 'noop',
'mgmt_driver': 'noop',
'attributes': {'key0': 'value0', 'key1': 'value1'}, 'attributes': {'key0': 'value0', 'key1': 'value1'},
} }
instance = self.plugin.return_value instance = self.plugin.return_value
@ -138,7 +132,6 @@ class TackerExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
'name': 'instance0', 'name': 'instance0',
'service_type_id': _uuid(), 'service_type_id': _uuid(),
'service_table_id': _uuid(), 'service_table_id': _uuid(),
'mgmt_driver': 'noop',
'mgmt_address': 'no-address', 'mgmt_address': 'no-address',
'service_contexts': [ 'service_contexts': [
{'network_id': _uuid(), }, {'network_id': _uuid(), },
@ -163,7 +156,6 @@ class TackerExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
'name': 'instance0', 'name': 'instance0',
'service_type_id': _uuid(), 'service_type_id': _uuid(),
'service_table_id': _uuid(), 'service_table_id': _uuid(),
'mgmt_driver': 'noop',
'mgmt_address': 'no-address', 'mgmt_address': 'no-address',
'service_contexts': [ 'service_contexts': [
{'network_id': _uuid(), }, {'network_id': _uuid(), },

View File

@ -123,9 +123,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
id='eb094833-995e-49f0-a047-dfb56aaf7c4e', id='eb094833-995e-49f0-a047-dfb56aaf7c4e',
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
name='fake_template', name='fake_template',
description='fake_template_description', description='fake_template_description')
infra_driver='fake_driver',
mgmt_driver='fake_mgmt_driver')
session.add(device_template) session.add(device_template)
session.flush() session.flush()
return device_template return device_template

View File

@ -21,7 +21,6 @@ import yaml
import eventlet import eventlet
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_log import versionutils
from oslo_utils import excutils from oslo_utils import excutils
from toscaparser.tosca_template import ToscaTemplate from toscaparser.tosca_template import ToscaTemplate
@ -151,12 +150,6 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
LOG.debug(_('vnfd %s'), vnfd_data) LOG.debug(_('vnfd %s'), vnfd_data)
if 'infra_driver' in vnfd_data or 'mgmt_driver' in vnfd_data:
versionutils.report_deprecated_feature(LOG, "Deriving "
"infra_driver and mgmt_driver from VNFD API is deprecated and"
" will be removed in Ocata. infra_driver will be automatically"
" derived from target vim type. mgmt_driver will be derived "
"from TOSCA template values.")
name = vnfd_data['name'] name = vnfd_data['name']
if self._get_by_name(context, vnfm_db.VNFD, name): if self._get_by_name(context, vnfm_db.VNFD, name):
raise exceptions.DuplicateResourceName(resource='VNFD', name=name) raise exceptions.DuplicateResourceName(resource='VNFD', name=name)