add description to vnf

Change-Id: I3ccd7a98a26966bc18e4c358ad4bdeefa895e343
This commit is contained in:
Isaku Yamahata 2015-05-18 19:10:14 -07:00
parent 7dba4d8208
commit 96d5349699
4 changed files with 49 additions and 3 deletions

View File

@ -0,0 +1,35 @@
# Copyright 2015 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.
#
"""add descrition to vnf
Revision ID: 13c0e0661015
Revises: 4c31092895b8
Create Date: 2015-05-18 18:47:22.180962
"""
# revision identifiers, used by Alembic.
revision = '13c0e0661015'
down_revision = '4c31092895b8'
from alembic import op
import sqlalchemy as sa
def upgrade(active_plugins=None, options=None):
op.add_column('devices',
sa.Column('description', sa.String(255),
nullable=True, server_default=''))

View File

@ -1 +1 @@
4c31092895b8
13c0e0661015

View File

@ -106,6 +106,7 @@ class Device(model_base.BASE, models_v1.HasTenant):
template = orm.relationship('DeviceTemplate')
name = sa.Column(sa.String(255), nullable=True)
description = sa.Column(sa.String(255), nullable=True)
# sufficient information to uniquely identify hosting device.
# In case of service VM, it's UUID of nova VM.
@ -337,8 +338,8 @@ class ServiceResourcePluginDb(servicevm.ServiceVMPluginBase,
'service_context':
self._make_device_service_context_dict(device_db.service_context),
}
key_list = ('id', 'tenant_id', 'name', 'instance_id', 'template_id',
'status', 'mgmt_url')
key_list = ('id', 'tenant_id', 'name', 'description', 'instance_id',
'template_id', 'status', 'mgmt_url')
res.update((key, device_db[key]) for key in key_list)
return self._fields(res, fields)
@ -517,9 +518,12 @@ class ServiceResourcePluginDb(servicevm.ServiceVMPluginBase,
attributes = device.get('attributes', {})
service_context = device.get('service_context', [])
with context.session.begin(subtransactions=True):
template_db = self._get_resource(context, DeviceTemplate,
template_id)
device_db = Device(id=device_id,
tenant_id=tenant_id,
name=name,
description=template_db.description,
instance_id=None,
template_id=template_id,
status=constants.PENDING_CREATE)

View File

@ -235,6 +235,13 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True,
'default': '',
},
'description': {
'allow_post': True,
'allow_put': True,
'validate': {'type:string': None},
'is_visible': True,
'default': '',
},
'instance_id': {
'allow_post': False,
'allow_put': False,