diff options
-rw-r--r-- | trove/backup/models.py | 4 | ||||
-rw-r--r-- | trove/cluster/models.py | 3 | ||||
-rw-r--r-- | trove/configuration/models.py | 5 | ||||
-rw-r--r-- | trove/datastore/models.py | 22 | ||||
-rw-r--r-- | trove/db/sqlalchemy/mappers.py | 14 | ||||
-rw-r--r-- | trove/extensions/security_group/models.py | 21 | ||||
-rw-r--r-- | trove/instance/models.py | 18 | ||||
-rw-r--r-- | trove/module/models.py | 10 | ||||
-rw-r--r-- | trove/quota/models.py | 12 |
9 files changed, 63 insertions, 46 deletions
diff --git a/trove/backup/models.py b/trove/backup/models.py index 42d49713..06e50876 100644 --- a/trove/backup/models.py +++ b/trove/backup/models.py @@ -299,12 +299,12 @@ def persisted_models(): class DBBackup(DatabaseModelBase): """A table for Backup records.""" - _data_fields = ['id', 'name', 'description', 'location', 'backup_type', + _data_fields = ['name', 'description', 'location', 'backup_type', 'size', 'tenant_id', 'state', 'instance_id', 'checksum', 'backup_timestamp', 'deleted', 'created', 'updated', 'deleted_at', 'parent_id', 'datastore_version_id'] - preserve_on_delete = True + _table_name = 'backups' @property def is_running(self): diff --git a/trove/cluster/models.py b/trove/cluster/models.py index a79f6c04..27caacec 100644 --- a/trove/cluster/models.py +++ b/trove/cluster/models.py @@ -59,9 +59,10 @@ def persisted_models(): class DBCluster(dbmodels.DatabaseModelBase): - _data_fields = ['id', 'created', 'updated', 'name', 'task_id', + _data_fields = ['created', 'updated', 'name', 'task_id', 'tenant_id', 'datastore_version_id', 'deleted', 'deleted_at', 'configuration_id'] + _table_name = 'clusters' def __init__(self, task_status, **kwargs): """ diff --git a/trove/configuration/models.py b/trove/configuration/models.py index 599a1501..1b912ac6 100644 --- a/trove/configuration/models.py +++ b/trove/configuration/models.py @@ -228,6 +228,7 @@ class Configuration(object): class DBConfiguration(dbmodels.DatabaseModelBase): _data_fields = ['name', 'description', 'tenant_id', 'datastore_version_id', 'deleted', 'deleted_at', 'created', 'updated'] + _table_name = 'configurations' @property def datastore(self): @@ -245,9 +246,11 @@ class DBConfiguration(dbmodels.DatabaseModelBase): class DBConfigurationParameter(dbmodels.DatabaseModelBase): + _auto_generated_attrs = [] _data_fields = ['configuration_id', 'configuration_key', 'configuration_value', 'deleted', 'deleted_at'] + _table_name = 'configuration_parameters' def __hash__(self): return self.configuration_key.__hash__() @@ -255,7 +258,6 @@ class DBConfigurationParameter(dbmodels.DatabaseModelBase): class DBDatastoreConfigurationParameters(dbmodels.DatabaseModelBase): """Model for storing the configuration parameters on a datastore.""" - _auto_generated_attrs = ['id'] _data_fields = [ 'name', 'datastore_version_id', @@ -267,7 +269,6 @@ class DBDatastoreConfigurationParameters(dbmodels.DatabaseModelBase): 'deleted_at', ] _table_name = "datastore_configuration_parameters" - preserve_on_delete = True class DatastoreConfigurationParameters(object): diff --git a/trove/datastore/models.py b/trove/datastore/models.py index a50f2bef..f95fae63 100644 --- a/trove/datastore/models.py +++ b/trove/datastore/models.py @@ -35,9 +35,9 @@ db_api = get_db_api() def persisted_models(): return { - 'datastore': DBDatastore, + 'datastores': DBDatastore, 'capabilities': DBCapabilities, - 'datastore_version': DBDatastoreVersion, + 'datastore_versions': DBDatastoreVersion, 'capability_overrides': DBCapabilityOverrides, 'datastore_version_metadata': DBDatastoreVersionMetadata } @@ -45,30 +45,34 @@ def persisted_models(): class DBDatastore(dbmodels.DatabaseModelBase): - _data_fields = ['id', 'name', 'default_version_id'] + _data_fields = ['name', 'default_version_id'] + _table_name = 'datastores' class DBCapabilities(dbmodels.DatabaseModelBase): - _data_fields = ['id', 'name', 'description', 'enabled'] + _data_fields = ['name', 'description', 'enabled'] + _table_name = 'capabilities' class DBCapabilityOverrides(dbmodels.DatabaseModelBase): - _data_fields = ['id', 'capability_id', 'datastore_version_id', 'enabled'] + _data_fields = ['capability_id', 'datastore_version_id', 'enabled'] + _table_name = 'capability_overrides' class DBDatastoreVersion(dbmodels.DatabaseModelBase): - _data_fields = ['id', 'datastore_id', 'name', 'manager', 'image_id', - 'packages', 'active'] + _data_fields = ['datastore_id', 'name', 'image_id', 'packages', + 'active', 'manager'] + _table_name = 'datastore_versions' class DBDatastoreVersionMetadata(dbmodels.DatabaseModelBase): - _data_fields = ['id', 'datastore_version_id', 'key', 'value', + _data_fields = ['datastore_version_id', 'key', 'value', 'created', 'deleted', 'deleted_at', 'updated_at'] - preserve_on_delete = True + _table_name = 'datastore_version_metadata' class Capabilities(object): diff --git a/trove/db/sqlalchemy/mappers.py b/trove/db/sqlalchemy/mappers.py index ff90e262..7bb8b15f 100644 --- a/trove/db/sqlalchemy/mappers.py +++ b/trove/db/sqlalchemy/mappers.py @@ -22,17 +22,17 @@ from sqlalchemy import Table def map(engine, models): meta = MetaData() meta.bind = engine - if mapping_exists(models['instance']): + if mapping_exists(models['instances']): return - orm.mapper(models['instance'], Table('instances', meta, autoload=True)) + orm.mapper(models['instances'], Table('instances', meta, autoload=True)) orm.mapper(models['instance_faults'], Table('instance_faults', meta, autoload=True)) orm.mapper(models['root_enabled_history'], Table('root_enabled_history', meta, autoload=True)) - orm.mapper(models['datastore'], + orm.mapper(models['datastores'], Table('datastores', meta, autoload=True)) - orm.mapper(models['datastore_version'], + orm.mapper(models['datastore_versions'], Table('datastore_versions', meta, autoload=True)) orm.mapper(models['datastore_version_metadata'], Table('datastore_version_metadata', meta, autoload=True)) @@ -54,11 +54,11 @@ def map(engine, models): Table('reservations', meta, autoload=True)) orm.mapper(models['backups'], Table('backups', meta, autoload=True)) - orm.mapper(models['security_group'], + orm.mapper(models['security_groups'], Table('security_groups', meta, autoload=True)) - orm.mapper(models['security_group_rule'], + orm.mapper(models['security_group_rules'], Table('security_group_rules', meta, autoload=True)) - orm.mapper(models['security_group_instance_association'], + orm.mapper(models['security_group_instance_associations'], Table('security_group_instance_associations', meta, autoload=True)) orm.mapper(models['configurations'], diff --git a/trove/extensions/security_group/models.py b/trove/extensions/security_group/models.py index ac8c327c..17e2699c 100644 --- a/trove/extensions/security_group/models.py +++ b/trove/extensions/security_group/models.py @@ -32,16 +32,17 @@ LOG = logging.getLogger(__name__) def persisted_models(): return { - 'security_group': SecurityGroup, - 'security_group_rule': SecurityGroupRule, - 'security_group_instance_association': + 'security_groups': SecurityGroup, + 'security_group_rules': SecurityGroupRule, + 'security_group_instance_associations': SecurityGroupInstanceAssociation, } class SecurityGroup(DatabaseModelBase): - _data_fields = ['id', 'name', 'description', 'user', 'tenant_id', + _data_fields = ['name', 'description', 'user', 'tenant_id', 'created', 'updated', 'deleted', 'deleted_at'] + _table_name = 'security_groups' @property def instance_id(self): @@ -134,9 +135,10 @@ class SecurityGroup(DatabaseModelBase): class SecurityGroupRule(DatabaseModelBase): - _data_fields = ['id', 'parent_group_id', 'protocol', 'from_port', - 'to_port', 'cidr', 'group_id', 'created', 'updated', - 'deleted', 'deleted_at'] + _data_fields = ['group_id', 'parent_group_id', 'protocol', + 'from_port', 'to_port', 'cidr', 'created', + 'updated', 'deleted', 'deleted_at'] + _table_name = 'security_group_rules' @classmethod def create_sec_group_rule(cls, sec_group, protocol, from_port, @@ -185,8 +187,9 @@ class SecurityGroupRule(DatabaseModelBase): class SecurityGroupInstanceAssociation(DatabaseModelBase): - _data_fields = ['id', 'security_group_id', 'instance_id', - 'created', 'updated', 'deleted', 'deleted_at'] + _data_fields = ['security_group_id', 'instance_id', 'created', + 'updated', 'deleted', 'deleted_at'] + _table_name = 'security_group_instance_associations' def get_security_group(self): return SecurityGroup.find_by(id=self.security_group_id, diff --git a/trove/instance/models.py b/trove/instance/models.py index ebe8a411..ce07e4d4 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -1583,12 +1583,14 @@ class Instances(object): class DBInstance(dbmodels.DatabaseModelBase): - _data_fields = ['name', 'created', 'compute_instance_id', - 'task_id', 'task_description', 'task_start_time', - 'volume_id', 'deleted', 'tenant_id', - 'datastore_version_id', 'configuration_id', 'slave_of_id', - 'cluster_id', 'shard_id', 'type', 'region_id', - 'encrypted_key'] + _data_fields = ['created', 'updated', 'name', 'hostname', + 'compute_instance_id', 'task_id', 'task_description', + 'task_start_time', 'volume_id', 'flavor_id', + 'volume_size', 'tenant_id', 'server_status', + 'deleted', 'deleted_at', 'datastore_version_id', + 'configuration_id', 'slave_of_id', 'cluster_id', + 'shard_id', 'type', 'region_id', 'encrypted_key'] + _table_name = 'instances' def __init__(self, task_status, **kwargs): """ @@ -1772,6 +1774,7 @@ def save_instance_fault(instance_id, message, details, skip_delta=None): class DBInstanceFault(dbmodels.DatabaseModelBase): _data_fields = ['instance_id', 'message', 'details', 'created', 'updated', 'deleted', 'deleted_at'] + _table_name = 'instance_faults' def __init__(self, **kwargs): super(DBInstanceFault, self).__init__(**kwargs) @@ -1784,6 +1787,7 @@ class DBInstanceFault(dbmodels.DatabaseModelBase): class InstanceServiceStatus(dbmodels.DatabaseModelBase): _data_fields = ['instance_id', 'status_id', 'status_description', 'updated_at'] + _table_name = 'service_statuses' def __init__(self, status, **kwargs): kwargs["status_id"] = status.code @@ -1825,7 +1829,7 @@ class InstanceServiceStatus(dbmodels.DatabaseModelBase): def persisted_models(): return { - 'instance': DBInstance, + 'instances': DBInstance, 'instance_faults': DBInstanceFault, 'service_statuses': InstanceServiceStatus, } diff --git a/trove/module/models.py b/trove/module/models.py index b9962aa6..975ef13b 100644 --- a/trove/module/models.py +++ b/trove/module/models.py @@ -446,17 +446,19 @@ class InstanceModule(object): class DBInstanceModule(models.DatabaseModelBase): _data_fields = [ - 'id', 'instance_id', 'module_id', 'md5', 'created', + 'instance_id', 'module_id', 'md5', 'created', 'updated', 'deleted', 'deleted_at'] + _table_name = 'instance_modules' class DBModule(models.DatabaseModelBase): _data_fields = [ - 'id', 'name', 'type', 'contents', 'description', + 'name', 'type', 'contents', 'description', 'tenant_id', 'datastore_id', 'datastore_version_id', 'auto_apply', 'visible', 'live_update', - 'priority_apply', 'apply_order', 'is_admin', - 'md5', 'created', 'updated', 'deleted', 'deleted_at'] + 'md5', 'created', 'updated', 'deleted', 'deleted_at', + 'priority_apply', 'apply_order', 'is_admin'] + _table_name = 'modules' def persisted_models(): diff --git a/trove/quota/models.py b/trove/quota/models.py index 31b7542d..e2ae0979 100644 --- a/trove/quota/models.py +++ b/trove/quota/models.py @@ -29,7 +29,8 @@ class Quota(dbmodels.DatabaseModelBase): """Defines the base model class for a quota.""" _data_fields = ['created', 'updated', 'tenant_id', 'resource', - 'hard_limit', 'id'] + 'hard_limit'] + _table_name = 'quotas' def __init__(self, tenant_id, resource, hard_limit, id=utils.generate_uuid(), created=timeutils.utcnow(), @@ -45,15 +46,16 @@ class Quota(dbmodels.DatabaseModelBase): class QuotaUsage(dbmodels.DatabaseModelBase): """Defines the quota usage for a tenant.""" - _data_fields = ['created', 'updated', 'tenant_id', 'resource', - 'in_use', 'reserved', 'id'] + _data_fields = ['created', 'updated', 'tenant_id', + 'in_use', 'reserved', 'resource'] + _table_name = 'quota_usages' class Reservation(dbmodels.DatabaseModelBase): """Defines the reservation for a quota.""" - _data_fields = ['created', 'updated', 'usage_id', - 'id', 'delta', 'status'] + _data_fields = ['created', 'updated', 'usage_id', 'delta', 'status'] + _table_name = 'reservations' Statuses = enum(NEW='New', RESERVED='Reserved', |