db update:

Change-Id: If891fc30d6fc5a6b501235d87f32a43b50bf3acf
This commit is contained in:
Isaku Yamahata 2015-04-07 19:03:08 -07:00
parent d5d412d968
commit 75b4574055
4 changed files with 12 additions and 92 deletions

View File

@ -46,14 +46,6 @@ def upgrade(active_plugins=None, options=None):
sa.Column('mgmt_driver', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'servicetypes',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('tenant_id', sa.String(length=255), nullable=True),
sa.Column('template_id', sa.String(length=36), nullable=False),
sa.Column('service_type', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'devicetemplateattributes',
sa.Column('id', sa.String(length=36), nullable=False),
@ -69,13 +61,13 @@ def upgrade(active_plugins=None, options=None):
sa.Column('tenant_id', 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_address', sa.String(length=255), nullable=True),
sa.Column('mgmt_url', sa.String(length=255), nullable=True),
sa.Column('status', sa.String(length=255), nullable=True),
sa.ForeignKeyConstraint(['template_id'], ['devicetemplates.id'], ),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'deviceargs',
'deviceattributes',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('device_id', sa.String(length=36)),
sa.Column('key', sa.String(length=255), nullable=False),
@ -83,63 +75,3 @@ def upgrade(active_plugins=None, options=None):
sa.ForeignKeyConstraint(['device_id'], ['devices.id'], ),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'deviceservicecontexts',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('device_id', sa.String(length=36)),
sa.Column('network_id', sa.String(length=36), nullable=True),
sa.Column('subnet_id', sa.String(length=36), nullable=True),
sa.Column('port_id', sa.String(length=36), nullable=True),
sa.Column('router_id', sa.String(length=36), nullable=True),
sa.Column('role', sa.String(length=256), nullable=True),
sa.Column('index', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'serviceinstances',
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('service_type_id', sa.String(length=36), nullable=True),
sa.Column('service_table_id', sa.String(length=36), nullable=True),
sa.Column('managed_by_user', sa.Boolean(), nullable=False),
sa.Column('mgmt_driver', sa.String(length=255), nullable=True),
sa.Column('mgmt_address', sa.String(length=255), nullable=True),
sa.Column('status', sa.String(length=255), nullable=True),
sa.ForeignKeyConstraint(['service_type_id'], ['servicetypes.id'], ),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'servicecontexts',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('service_instance_id', sa.String(length=36)),
sa.Column('network_id', sa.String(length=36), nullable=True),
sa.Column('subnet_id', sa.String(length=36), nullable=True),
sa.Column('port_id', sa.String(length=36), nullable=True),
sa.Column('router_id', sa.String(length=36), nullable=True),
sa.Column('role', sa.String(length=256), nullable=True),
sa.Column('index', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
)
op.create_table(
'servicedevicebindings',
sa.Column('service_instance_id', sa.String(length=36), nullable=True),
sa.Column('device_id', sa.String(length=36), nullable=True),
sa.ForeignKeyConstraint(['device_id'], ['devices.id'], ),
sa.ForeignKeyConstraint(['service_instance_id'],
['serviceinstances.id'], ),
sa.PrimaryKeyConstraint('service_instance_id'),
sa.PrimaryKeyConstraint('device_id'),
)
def downgrade(active_plugins=None, options=None):
op.drop_table('devicetemplates')
op.drop_table('servicetypes')
op.drop_table('devicetemplateattributes')
op.drop_table('devices')
op.drop_table('deviceargs')
op.drop_table('deviceservicecontexts')
op.drop_table('serviceinstances')
op.drop_table('servicecontexts')
op.drop_table('servicedevicebindings')

View File

@ -25,18 +25,15 @@ Create Date: 2014-08-01 11:48:10.319498
revision = '4c31092895b8'
down_revision = '81ffa86020d'
from alembic import op
# from alembic import op
def upgrade(active_plugins=None, options=None):
op.drop_column('devicetameplates', 'service_types')
# op.drop_column('devicetameplates', 'service_types')
op.drop_table('servicetypes')
op.drop_table('deviceservicecontexts')
op.drop_table('serviceinstances')
op.drop_table('servicecontexts')
op.drop_table('servicedevicebindings')
def downgrade(active_plugins=None, options=None):
raise NotImplementedError()
# op.drop_table('servicetypes')
# op.drop_table('deviceservicecontexts')
# op.drop_table('serviceinstances')
# op.drop_table('servicecontexts')
# op.drop_table('servicedevicebindings')
pass

View File

@ -52,8 +52,3 @@ def upgrade(active_plugins=None, options=None):
sa.Column('clt_ns_proxy_id', sa.String(36)),
sa.PrimaryKeyConstraint('service_instance_id'),
)
def downgrade(active_plugins=None, options=None):
op.drop_table('proxymgmtport')
op.drop_table('proxyserviceport')

View File

@ -141,8 +141,6 @@ class ServiceResourcePluginDb(servicevm.ServiceVMPluginBase,
def _make_template_dict(self, template, fields=None):
res = {
'attributes': self._make_attributes_dict(template['attributes']),
'service_types':
self._make_service_types_list(template['service_types']),
}
key_list = ('id', 'tenant_id', 'name', 'description', 'infra_driver')
res.update((key, template[key]) for key in key_list)
@ -201,11 +199,9 @@ class ServiceResourcePluginDb(servicevm.ServiceVMPluginBase,
value=value)
context.session.add(attribute_db)
LOG.debug(_('template_db %(template_db)s %(attributes)s '
'%(service_types)s'),
LOG.debug(_('template_db %(template_db)s %(attributes)s '),
{'template_db': template_db,
'attributes': template_db.attributes,
'service_types': template_db.service_types})
'attributes': template_db.attributes})
return self._make_template_dict(template_db)
def update_device_template(self, context, device_template_id,