Merge "Add service_type to the instances table"
This commit is contained in:
commit
5cca5ef444
@ -0,0 +1,37 @@
|
||||
# Copyright 2012 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.
|
||||
|
||||
from sqlalchemy.schema import Column
|
||||
from sqlalchemy.schema import MetaData
|
||||
|
||||
from trove.db.sqlalchemy.migrate_repo.schema import Integer
|
||||
from trove.db.sqlalchemy.migrate_repo.schema import String
|
||||
from trove.db.sqlalchemy.migrate_repo.schema import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
instances = Table('instances', meta, autoload=True)
|
||||
service_type = Column('service_type', String(36))
|
||||
instances.create_column(service_type)
|
||||
instances.update().values({'service_type': 'mysql'}).execute()
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
# modify column:
|
||||
instances = Table('instances', meta, autoload=True)
|
||||
instances.drop_column('service_type')
|
@ -221,6 +221,10 @@ class SimpleInstance(object):
|
||||
def volume_size(self):
|
||||
return self.db_info.volume_size
|
||||
|
||||
@property
|
||||
def service_type(self):
|
||||
return self.db_info.service_type
|
||||
|
||||
|
||||
class DetailInstance(SimpleInstance):
|
||||
"""A detailed view of an Instnace.
|
||||
@ -448,6 +452,7 @@ class Instance(BuiltInstance):
|
||||
db_info = DBInstance.create(name=name, flavor_id=flavor_id,
|
||||
tenant_id=context.tenant,
|
||||
volume_size=volume_size,
|
||||
service_type=service_type,
|
||||
task_status=InstanceTasks.BUILDING)
|
||||
LOG.debug(_("Tenant %s created new Trove instance %s...")
|
||||
% (context.tenant, db_info.id))
|
||||
@ -675,7 +680,7 @@ class DBInstance(dbmodels.DatabaseModelBase):
|
||||
|
||||
_data_fields = ['name', 'created', 'compute_instance_id',
|
||||
'task_id', 'task_description', 'task_start_time',
|
||||
'volume_id', 'deleted', 'tenant_id']
|
||||
'volume_id', 'deleted', 'tenant_id', 'service_type']
|
||||
|
||||
def __init__(self, task_status, **kwargs):
|
||||
kwargs["task_id"] = task_status.code
|
||||
|
@ -50,6 +50,7 @@ class ResizeTestBase(TestCase):
|
||||
flavor_id=OLD_FLAVOR_ID,
|
||||
tenant_id=999,
|
||||
volume_size=None,
|
||||
service_type='mysql',
|
||||
task_status=InstanceTasks.RESIZING)
|
||||
self.server = self.mock.CreateMock(Server)
|
||||
self.instance = models.BuiltInstanceTasks(context,
|
||||
|
@ -50,6 +50,7 @@ class MgmtInstanceBase(object):
|
||||
flavor_id=1,
|
||||
tenant_id=self.tenant_id,
|
||||
volume_size=None,
|
||||
service_type='mysql',
|
||||
task_status=InstanceTasks.NONE)
|
||||
self.server = self.mock.CreateMock(Server)
|
||||
self.instance = imodels.Instance(self.context,
|
||||
|
Loading…
Reference in New Issue
Block a user