From fcea281cee9b4202bdfcc9cf390c6d95d379396c Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Sat, 2 May 2015 15:40:26 -0700 Subject: [PATCH] device, vnf: add name column Change-Id: I12b66e4cbf942db7f463cded5783c059c36152a1 --- .../versions/1c6b0d82afcd_servicevm_framework.py | 1 + tacker/db/vm/vm_db.py | 8 ++++++-- tacker/extensions/servicevm.py | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tacker/db/migration/alembic_migrations/versions/1c6b0d82afcd_servicevm_framework.py b/tacker/db/migration/alembic_migrations/versions/1c6b0d82afcd_servicevm_framework.py index cb0556e88..f485ed35e 100644 --- a/tacker/db/migration/alembic_migrations/versions/1c6b0d82afcd_servicevm_framework.py +++ b/tacker/db/migration/alembic_migrations/versions/1c6b0d82afcd_servicevm_framework.py @@ -59,6 +59,7 @@ def upgrade(active_plugins=None, options=None): 'devices', sa.Column('id', sa.String(length=36), nullable=False), sa.Column('tenant_id', sa.String(length=255), nullable=True), + sa.Column('name', sa.String(length=255), nullable=True), sa.Column('template_id', sa.String(length=36), nullable=True), sa.Column('instance_id', sa.String(length=255), nullable=True), sa.Column('mgmt_url', sa.String(length=255), nullable=True), diff --git a/tacker/db/vm/vm_db.py b/tacker/db/vm/vm_db.py index 36b83869c..b6df80b6f 100644 --- a/tacker/db/vm/vm_db.py +++ b/tacker/db/vm/vm_db.py @@ -97,6 +97,8 @@ class Device(model_base.BASE, models_v1.HasId, models_v1.HasTenant): template_id = sa.Column(sa.String(36), sa.ForeignKey('devicetemplates.id')) template = orm.relationship('DeviceTemplate') + name = 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. instance_id = sa.Column(sa.String(255), nullable=True) @@ -324,8 +326,8 @@ class ServiceResourcePluginDb(servicevm.ServiceVMPluginBase, 'service_context': self._make_device_service_context_dict(device_db.service_context), } - key_list = ('id', 'tenant_id', 'instance_id', 'template_id', 'status', - 'mgmt_url') + key_list = ('id', 'tenant_id', 'name', 'instance_id', 'template_id', + 'status', 'mgmt_url') res.update((key, device_db[key]) for key in key_list) return self._fields(res, fields) @@ -486,12 +488,14 @@ class ServiceResourcePluginDb(servicevm.ServiceVMPluginBase, LOG.debug(_('device %s'), device) tenant_id = self._get_tenant_id_for_create(context, device) template_id = device['template_id'] + name = device.get('name') device_id = device.get('id') or str(uuid.uuid4()) kwargs = device.get('attributes', {}) service_context = device.get('service_context', []) with context.session.begin(subtransactions=True): device_db = Device(id=device_id, tenant_id=tenant_id, + name=name, instance_id=None, template_id=template_id, status=constants.PENDING_CREATE) diff --git a/tacker/extensions/servicevm.py b/tacker/extensions/servicevm.py index c0e93ba3f..99f5d4ce4 100644 --- a/tacker/extensions/servicevm.py +++ b/tacker/extensions/servicevm.py @@ -228,6 +228,13 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': {'type:uuid': None}, 'is_visible': True, }, + 'name': { + 'allow_post': True, + 'allow_put': True, + 'validate': {'type:string': None}, + 'is_visible': True, + 'default': '', + }, 'instance_id': { 'allow_post': False, 'allow_put': False,