diff options
author | Peter Stachowski <peter@tesora.com> | 2016-02-21 19:31:56 -0500 |
---|---|---|
committer | Peter Stachowski <peter@tesora.com> | 2016-02-25 11:10:51 -0500 |
commit | bf3fb085cc59fdcee42708e8c5f1fb06ec6a379e (patch) | |
tree | 18a665a0c5bb3219502d1eedc84ed64d8e0bba7f /trove/db | |
parent | de963bc49b73d91404017076b55a7946b4d32d10 (diff) | |
download | trove-bf3fb085cc59fdcee42708e8c5f1fb06ec6a379e.tar.gz |
Server side of module maintenance commands
This changeset handles the details of creating,
updating, listing and deleting Trove 'modules.'
Two new tables have been added to the Trove database:
modules
instance_modules
although the instance_modules table is at present unused.
Scenario tests have been written as well, to exercise the
new functionality. These tests can be run by:
./redstack int-tests --group=module_create
In the follow-up changeset, all module tests can be run
by:
./redstack int-tests --group=module
Since module support is available for all datastores
(controlled by a CONF option) the module test has been
added to the common modules group.
Note: Trying to do admin tasks with none admin
credentials results in an Unauthorized exception
being thrown, instead of Forbidden. This
is due to the fact that Forbidden is in the
HTTPUnauthorized section of wsgi.py instead of
the HTTPForbidden section. Moving the exception
caused too many failures, so I created a 'Module'
Forbidden exception and put it in the right section.
Change-Id: I755b0431b33b870ae02d903527f071fd8e23130d
Depends-On: I54d37025275dee4731ad49ebbd21612c4464e4c4
Depends-On: I779c24472d3d96a7b2fe4ed0284fd5869cdef93b
Partially-Implements: blueprint module-maintenance
Diffstat (limited to 'trove/db')
-rw-r--r-- | trove/db/sqlalchemy/mappers.py | 4 | ||||
-rw-r--r-- | trove/db/sqlalchemy/migrate_repo/versions/037_modules.py | 84 | ||||
-rw-r--r-- | trove/db/sqlalchemy/session.py | 2 |
3 files changed, 90 insertions, 0 deletions
diff --git a/trove/db/sqlalchemy/mappers.py b/trove/db/sqlalchemy/mappers.py index 9d379bc0..68063ba9 100644 --- a/trove/db/sqlalchemy/mappers.py +++ b/trove/db/sqlalchemy/mappers.py @@ -70,6 +70,10 @@ def map(engine, models): orm.mapper(models['datastore_configuration_parameters'], Table('datastore_configuration_parameters', meta, autoload=True)) + orm.mapper(models['modules'], + Table('modules', meta, autoload=True)) + orm.mapper(models['instance_modules'], + Table('instance_modules', meta, autoload=True)) def mapping_exists(model): diff --git a/trove/db/sqlalchemy/migrate_repo/versions/037_modules.py b/trove/db/sqlalchemy/migrate_repo/versions/037_modules.py new file mode 100644 index 00000000..b2fc3334 --- /dev/null +++ b/trove/db/sqlalchemy/migrate_repo/versions/037_modules.py @@ -0,0 +1,84 @@ +# Copyright 2016 Tesora, Inc. +# All Rights Reserved. +# +# 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. +# + +from sqlalchemy import ForeignKey +from sqlalchemy.schema import Column +from sqlalchemy.schema import MetaData +from sqlalchemy.schema import UniqueConstraint + +from trove.db.sqlalchemy.migrate_repo.schema import Boolean +from trove.db.sqlalchemy.migrate_repo.schema import create_tables +from trove.db.sqlalchemy.migrate_repo.schema import DateTime +from trove.db.sqlalchemy.migrate_repo.schema import drop_tables +from trove.db.sqlalchemy.migrate_repo.schema import String +from trove.db.sqlalchemy.migrate_repo.schema import Table +from trove.db.sqlalchemy.migrate_repo.schema import Text + + +meta = MetaData() + +modules = Table( + 'modules', + meta, + Column('id', String(length=64), primary_key=True, nullable=False), + Column('name', String(length=255), nullable=False), + Column('type', String(length=255), nullable=False), + Column('contents', Text(), nullable=False), + Column('description', String(length=255)), + Column('tenant_id', String(length=64), nullable=True), + Column('datastore_id', String(length=64), nullable=True), + Column('datastore_version_id', String(length=64), nullable=True), + Column('auto_apply', Boolean(), default=0, nullable=False), + Column('visible', Boolean(), default=1, nullable=False), + Column('live_update', Boolean(), default=0, nullable=False), + Column('md5', String(length=32), nullable=False), + Column('created', DateTime(), nullable=False), + Column('updated', DateTime(), nullable=False), + Column('deleted', Boolean(), default=0, nullable=False), + Column('deleted_at', DateTime()), + UniqueConstraint( + 'type', 'tenant_id', 'datastore_id', 'datastore_version_id', + 'name', 'deleted_at', + name='UQ_type_tenant_datastore_datastore_version_name'), +) + +instance_modules = Table( + 'instance_modules', + meta, + Column('id', String(length=64), primary_key=True, nullable=False), + Column('instance_id', String(length=64), + ForeignKey('instances.id', ondelete="CASCADE", + onupdate="CASCADE"), nullable=False), + Column('module_id', String(length=64), + ForeignKey('modules.id', ondelete="CASCADE", + onupdate="CASCADE"), nullable=False), + Column('md5', String(length=32), nullable=False), + Column('created', DateTime(), nullable=False), + Column('updated', DateTime(), nullable=False), + Column('deleted', Boolean(), default=0, nullable=False), + Column('deleted_at', DateTime()), +) + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + Table('instances', meta, autoload=True) + create_tables([modules, instance_modules]) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + drop_tables([instance_modules, modules]) diff --git a/trove/db/sqlalchemy/session.py b/trove/db/sqlalchemy/session.py index cb08a378..e6a3f8ed 100644 --- a/trove/db/sqlalchemy/session.py +++ b/trove/db/sqlalchemy/session.py @@ -48,6 +48,7 @@ def configure_db(options, models_mapper=None): from trove.extensions.security_group import models as secgrp_models from trove.guestagent import models as agent_models from trove.instance import models as base_models + from trove.module import models as module_models from trove.quota import models as quota_models model_modules = [ @@ -62,6 +63,7 @@ def configure_db(options, models_mapper=None): configurations_models, conductor_models, cluster_models, + module_models ] models = {} |