Improve DB method naming consistency
Some of our DB methods have names that are not consistent with the general naming we use to differentiate between methods that return a single value -_get_- and those that return a list of values -_get_all_-. This patch renames some of these methods to make them reflect whether they are returning a single entity or a list of entities. Change-Id: I3d32d65e573f71cf58c8956ef86debd4824d9f02
This commit is contained in:
parent
344f230990
commit
8d5653730c
@ -106,7 +106,7 @@ def main():
|
|||||||
'audit_period_ending': str(end),
|
'audit_period_ending': str(end),
|
||||||
}
|
}
|
||||||
|
|
||||||
volumes = objects.VolumeList.get_active_by_window(admin_context,
|
volumes = objects.VolumeList.get_all_active_by_window(admin_context,
|
||||||
begin,
|
begin,
|
||||||
end)
|
end)
|
||||||
LOG.info(_LI("Found %d volumes"), len(volumes))
|
LOG.info(_LI("Found %d volumes"), len(volumes))
|
||||||
@ -178,7 +178,7 @@ def main():
|
|||||||
LOG.exception(_LE("Delete volume notification failed: %s"),
|
LOG.exception(_LE("Delete volume notification failed: %s"),
|
||||||
exc_msg, resource=volume_ref)
|
exc_msg, resource=volume_ref)
|
||||||
|
|
||||||
snapshots = objects.SnapshotList.get_active_by_window(admin_context,
|
snapshots = objects.SnapshotList.get_all_active_by_window(admin_context,
|
||||||
begin, end)
|
begin, end)
|
||||||
LOG.info(_LI("Found %d snapshots"), len(snapshots))
|
LOG.info(_LI("Found %d snapshots"), len(snapshots))
|
||||||
for snapshot_ref in snapshots:
|
for snapshot_ref in snapshots:
|
||||||
@ -248,7 +248,7 @@ def main():
|
|||||||
LOG.exception(_LE("Delete snapshot notification failed: %s"),
|
LOG.exception(_LE("Delete snapshot notification failed: %s"),
|
||||||
exc_msg, resource=snapshot_ref)
|
exc_msg, resource=snapshot_ref)
|
||||||
|
|
||||||
backups = objects.BackupList.get_active_by_window(admin_context,
|
backups = objects.BackupList.get_all_active_by_window(admin_context,
|
||||||
begin, end)
|
begin, end)
|
||||||
|
|
||||||
LOG.info(_LI("Found %d backups"), len(backups))
|
LOG.info(_LI("Found %d backups"), len(backups))
|
||||||
|
@ -409,13 +409,13 @@ def snapshot_get_all_by_project(context, project_id, filters=None, marker=None,
|
|||||||
sort_dirs, offset)
|
sort_dirs, offset)
|
||||||
|
|
||||||
|
|
||||||
def snapshot_get_by_host(context, host, filters=None):
|
def snapshot_get_all_by_host(context, host, filters=None):
|
||||||
"""Get all snapshots belonging to a host.
|
"""Get all snapshots belonging to a host.
|
||||||
|
|
||||||
:param host: Include include snapshots only for specified host.
|
:param host: Include include snapshots only for specified host.
|
||||||
:param filters: Filters for the query in the form of key/value.
|
:param filters: Filters for the query in the form of key/value.
|
||||||
"""
|
"""
|
||||||
return IMPL.snapshot_get_by_host(context, host, filters)
|
return IMPL.snapshot_get_all_by_host(context, host, filters)
|
||||||
|
|
||||||
|
|
||||||
def snapshot_get_all_for_cgsnapshot(context, project_id):
|
def snapshot_get_all_for_cgsnapshot(context, project_id):
|
||||||
@ -449,12 +449,14 @@ def snapshot_data_get_for_project(context, project_id, volume_type_id=None):
|
|||||||
volume_type_id)
|
volume_type_id)
|
||||||
|
|
||||||
|
|
||||||
def snapshot_get_active_by_window(context, begin, end=None, project_id=None):
|
def snapshot_get_all_active_by_window(context, begin, end=None,
|
||||||
|
project_id=None):
|
||||||
"""Get all the snapshots inside the window.
|
"""Get all the snapshots inside the window.
|
||||||
|
|
||||||
Specifying a project_id will filter for a certain project.
|
Specifying a project_id will filter for a certain project.
|
||||||
"""
|
"""
|
||||||
return IMPL.snapshot_get_active_by_window(context, begin, end, project_id)
|
return IMPL.snapshot_get_all_active_by_window(context, begin, end,
|
||||||
|
project_id)
|
||||||
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
@ -619,12 +621,13 @@ def volume_type_destroy(context, id):
|
|||||||
return IMPL.volume_type_destroy(context, id)
|
return IMPL.volume_type_destroy(context, id)
|
||||||
|
|
||||||
|
|
||||||
def volume_get_active_by_window(context, begin, end=None, project_id=None):
|
def volume_get_all_active_by_window(context, begin, end=None, project_id=None):
|
||||||
"""Get all the volumes inside the window.
|
"""Get all the volumes inside the window.
|
||||||
|
|
||||||
Specifying a project_id will filter for a certain project.
|
Specifying a project_id will filter for a certain project.
|
||||||
"""
|
"""
|
||||||
return IMPL.volume_get_active_by_window(context, begin, end, project_id)
|
return IMPL.volume_get_all_active_by_window(context, begin, end,
|
||||||
|
project_id)
|
||||||
|
|
||||||
|
|
||||||
def volume_type_access_get_all(context, type_id):
|
def volume_type_access_get_all(context, type_id):
|
||||||
@ -1029,9 +1032,9 @@ def quota_class_get(context, class_name, resource):
|
|||||||
return IMPL.quota_class_get(context, class_name, resource)
|
return IMPL.quota_class_get(context, class_name, resource)
|
||||||
|
|
||||||
|
|
||||||
def quota_class_get_default(context):
|
def quota_class_get_defaults(context):
|
||||||
"""Retrieve all default quotas."""
|
"""Retrieve all default quotas."""
|
||||||
return IMPL.quota_class_get_default(context)
|
return IMPL.quota_class_get_defaults(context)
|
||||||
|
|
||||||
|
|
||||||
def quota_class_get_all_by_name(context, class_name):
|
def quota_class_get_all_by_name(context, class_name):
|
||||||
@ -1154,12 +1157,13 @@ def backup_get_all_by_volume(context, volume_id, filters=None):
|
|||||||
filters=filters)
|
filters=filters)
|
||||||
|
|
||||||
|
|
||||||
def backup_get_active_by_window(context, begin, end=None, project_id=None):
|
def backup_get_all_active_by_window(context, begin, end=None, project_id=None):
|
||||||
"""Get all the backups inside the window.
|
"""Get all the backups inside the window.
|
||||||
|
|
||||||
Specifying a project_id will filter for a certain project.
|
Specifying a project_id will filter for a certain project.
|
||||||
"""
|
"""
|
||||||
return IMPL.backup_get_active_by_window(context, begin, end, project_id)
|
return IMPL.backup_get_all_active_by_window(context, begin, end,
|
||||||
|
project_id)
|
||||||
|
|
||||||
|
|
||||||
def backup_update(context, backup_id, values):
|
def backup_update(context, backup_id, values):
|
||||||
|
@ -795,7 +795,7 @@ def quota_allocated_get_all_by_project(context, project_id):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
def _quota_get_by_resource(context, resource, session=None):
|
def _quota_get_all_by_resource(context, resource, session=None):
|
||||||
rows = model_query(context, models.Quota,
|
rows = model_query(context, models.Quota,
|
||||||
session=session,
|
session=session,
|
||||||
read_deleted='no').filter_by(
|
read_deleted='no').filter_by(
|
||||||
@ -831,7 +831,7 @@ def quota_update(context, project_id, resource, limit):
|
|||||||
def quota_update_resource(context, old_res, new_res):
|
def quota_update_resource(context, old_res, new_res):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
quotas = _quota_get_by_resource(context, old_res, session=session)
|
quotas = _quota_get_all_by_resource(context, old_res, session=session)
|
||||||
for quota in quotas:
|
for quota in quotas:
|
||||||
quota.resource = new_res
|
quota.resource = new_res
|
||||||
|
|
||||||
@ -875,7 +875,7 @@ def quota_class_get(context, class_name, resource):
|
|||||||
return _quota_class_get(context, class_name, resource)
|
return _quota_class_get(context, class_name, resource)
|
||||||
|
|
||||||
|
|
||||||
def quota_class_get_default(context):
|
def quota_class_get_defaults(context):
|
||||||
rows = model_query(context, models.QuotaClass,
|
rows = model_query(context, models.QuotaClass,
|
||||||
read_deleted="no").\
|
read_deleted="no").\
|
||||||
filter_by(class_name=_DEFAULT_QUOTA_NAME).all()
|
filter_by(class_name=_DEFAULT_QUOTA_NAME).all()
|
||||||
@ -2693,7 +2693,7 @@ def snapshot_get_all_for_volume(context, volume_id):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
def snapshot_get_by_host(context, host, filters=None):
|
def snapshot_get_all_by_host(context, host, filters=None):
|
||||||
if filters and not is_valid_model_filters(models.Snapshot, filters):
|
if filters and not is_valid_model_filters(models.Snapshot, filters):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -2812,7 +2812,8 @@ def snapshot_data_get_for_project(context, project_id, volume_type_id=None):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
def snapshot_get_active_by_window(context, begin, end=None, project_id=None):
|
def snapshot_get_all_active_by_window(context, begin, end=None,
|
||||||
|
project_id=None):
|
||||||
"""Return snapshots that were active during window."""
|
"""Return snapshots that were active during window."""
|
||||||
|
|
||||||
query = model_query(context, models.Snapshot, read_deleted="yes")
|
query = model_query(context, models.Snapshot, read_deleted="yes")
|
||||||
@ -3697,7 +3698,7 @@ def group_type_destroy(context, id):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
def volume_get_active_by_window(context,
|
def volume_get_all_active_by_window(context,
|
||||||
begin,
|
begin,
|
||||||
end=None,
|
end=None,
|
||||||
project_id=None):
|
project_id=None):
|
||||||
@ -4005,7 +4006,7 @@ def qos_specs_create(context, values):
|
|||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
try:
|
try:
|
||||||
_qos_specs_get_by_name(context, values['name'], session)
|
_qos_specs_get_all_by_name(context, values['name'], session)
|
||||||
raise exception.QoSSpecsExists(specs_id=values['name'])
|
raise exception.QoSSpecsExists(specs_id=values['name'])
|
||||||
except exception.QoSSpecsNotFound:
|
except exception.QoSSpecsNotFound:
|
||||||
pass
|
pass
|
||||||
@ -4049,7 +4050,7 @@ def qos_specs_create(context, values):
|
|||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def _qos_specs_get_by_name(context, name, session=None, inactive=False):
|
def _qos_specs_get_all_by_name(context, name, session=None, inactive=False):
|
||||||
read_deleted = 'yes' if inactive else 'no'
|
read_deleted = 'yes' if inactive else 'no'
|
||||||
results = model_query(context, models.QualityOfServiceSpecs,
|
results = model_query(context, models.QualityOfServiceSpecs,
|
||||||
read_deleted=read_deleted, session=session). \
|
read_deleted=read_deleted, session=session). \
|
||||||
@ -4064,7 +4065,8 @@ def _qos_specs_get_by_name(context, name, session=None, inactive=False):
|
|||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def _qos_specs_get_ref(context, qos_specs_id, session=None, inactive=False):
|
def _qos_specs_get_all_ref(context, qos_specs_id, session=None,
|
||||||
|
inactive=False):
|
||||||
read_deleted = 'yes' if inactive else 'no'
|
read_deleted = 'yes' if inactive else 'no'
|
||||||
result = model_query(context, models.QualityOfServiceSpecs,
|
result = model_query(context, models.QualityOfServiceSpecs,
|
||||||
read_deleted=read_deleted, session=session). \
|
read_deleted=read_deleted, session=session). \
|
||||||
@ -4110,7 +4112,8 @@ def _dict_with_qos_specs(rows):
|
|||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def qos_specs_get(context, qos_specs_id, inactive=False):
|
def qos_specs_get(context, qos_specs_id, inactive=False):
|
||||||
rows = _qos_specs_get_ref(context, qos_specs_id, None, inactive)
|
rows = _qos_specs_get_all_ref(context, qos_specs_id, None, inactive)
|
||||||
|
|
||||||
return _dict_with_qos_specs(rows)[0]
|
return _dict_with_qos_specs(rows)[0]
|
||||||
|
|
||||||
|
|
||||||
@ -4188,7 +4191,7 @@ def _qos_specs_get(context, qos_spec_id, session=None):
|
|||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def qos_specs_get_by_name(context, name, inactive=False):
|
def qos_specs_get_by_name(context, name, inactive=False):
|
||||||
rows = _qos_specs_get_by_name(context, name, None, inactive)
|
rows = _qos_specs_get_all_by_name(context, name, None, inactive)
|
||||||
|
|
||||||
return _dict_with_qos_specs(rows)[0]
|
return _dict_with_qos_specs(rows)[0]
|
||||||
|
|
||||||
@ -4247,7 +4250,7 @@ def qos_specs_item_delete(context, qos_specs_id, key):
|
|||||||
def qos_specs_delete(context, qos_specs_id):
|
def qos_specs_delete(context, qos_specs_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
_qos_specs_get_ref(context, qos_specs_id, session)
|
_qos_specs_get_all_ref(context, qos_specs_id, session)
|
||||||
updated_values = {'deleted': True,
|
updated_values = {'deleted': True,
|
||||||
'deleted_at': timeutils.utcnow(),
|
'deleted_at': timeutils.utcnow(),
|
||||||
'updated_at': literal_column('updated_at')}
|
'updated_at': literal_column('updated_at')}
|
||||||
@ -4287,7 +4290,7 @@ def qos_specs_update(context, qos_specs_id, updates):
|
|||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
# make sure qos specs exists
|
# make sure qos specs exists
|
||||||
_qos_specs_get_ref(context, qos_specs_id, session)
|
_qos_specs_get_all_ref(context, qos_specs_id, session)
|
||||||
specs = updates.get('specs', {})
|
specs = updates.get('specs', {})
|
||||||
|
|
||||||
if 'consumer' in updates:
|
if 'consumer' in updates:
|
||||||
@ -4729,7 +4732,7 @@ def backup_get_all_by_volume(context, volume_id, filters=None):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
def backup_get_active_by_window(context, begin, end=None, project_id=None):
|
def backup_get_all_active_by_window(context, begin, end=None, project_id=None):
|
||||||
"""Return backups that were active during window."""
|
"""Return backups that were active during window."""
|
||||||
|
|
||||||
query = model_query(context, models.Backup, read_deleted="yes")
|
query = model_query(context, models.Backup, read_deleted="yes")
|
||||||
|
@ -192,8 +192,8 @@ class BackupList(base.ObjectListBase, base.CinderObject):
|
|||||||
backups)
|
backups)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_active_by_window(cls, context, begin, end):
|
def get_all_active_by_window(cls, context, begin, end):
|
||||||
backups = db.backup_get_active_by_window(context, begin, end)
|
backups = db.backup_get_all_active_by_window(context, begin, end)
|
||||||
return base.obj_make_list(context, cls(context), objects.Backup,
|
return base.obj_make_list(context, cls(context), objects.Backup,
|
||||||
backups)
|
backups)
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ class SnapshotList(base.ObjectListBase, base.CinderObject):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_by_host(cls, context, host, filters=None):
|
def get_by_host(cls, context, host, filters=None):
|
||||||
snapshots = db.snapshot_get_by_host(context, host, filters)
|
snapshots = db.snapshot_get_all_by_host(context, host, filters)
|
||||||
expected_attrs = Snapshot._get_expected_attrs(context)
|
expected_attrs = Snapshot._get_expected_attrs(context)
|
||||||
return base.obj_make_list(context, cls(context), objects.Snapshot,
|
return base.obj_make_list(context, cls(context), objects.Snapshot,
|
||||||
snapshots, expected_attrs=expected_attrs)
|
snapshots, expected_attrs=expected_attrs)
|
||||||
@ -307,8 +307,8 @@ class SnapshotList(base.ObjectListBase, base.CinderObject):
|
|||||||
snapshots, expected_attrs=expected_attrs)
|
snapshots, expected_attrs=expected_attrs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_active_by_window(cls, context, begin, end):
|
def get_all_active_by_window(cls, context, begin, end):
|
||||||
snapshots = db.snapshot_get_active_by_window(context, begin, end)
|
snapshots = db.snapshot_get_all_active_by_window(context, begin, end)
|
||||||
expected_attrs = Snapshot._get_expected_attrs(context)
|
expected_attrs = Snapshot._get_expected_attrs(context)
|
||||||
return base.obj_make_list(context, cls(context), objects.Snapshot,
|
return base.obj_make_list(context, cls(context), objects.Snapshot,
|
||||||
snapshots, expected_attrs=expected_attrs)
|
snapshots, expected_attrs=expected_attrs)
|
||||||
|
@ -635,8 +635,8 @@ class VolumeList(base.ObjectListBase, base.CinderObject):
|
|||||||
return volumes
|
return volumes
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_active_by_window(cls, context, begin, end):
|
def get_all_active_by_window(cls, context, begin, end):
|
||||||
volumes = db.volume_get_active_by_window(context, begin, end)
|
volumes = db.volume_get_all_active_by_window(context, begin, end)
|
||||||
expected_attrs = cls._get_expected_attrs(context)
|
expected_attrs = cls._get_expected_attrs(context)
|
||||||
return base.obj_make_list(context, cls(context), objects.Volume,
|
return base.obj_make_list(context, cls(context), objects.Volume,
|
||||||
volumes, expected_attrs=expected_attrs)
|
volumes, expected_attrs=expected_attrs)
|
||||||
|
@ -103,7 +103,7 @@ class DbQuotaDriver(object):
|
|||||||
|
|
||||||
def get_default(self, context, resource, project_id):
|
def get_default(self, context, resource, project_id):
|
||||||
"""Get a specific default quota for a resource."""
|
"""Get a specific default quota for a resource."""
|
||||||
default_quotas = db.quota_class_get_default(context)
|
default_quotas = db.quota_class_get_defaults(context)
|
||||||
return default_quotas.get(resource.name, resource.default)
|
return default_quotas.get(resource.name, resource.default)
|
||||||
|
|
||||||
def get_defaults(self, context, resources, project_id=None):
|
def get_defaults(self, context, resources, project_id=None):
|
||||||
@ -120,7 +120,7 @@ class DbQuotaDriver(object):
|
|||||||
quotas = {}
|
quotas = {}
|
||||||
default_quotas = {}
|
default_quotas = {}
|
||||||
if CONF.use_default_quota_class:
|
if CONF.use_default_quota_class:
|
||||||
default_quotas = db.quota_class_get_default(context)
|
default_quotas = db.quota_class_get_defaults(context)
|
||||||
|
|
||||||
for resource in resources.values():
|
for resource in resources.values():
|
||||||
if default_quotas:
|
if default_quotas:
|
||||||
@ -152,7 +152,7 @@ class DbQuotaDriver(object):
|
|||||||
default_quotas = {}
|
default_quotas = {}
|
||||||
class_quotas = db.quota_class_get_all_by_name(context, quota_class)
|
class_quotas = db.quota_class_get_all_by_name(context, quota_class)
|
||||||
if defaults:
|
if defaults:
|
||||||
default_quotas = db.quota_class_get_default(context)
|
default_quotas = db.quota_class_get_defaults(context)
|
||||||
for resource in resources.values():
|
for resource in resources.values():
|
||||||
if resource.name in class_quotas:
|
if resource.name in class_quotas:
|
||||||
quotas[resource.name] = class_quotas[resource.name]
|
quotas[resource.name] = class_quotas[resource.name]
|
||||||
|
@ -226,7 +226,7 @@ class TestSnapshotList(test_objects.BaseObjectsTestCase):
|
|||||||
None, None, None, None, None)
|
None, None, None, None, None)
|
||||||
|
|
||||||
@mock.patch('cinder.objects.Volume.get_by_id')
|
@mock.patch('cinder.objects.Volume.get_by_id')
|
||||||
@mock.patch('cinder.db.snapshot_get_by_host',
|
@mock.patch('cinder.db.snapshot_get_all_by_host',
|
||||||
return_value=[fake_db_snapshot])
|
return_value=[fake_db_snapshot])
|
||||||
def test_get_by_host(self, get_by_host, volume_get_by_id):
|
def test_get_by_host(self, get_by_host, volume_get_by_id):
|
||||||
fake_volume_obj = fake_volume.fake_volume_obj(self.context)
|
fake_volume_obj = fake_volume.fake_volume_obj(self.context)
|
||||||
@ -267,14 +267,14 @@ class TestSnapshotList(test_objects.BaseObjectsTestCase):
|
|||||||
TestSnapshot._compare(self, fake_snapshot_obj, snapshots[0])
|
TestSnapshot._compare(self, fake_snapshot_obj, snapshots[0])
|
||||||
|
|
||||||
@mock.patch('cinder.objects.volume.Volume.get_by_id')
|
@mock.patch('cinder.objects.volume.Volume.get_by_id')
|
||||||
@mock.patch('cinder.db.snapshot_get_active_by_window',
|
@mock.patch('cinder.db.snapshot_get_all_active_by_window',
|
||||||
return_value=[fake_db_snapshot])
|
return_value=[fake_db_snapshot])
|
||||||
def test_get_active_by_window(self, get_active_by_window,
|
def test_get_all_active_by_window(self, get_all_active_by_window,
|
||||||
volume_get_by_id):
|
volume_get_by_id):
|
||||||
fake_volume_obj = fake_volume.fake_volume_obj(self.context)
|
fake_volume_obj = fake_volume.fake_volume_obj(self.context)
|
||||||
volume_get_by_id.return_value = fake_volume_obj
|
volume_get_by_id.return_value = fake_volume_obj
|
||||||
|
|
||||||
snapshots = objects.SnapshotList.get_active_by_window(
|
snapshots = objects.SnapshotList.get_all_active_by_window(
|
||||||
self.context, mock.sentinel.begin, mock.sentinel.end)
|
self.context, mock.sentinel.begin, mock.sentinel.end)
|
||||||
self.assertEqual(1, len(snapshots))
|
self.assertEqual(1, len(snapshots))
|
||||||
TestSnapshot._compare(self, fake_snapshot_obj, snapshots[0])
|
TestSnapshot._compare(self, fake_snapshot_obj, snapshots[0])
|
||||||
|
@ -1565,7 +1565,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
last_completed_audit_period.assert_called_once_with()
|
last_completed_audit_period.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
||||||
@mock.patch('cinder.objects.volume.VolumeList.get_active_by_window')
|
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.utils.last_completed_audit_period')
|
@mock.patch('cinder.utils.last_completed_audit_period')
|
||||||
@mock.patch('cinder.rpc.init')
|
@mock.patch('cinder.rpc.init')
|
||||||
@mock.patch('cinder.version.version_string')
|
@mock.patch('cinder.version.version_string')
|
||||||
@ -1576,7 +1576,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
get_logger, version_string,
|
get_logger, version_string,
|
||||||
rpc_init,
|
rpc_init,
|
||||||
last_completed_audit_period,
|
last_completed_audit_period,
|
||||||
volume_get_active_by_window,
|
volume_get_all_active_by_window,
|
||||||
notify_about_volume_usage):
|
notify_about_volume_usage):
|
||||||
CONF.set_override('send_actions', True)
|
CONF.set_override('send_actions', True)
|
||||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||||
@ -1593,7 +1593,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
||||||
created_at=volume1_created,
|
created_at=volume1_created,
|
||||||
deleted_at=volume1_deleted)
|
deleted_at=volume1_deleted)
|
||||||
volume_get_active_by_window.return_value = [volume1]
|
volume_get_all_active_by_window.return_value = [volume1]
|
||||||
extra_info = {
|
extra_info = {
|
||||||
'audit_period_beginning': str(begin),
|
'audit_period_beginning': str(begin),
|
||||||
'audit_period_ending': str(end),
|
'audit_period_ending': str(end),
|
||||||
@ -1620,7 +1620,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
get_logger.assert_called_once_with('cinder')
|
get_logger.assert_called_once_with('cinder')
|
||||||
rpc_init.assert_called_once_with(CONF)
|
rpc_init.assert_called_once_with(CONF)
|
||||||
last_completed_audit_period.assert_called_once_with()
|
last_completed_audit_period.assert_called_once_with()
|
||||||
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
|
volume_get_all_active_by_window.assert_called_once_with(ctxt, begin,
|
||||||
|
end)
|
||||||
notify_about_volume_usage.assert_has_calls([
|
notify_about_volume_usage.assert_has_calls([
|
||||||
mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
|
mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
|
||||||
mock.call(ctxt, volume1, 'create.start',
|
mock.call(ctxt, volume1, 'create.start',
|
||||||
@ -1630,7 +1631,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
||||||
@mock.patch('cinder.objects.volume.VolumeList.get_active_by_window')
|
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.utils.last_completed_audit_period')
|
@mock.patch('cinder.utils.last_completed_audit_period')
|
||||||
@mock.patch('cinder.rpc.init')
|
@mock.patch('cinder.rpc.init')
|
||||||
@mock.patch('cinder.version.version_string')
|
@mock.patch('cinder.version.version_string')
|
||||||
@ -1641,7 +1642,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
get_logger, version_string,
|
get_logger, version_string,
|
||||||
rpc_init,
|
rpc_init,
|
||||||
last_completed_audit_period,
|
last_completed_audit_period,
|
||||||
volume_get_active_by_window,
|
volume_get_all_active_by_window,
|
||||||
notify_about_volume_usage):
|
notify_about_volume_usage):
|
||||||
CONF.set_override('send_actions', True)
|
CONF.set_override('send_actions', True)
|
||||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||||
@ -1658,7 +1659,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
||||||
created_at=volume1_created,
|
created_at=volume1_created,
|
||||||
deleted_at=volume1_deleted)
|
deleted_at=volume1_deleted)
|
||||||
volume_get_active_by_window.return_value = [volume1]
|
volume_get_all_active_by_window.return_value = [volume1]
|
||||||
extra_info = {
|
extra_info = {
|
||||||
'audit_period_beginning': str(begin),
|
'audit_period_beginning': str(begin),
|
||||||
'audit_period_ending': str(end),
|
'audit_period_ending': str(end),
|
||||||
@ -1689,7 +1690,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
get_logger.assert_called_once_with('cinder')
|
get_logger.assert_called_once_with('cinder')
|
||||||
rpc_init.assert_called_once_with(CONF)
|
rpc_init.assert_called_once_with(CONF)
|
||||||
last_completed_audit_period.assert_called_once_with()
|
last_completed_audit_period.assert_called_once_with()
|
||||||
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
|
volume_get_all_active_by_window.assert_called_once_with(ctxt, begin,
|
||||||
|
end)
|
||||||
notify_about_volume_usage.assert_has_calls([
|
notify_about_volume_usage.assert_has_calls([
|
||||||
mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
|
mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
|
||||||
mock.call(ctxt, volume1, 'create.start',
|
mock.call(ctxt, volume1, 'create.start',
|
||||||
@ -1703,9 +1705,10 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
|
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
|
||||||
@mock.patch('cinder.objects.snapshot.SnapshotList.get_active_by_window')
|
@mock.patch('cinder.objects.snapshot.SnapshotList.'
|
||||||
|
'get_all_active_by_window')
|
||||||
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
||||||
@mock.patch('cinder.objects.volume.VolumeList.get_active_by_window')
|
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.utils.last_completed_audit_period')
|
@mock.patch('cinder.utils.last_completed_audit_period')
|
||||||
@mock.patch('cinder.rpc.init')
|
@mock.patch('cinder.rpc.init')
|
||||||
@mock.patch('cinder.version.version_string')
|
@mock.patch('cinder.version.version_string')
|
||||||
@ -1716,9 +1719,9 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
log_setup, get_logger,
|
log_setup, get_logger,
|
||||||
version_string, rpc_init,
|
version_string, rpc_init,
|
||||||
last_completed_audit_period,
|
last_completed_audit_period,
|
||||||
volume_get_active_by_window,
|
volume_get_all_active_by_window,
|
||||||
notify_about_volume_usage,
|
notify_about_volume_usage,
|
||||||
snapshot_get_active_by_window,
|
snapshot_get_all_active_by_window,
|
||||||
notify_about_snapshot_usage):
|
notify_about_snapshot_usage):
|
||||||
CONF.set_override('send_actions', True)
|
CONF.set_override('send_actions', True)
|
||||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||||
@ -1736,8 +1739,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
project_id=fake.PROJECT_ID,
|
project_id=fake.PROJECT_ID,
|
||||||
created_at=snapshot1_created,
|
created_at=snapshot1_created,
|
||||||
deleted_at=snapshot1_deleted)
|
deleted_at=snapshot1_deleted)
|
||||||
volume_get_active_by_window.return_value = []
|
volume_get_all_active_by_window.return_value = []
|
||||||
snapshot_get_active_by_window.return_value = [snapshot1]
|
snapshot_get_all_active_by_window.return_value = [snapshot1]
|
||||||
extra_info = {
|
extra_info = {
|
||||||
'audit_period_beginning': str(begin),
|
'audit_period_beginning': str(begin),
|
||||||
'audit_period_ending': str(end),
|
'audit_period_ending': str(end),
|
||||||
@ -1767,7 +1770,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
get_logger.assert_called_once_with('cinder')
|
get_logger.assert_called_once_with('cinder')
|
||||||
rpc_init.assert_called_once_with(CONF)
|
rpc_init.assert_called_once_with(CONF)
|
||||||
last_completed_audit_period.assert_called_once_with()
|
last_completed_audit_period.assert_called_once_with()
|
||||||
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
|
volume_get_all_active_by_window.assert_called_once_with(ctxt, begin,
|
||||||
|
end)
|
||||||
self.assertFalse(notify_about_volume_usage.called)
|
self.assertFalse(notify_about_volume_usage.called)
|
||||||
notify_about_snapshot_usage.assert_has_calls([
|
notify_about_snapshot_usage.assert_has_calls([
|
||||||
mock.call(ctxt, snapshot1, 'exists', extra_info),
|
mock.call(ctxt, snapshot1, 'exists', extra_info),
|
||||||
@ -1778,9 +1782,9 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
|
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
|
||||||
@mock.patch('cinder.objects.backup.BackupList.get_active_by_window')
|
@mock.patch('cinder.objects.backup.BackupList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
||||||
@mock.patch('cinder.objects.volume.VolumeList.get_active_by_window')
|
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.utils.last_completed_audit_period')
|
@mock.patch('cinder.utils.last_completed_audit_period')
|
||||||
@mock.patch('cinder.rpc.init')
|
@mock.patch('cinder.rpc.init')
|
||||||
@mock.patch('cinder.version.version_string')
|
@mock.patch('cinder.version.version_string')
|
||||||
@ -1788,9 +1792,9 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
def test_main_send_backup_error(self, get_admin_context,
|
def test_main_send_backup_error(self, get_admin_context,
|
||||||
version_string, rpc_init,
|
version_string, rpc_init,
|
||||||
last_completed_audit_period,
|
last_completed_audit_period,
|
||||||
volume_get_active_by_window,
|
volume_get_all_active_by_window,
|
||||||
notify_about_volume_usage,
|
notify_about_volume_usage,
|
||||||
backup_get_active_by_window,
|
backup_get_all_active_by_window,
|
||||||
notify_about_backup_usage):
|
notify_about_backup_usage):
|
||||||
CONF.set_override('send_actions', True)
|
CONF.set_override('send_actions', True)
|
||||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||||
@ -1808,8 +1812,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
project_id=fake.PROJECT_ID,
|
project_id=fake.PROJECT_ID,
|
||||||
created_at=backup1_created,
|
created_at=backup1_created,
|
||||||
deleted_at=backup1_deleted)
|
deleted_at=backup1_deleted)
|
||||||
volume_get_active_by_window.return_value = []
|
volume_get_all_active_by_window.return_value = []
|
||||||
backup_get_active_by_window.return_value = [backup1]
|
backup_get_all_active_by_window.return_value = [backup1]
|
||||||
extra_info = {
|
extra_info = {
|
||||||
'audit_period_beginning': str(begin),
|
'audit_period_beginning': str(begin),
|
||||||
'audit_period_ending': str(end),
|
'audit_period_ending': str(end),
|
||||||
@ -1832,7 +1836,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
self.assertEqual(CONF.version, version.version_string())
|
self.assertEqual(CONF.version, version.version_string())
|
||||||
rpc_init.assert_called_once_with(CONF)
|
rpc_init.assert_called_once_with(CONF)
|
||||||
last_completed_audit_period.assert_called_once_with()
|
last_completed_audit_period.assert_called_once_with()
|
||||||
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
|
volume_get_all_active_by_window.assert_called_once_with(ctxt,
|
||||||
|
begin, end)
|
||||||
self.assertFalse(notify_about_volume_usage.called)
|
self.assertFalse(notify_about_volume_usage.called)
|
||||||
notify_about_backup_usage.assert_any_call(ctxt, backup1, 'exists',
|
notify_about_backup_usage.assert_any_call(ctxt, backup1, 'exists',
|
||||||
extra_info)
|
extra_info)
|
||||||
@ -1844,11 +1849,12 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
extra_usage_info=local_extra_info_delete)
|
extra_usage_info=local_extra_info_delete)
|
||||||
|
|
||||||
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
|
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
|
||||||
@mock.patch('cinder.objects.backup.BackupList.get_active_by_window')
|
@mock.patch('cinder.objects.backup.BackupList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
|
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
|
||||||
@mock.patch('cinder.objects.snapshot.SnapshotList.get_active_by_window')
|
@mock.patch('cinder.objects.snapshot.SnapshotList.'
|
||||||
|
'get_all_active_by_window')
|
||||||
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
||||||
@mock.patch('cinder.objects.volume.VolumeList.get_active_by_window')
|
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
|
||||||
@mock.patch('cinder.utils.last_completed_audit_period')
|
@mock.patch('cinder.utils.last_completed_audit_period')
|
||||||
@mock.patch('cinder.rpc.init')
|
@mock.patch('cinder.rpc.init')
|
||||||
@mock.patch('cinder.version.version_string')
|
@mock.patch('cinder.version.version_string')
|
||||||
@ -1857,9 +1863,10 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
@mock.patch('cinder.context.get_admin_context')
|
@mock.patch('cinder.context.get_admin_context')
|
||||||
def test_main(self, get_admin_context, log_setup, get_logger,
|
def test_main(self, get_admin_context, log_setup, get_logger,
|
||||||
version_string, rpc_init, last_completed_audit_period,
|
version_string, rpc_init, last_completed_audit_period,
|
||||||
volume_get_active_by_window, notify_about_volume_usage,
|
volume_get_all_active_by_window, notify_about_volume_usage,
|
||||||
snapshot_get_active_by_window, notify_about_snapshot_usage,
|
snapshot_get_all_active_by_window,
|
||||||
backup_get_active_by_window, notify_about_backup_usage):
|
notify_about_snapshot_usage, backup_get_all_active_by_window,
|
||||||
|
notify_about_backup_usage):
|
||||||
CONF.set_override('send_actions', True)
|
CONF.set_override('send_actions', True)
|
||||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||||
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
||||||
@ -1876,7 +1883,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
||||||
created_at=volume1_created,
|
created_at=volume1_created,
|
||||||
deleted_at=volume1_deleted)
|
deleted_at=volume1_deleted)
|
||||||
volume_get_active_by_window.return_value = [volume1]
|
volume_get_all_active_by_window.return_value = [volume1]
|
||||||
extra_info = {
|
extra_info = {
|
||||||
'audit_period_beginning': str(begin),
|
'audit_period_beginning': str(begin),
|
||||||
'audit_period_ending': str(end),
|
'audit_period_ending': str(end),
|
||||||
@ -1898,7 +1905,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
project_id=fake.PROJECT_ID,
|
project_id=fake.PROJECT_ID,
|
||||||
created_at=snapshot1_created,
|
created_at=snapshot1_created,
|
||||||
deleted_at=snapshot1_deleted)
|
deleted_at=snapshot1_deleted)
|
||||||
snapshot_get_active_by_window.return_value = [snapshot1]
|
snapshot_get_all_active_by_window.return_value = [snapshot1]
|
||||||
extra_info_snapshot_create = {
|
extra_info_snapshot_create = {
|
||||||
'audit_period_beginning': str(snapshot1.created_at),
|
'audit_period_beginning': str(snapshot1.created_at),
|
||||||
'audit_period_ending': str(snapshot1.created_at),
|
'audit_period_ending': str(snapshot1.created_at),
|
||||||
@ -1916,7 +1923,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
project_id=fake.PROJECT_ID,
|
project_id=fake.PROJECT_ID,
|
||||||
created_at=backup1_created,
|
created_at=backup1_created,
|
||||||
deleted_at=backup1_deleted)
|
deleted_at=backup1_deleted)
|
||||||
backup_get_active_by_window.return_value = [backup1]
|
backup_get_all_active_by_window.return_value = [backup1]
|
||||||
extra_info_backup_create = {
|
extra_info_backup_create = {
|
||||||
'audit_period_beginning': str(backup1.created_at),
|
'audit_period_beginning': str(backup1.created_at),
|
||||||
'audit_period_ending': str(backup1.created_at),
|
'audit_period_ending': str(backup1.created_at),
|
||||||
@ -1935,7 +1942,8 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||||||
get_logger.assert_called_once_with('cinder')
|
get_logger.assert_called_once_with('cinder')
|
||||||
rpc_init.assert_called_once_with(CONF)
|
rpc_init.assert_called_once_with(CONF)
|
||||||
last_completed_audit_period.assert_called_once_with()
|
last_completed_audit_period.assert_called_once_with()
|
||||||
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
|
volume_get_all_active_by_window.assert_called_once_with(ctxt,
|
||||||
|
begin, end)
|
||||||
notify_about_volume_usage.assert_has_calls([
|
notify_about_volume_usage.assert_has_calls([
|
||||||
mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
|
mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
|
||||||
mock.call(ctxt, volume1, 'create.start',
|
mock.call(ctxt, volume1, 'create.start',
|
||||||
|
@ -1497,7 +1497,7 @@ class DBAPISnapshotTestCase(BaseTest):
|
|||||||
self.assertSetEqual({s.id for s in snapshots[:i + 1]},
|
self.assertSetEqual({s.id for s in snapshots[:i + 1]},
|
||||||
{s.id for s in result})
|
{s.id for s in result})
|
||||||
|
|
||||||
def test_snapshot_get_by_host(self):
|
def test_snapshot_get_all_by_host(self):
|
||||||
db.volume_create(self.ctxt, {'id': 1, 'host': 'host1'})
|
db.volume_create(self.ctxt, {'id': 1, 'host': 'host1'})
|
||||||
db.volume_create(self.ctxt, {'id': 2, 'host': 'host2'})
|
db.volume_create(self.ctxt, {'id': 2, 'host': 'host2'})
|
||||||
snapshot1 = db.snapshot_create(self.ctxt, {'id': 1, 'volume_id': 1})
|
snapshot1 = db.snapshot_create(self.ctxt, {'id': 1, 'volume_id': 1})
|
||||||
@ -1508,33 +1508,33 @@ class DBAPISnapshotTestCase(BaseTest):
|
|||||||
fields.SnapshotStatus.ERROR})
|
fields.SnapshotStatus.ERROR})
|
||||||
|
|
||||||
self._assertEqualListsOfObjects([snapshot1],
|
self._assertEqualListsOfObjects([snapshot1],
|
||||||
db.snapshot_get_by_host(
|
db.snapshot_get_all_by_host(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
'host1'),
|
'host1'),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
self._assertEqualListsOfObjects([snapshot2],
|
self._assertEqualListsOfObjects([snapshot2],
|
||||||
db.snapshot_get_by_host(
|
db.snapshot_get_all_by_host(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
'host2'),
|
'host2'),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
self._assertEqualListsOfObjects(
|
self._assertEqualListsOfObjects(
|
||||||
[], db.snapshot_get_by_host(self.ctxt, 'host2', {
|
[], db.snapshot_get_all_by_host(self.ctxt, 'host2', {
|
||||||
'status': fields.SnapshotStatus.AVAILABLE}),
|
'status': fields.SnapshotStatus.AVAILABLE}),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
self._assertEqualListsOfObjects(
|
self._assertEqualListsOfObjects(
|
||||||
[snapshot2], db.snapshot_get_by_host(self.ctxt, 'host2', {
|
[snapshot2], db.snapshot_get_all_by_host(self.ctxt, 'host2', {
|
||||||
'status': fields.SnapshotStatus.ERROR}),
|
'status': fields.SnapshotStatus.ERROR}),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
self._assertEqualListsOfObjects([],
|
self._assertEqualListsOfObjects([],
|
||||||
db.snapshot_get_by_host(
|
db.snapshot_get_all_by_host(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
'host2', {'fake_key': 'fake'}),
|
'host2', {'fake_key': 'fake'}),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
# If host is None or empty string, empty list should be returned.
|
# If host is None or empty string, empty list should be returned.
|
||||||
self.assertEqual([], db.snapshot_get_by_host(self.ctxt, None))
|
self.assertEqual([], db.snapshot_get_all_by_host(self.ctxt, None))
|
||||||
self.assertEqual([], db.snapshot_get_by_host(self.ctxt, ''))
|
self.assertEqual([], db.snapshot_get_all_by_host(self.ctxt, ''))
|
||||||
|
|
||||||
def test_snapshot_get_by_host_with_pools(self):
|
def test_snapshot_get_all_by_host_with_pools(self):
|
||||||
db.volume_create(self.ctxt, {'id': 1, 'host': 'host1#pool1'})
|
db.volume_create(self.ctxt, {'id': 1, 'host': 'host1#pool1'})
|
||||||
db.volume_create(self.ctxt, {'id': 2, 'host': 'host1#pool2'})
|
db.volume_create(self.ctxt, {'id': 2, 'host': 'host1#pool2'})
|
||||||
|
|
||||||
@ -1542,18 +1542,18 @@ class DBAPISnapshotTestCase(BaseTest):
|
|||||||
snapshot2 = db.snapshot_create(self.ctxt, {'id': 2, 'volume_id': 2})
|
snapshot2 = db.snapshot_create(self.ctxt, {'id': 2, 'volume_id': 2})
|
||||||
|
|
||||||
self._assertEqualListsOfObjects([snapshot1, snapshot2],
|
self._assertEqualListsOfObjects([snapshot1, snapshot2],
|
||||||
db.snapshot_get_by_host(
|
db.snapshot_get_all_by_host(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
'host1'),
|
'host1'),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
self._assertEqualListsOfObjects([snapshot1],
|
self._assertEqualListsOfObjects([snapshot1],
|
||||||
db.snapshot_get_by_host(
|
db.snapshot_get_all_by_host(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
'host1#pool1'),
|
'host1#pool1'),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
|
|
||||||
self._assertEqualListsOfObjects([],
|
self._assertEqualListsOfObjects([],
|
||||||
db.snapshot_get_by_host(
|
db.snapshot_get_all_by_host(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
'host1#pool0'),
|
'host1#pool0'),
|
||||||
ignored_keys='volume')
|
ignored_keys='volume')
|
||||||
|
@ -923,14 +923,14 @@ class DbQuotaDriverBaseTestCase(test.TestCase):
|
|||||||
def _mock_quota_class_get_default(self):
|
def _mock_quota_class_get_default(self):
|
||||||
# Mock quota_class_get_default
|
# Mock quota_class_get_default
|
||||||
def fake_qcgd(context):
|
def fake_qcgd(context):
|
||||||
self.calls.append('quota_class_get_default')
|
self.calls.append('quota_class_get_defaults')
|
||||||
return dict(volumes=10,
|
return dict(volumes=10,
|
||||||
snapshots=10,
|
snapshots=10,
|
||||||
gigabytes=1000,
|
gigabytes=1000,
|
||||||
backups=10,
|
backups=10,
|
||||||
backup_gigabytes=1000
|
backup_gigabytes=1000
|
||||||
)
|
)
|
||||||
self.mock_object(db, 'quota_class_get_default', fake_qcgd)
|
self.mock_object(db, 'quota_class_get_defaults', fake_qcgd)
|
||||||
|
|
||||||
def _mock_volume_type_get_all(self):
|
def _mock_volume_type_get_all(self):
|
||||||
def fake_vtga(context, inactive=False, filters=None):
|
def fake_vtga(context, inactive=False, filters=None):
|
||||||
@ -1039,7 +1039,7 @@ class DbQuotaDriverTestCase(DbQuotaDriverBaseTestCase):
|
|||||||
'quota_usage_get_all_by_project',
|
'quota_usage_get_all_by_project',
|
||||||
'quota_allocated_get_all_by_project',
|
'quota_allocated_get_all_by_project',
|
||||||
'quota_class_get_all_by_name',
|
'quota_class_get_all_by_name',
|
||||||
'quota_class_get_default', ], self.calls)
|
'quota_class_get_defaults', ], self.calls)
|
||||||
self.assertEqual(dict(volumes=dict(limit=10,
|
self.assertEqual(dict(volumes=dict(limit=10,
|
||||||
in_use=2,
|
in_use=2,
|
||||||
reserved=0, ),
|
reserved=0, ),
|
||||||
@ -1061,7 +1061,7 @@ class DbQuotaDriverTestCase(DbQuotaDriverBaseTestCase):
|
|||||||
), result)
|
), result)
|
||||||
|
|
||||||
@mock.patch('cinder.quota.db.quota_get_all_by_project')
|
@mock.patch('cinder.quota.db.quota_get_all_by_project')
|
||||||
@mock.patch('cinder.quota.db.quota_class_get_default')
|
@mock.patch('cinder.quota.db.quota_class_get_defaults')
|
||||||
def test_get_project_quotas_lazy_load_defaults(
|
def test_get_project_quotas_lazy_load_defaults(
|
||||||
self, mock_defaults, mock_quotas):
|
self, mock_defaults, mock_quotas):
|
||||||
mock_quotas.return_value = self._default_quotas_non_child
|
mock_quotas.return_value = self._default_quotas_non_child
|
||||||
@ -1089,7 +1089,7 @@ class DbQuotaDriverTestCase(DbQuotaDriverBaseTestCase):
|
|||||||
self.assertEqual(['quota_get_all_by_project',
|
self.assertEqual(['quota_get_all_by_project',
|
||||||
'quota_usage_get_all_by_project',
|
'quota_usage_get_all_by_project',
|
||||||
'quota_allocated_get_all_by_project',
|
'quota_allocated_get_all_by_project',
|
||||||
'quota_class_get_default', ], self.calls)
|
'quota_class_get_defaults', ], self.calls)
|
||||||
self.assertEqual(dict(volumes=dict(limit=10,
|
self.assertEqual(dict(volumes=dict(limit=10,
|
||||||
in_use=2,
|
in_use=2,
|
||||||
reserved=0,
|
reserved=0,
|
||||||
@ -1125,7 +1125,7 @@ class DbQuotaDriverTestCase(DbQuotaDriverBaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(['quota_get_all_by_project',
|
self.assertEqual(['quota_get_all_by_project',
|
||||||
'quota_usage_get_all_by_project',
|
'quota_usage_get_all_by_project',
|
||||||
'quota_class_get_default', ], self.calls)
|
'quota_class_get_defaults', ], self.calls)
|
||||||
self.assertEqual(dict(volumes=dict(limit=10,
|
self.assertEqual(dict(volumes=dict(limit=10,
|
||||||
in_use=2,
|
in_use=2,
|
||||||
reserved=0, ),
|
reserved=0, ),
|
||||||
@ -1156,7 +1156,7 @@ class DbQuotaDriverTestCase(DbQuotaDriverBaseTestCase):
|
|||||||
self.assertEqual(['quota_get_all_by_project',
|
self.assertEqual(['quota_get_all_by_project',
|
||||||
'quota_usage_get_all_by_project',
|
'quota_usage_get_all_by_project',
|
||||||
'quota_class_get_all_by_name',
|
'quota_class_get_all_by_name',
|
||||||
'quota_class_get_default', ], self.calls)
|
'quota_class_get_defaults', ], self.calls)
|
||||||
self.assertEqual(dict(volumes=dict(limit=10,
|
self.assertEqual(dict(volumes=dict(limit=10,
|
||||||
in_use=2,
|
in_use=2,
|
||||||
reserved=0, ),
|
reserved=0, ),
|
||||||
@ -1214,7 +1214,7 @@ class DbQuotaDriverTestCase(DbQuotaDriverBaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(['quota_get_all_by_project',
|
self.assertEqual(['quota_get_all_by_project',
|
||||||
'quota_class_get_all_by_name',
|
'quota_class_get_all_by_name',
|
||||||
'quota_class_get_default', ], self.calls)
|
'quota_class_get_defaults', ], self.calls)
|
||||||
self.assertEqual(dict(volumes=dict(limit=10, ),
|
self.assertEqual(dict(volumes=dict(limit=10, ),
|
||||||
snapshots=dict(limit=10, ),
|
snapshots=dict(limit=10, ),
|
||||||
backups=dict(limit=10, ),
|
backups=dict(limit=10, ),
|
||||||
|
@ -6060,7 +6060,7 @@ class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_volume_get_active_by_window(self):
|
def test_volume_get_all_active_by_window(self):
|
||||||
# Find all all volumes valid within a timeframe window.
|
# Find all all volumes valid within a timeframe window.
|
||||||
|
|
||||||
# Not in window
|
# Not in window
|
||||||
@ -6078,7 +6078,7 @@ class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
|
|||||||
# Not of window.
|
# Not of window.
|
||||||
db.volume_create(self.context, self.db_vol_attrs[4])
|
db.volume_create(self.context, self.db_vol_attrs[4])
|
||||||
|
|
||||||
volumes = db.volume_get_active_by_window(
|
volumes = db.volume_get_all_active_by_window(
|
||||||
self.context,
|
self.context,
|
||||||
datetime.datetime(1, 3, 1, 1, 1, 1),
|
datetime.datetime(1, 3, 1, 1, 1, 1),
|
||||||
datetime.datetime(1, 4, 1, 1, 1, 1),
|
datetime.datetime(1, 4, 1, 1, 1, 1),
|
||||||
@ -6088,7 +6088,7 @@ class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
|
|||||||
self.assertEqual(fake.VOLUME3_ID, volumes[1].id)
|
self.assertEqual(fake.VOLUME3_ID, volumes[1].id)
|
||||||
self.assertEqual(fake.VOLUME4_ID, volumes[2].id)
|
self.assertEqual(fake.VOLUME4_ID, volumes[2].id)
|
||||||
|
|
||||||
def test_snapshot_get_active_by_window(self):
|
def test_snapshot_get_all_active_by_window(self):
|
||||||
# Find all all snapshots valid within a timeframe window.
|
# Find all all snapshots valid within a timeframe window.
|
||||||
db.volume_create(self.context, {'id': fake.VOLUME_ID})
|
db.volume_create(self.context, {'id': fake.VOLUME_ID})
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
@ -6119,7 +6119,7 @@ class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
|
|||||||
snap5 = objects.Snapshot(self.ctx, **self.db_snap_attrs[4])
|
snap5 = objects.Snapshot(self.ctx, **self.db_snap_attrs[4])
|
||||||
snap5.create()
|
snap5.create()
|
||||||
|
|
||||||
snapshots = objects.SnapshotList.get_active_by_window(
|
snapshots = objects.SnapshotList.get_all_active_by_window(
|
||||||
self.context,
|
self.context,
|
||||||
datetime.datetime(1, 3, 1, 1, 1, 1),
|
datetime.datetime(1, 3, 1, 1, 1, 1),
|
||||||
datetime.datetime(1, 4, 1, 1, 1, 1)).objects
|
datetime.datetime(1, 4, 1, 1, 1, 1)).objects
|
||||||
@ -6131,7 +6131,7 @@ class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
|
|||||||
self.assertEqual(snap4.id, snapshots[2].id)
|
self.assertEqual(snap4.id, snapshots[2].id)
|
||||||
self.assertEqual(fake.VOLUME_ID, snapshots[2].volume_id)
|
self.assertEqual(fake.VOLUME_ID, snapshots[2].volume_id)
|
||||||
|
|
||||||
def test_backup_get_active_by_window(self):
|
def test_backup_get_all_active_by_window(self):
|
||||||
# Find all backups valid within a timeframe window.
|
# Find all backups valid within a timeframe window.
|
||||||
db.volume_create(self.context, {'id': fake.VOLUME_ID})
|
db.volume_create(self.context, {'id': fake.VOLUME_ID})
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
@ -6152,7 +6152,7 @@ class GetActiveByWindowTestCase(base.BaseVolumeTestCase):
|
|||||||
# Not of window
|
# Not of window
|
||||||
db.backup_create(self.ctx, self.db_back_attrs[4])
|
db.backup_create(self.ctx, self.db_back_attrs[4])
|
||||||
|
|
||||||
backups = db.backup_get_active_by_window(
|
backups = db.backup_get_all_active_by_window(
|
||||||
self.context,
|
self.context,
|
||||||
datetime.datetime(1, 3, 1, 1, 1, 1),
|
datetime.datetime(1, 3, 1, 1, 1, 1),
|
||||||
datetime.datetime(1, 4, 1, 1, 1, 1),
|
datetime.datetime(1, 4, 1, 1, 1, 1),
|
||||||
|
Loading…
Reference in New Issue
Block a user