db: Rename 'share_export_location_*' to 'export_location_*'

This better aligns with 'export_location_metadata_*' APIs. The plural
'export_locations_get*' APIs are renamed to 'export_location_get_all*'.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I14f2b834e7ac2d8be86f9d7e381706cadbb79eb8
This commit is contained in:
Stephen Finucane 2023-06-01 10:54:54 +01:00
parent 204215722e
commit 8b148ebd41
14 changed files with 144 additions and 140 deletions

View File

@ -49,7 +49,7 @@ class ShareExportLocationController(wsgi.Controller):
'ignore_migration_destination': True,
'ignore_secondary_replicas': ignore_secondary_replicas,
}
export_locations = db_api.share_export_locations_get_by_share_id(
export_locations = db_api.export_location_get_all_by_share_id(
context, share_id, **kwargs)
return self._view_builder.summary_list(req, export_locations)
@ -59,7 +59,7 @@ class ShareExportLocationController(wsgi.Controller):
context = req.environ['manila.context']
self._verify_share(context, share_id)
try:
export_location = db_api.share_export_location_get_by_uuid(
export_location = db_api.export_location_get_by_uuid(
context, export_location_uuid,
ignore_secondary_replicas=ignore_secondary_replicas)
except exception.ExportLocationNotFound:

View File

@ -49,9 +49,8 @@ class ShareInstanceExportLocationController(wsgi.Controller):
"""Return a list of export locations for the share instance."""
context = req.environ['manila.context']
self._verify_share_instance(context, share_instance_id)
export_locations = (
db_api.share_export_locations_get_by_share_instance_id(
context, share_instance_id))
export_locations = db_api.export_location_get_all_by_share_instance_id(
context, share_instance_id)
return self._view_builder.summary_list(req, export_locations)
@wsgi.Controller.api_version('2.9')
@ -61,7 +60,7 @@ class ShareInstanceExportLocationController(wsgi.Controller):
context = req.environ['manila.context']
self._verify_share_instance(context, share_instance_id)
try:
export_location = db_api.share_export_location_get_by_uuid(
export_location = db_api.export_location_get_by_uuid(
context, export_location_uuid)
return self._view_builder.detail(req, export_location)
except exception.ExportLocationNotFound as e:

View File

@ -55,11 +55,9 @@ class ShareReplicaExportLocationController(wsgi.Controller):
"""Return a list of export locations for the share instance."""
context = req.environ['manila.context']
self._verify_share_replica(context, share_replica_id)
export_locations = (
db_api.share_export_locations_get_by_share_instance_id(
context, share_replica_id,
include_admin_only=context.is_admin)
)
export_locations = db_api.export_location_get_all_by_share_instance_id(
context, share_replica_id,
include_admin_only=context.is_admin)
return self._view_builder.summary_list(req, export_locations,
replica=True)
@ -80,7 +78,7 @@ class ShareReplicaExportLocationController(wsgi.Controller):
context = req.environ['manila.context']
self._verify_share_replica(context, share_replica_id)
try:
export_location = db_api.share_export_location_get_by_uuid(
export_location = db_api.export_location_get_by_uuid(
context, export_location_uuid)
return self._view_builder.detail(req, export_location,
replica=True)

View File

@ -946,42 +946,46 @@ def share_metadata_update_item(context, share_id, item):
###################
def share_export_location_get_by_uuid(context, export_location_uuid,
ignore_secondary_replicas=False):
def export_location_get_by_uuid(
context, export_location_uuid, ignore_secondary_replicas=False,
):
"""Get specific export location of a share."""
return IMPL.share_export_location_get_by_uuid(
return IMPL.export_location_get_by_uuid(
context, export_location_uuid,
ignore_secondary_replicas=ignore_secondary_replicas)
def share_export_locations_get(context, share_id):
def export_location_get_all(context, share_id):
"""Get all export locations of a share."""
return IMPL.share_export_locations_get(context, share_id)
return IMPL.export_location_get_all(context, share_id)
def share_export_locations_get_by_share_id(context, share_id,
include_admin_only=True,
ignore_migration_destination=False,
ignore_secondary_replicas=False):
def export_location_get_all_by_share_id(
context, share_id,
include_admin_only=True,
ignore_migration_destination=False,
ignore_secondary_replicas=False,
):
"""Get all export locations of a share by its ID."""
return IMPL.share_export_locations_get_by_share_id(
return IMPL.export_location_get_all_by_share_id(
context, share_id, include_admin_only=include_admin_only,
ignore_migration_destination=ignore_migration_destination,
ignore_secondary_replicas=ignore_secondary_replicas)
def share_export_locations_get_by_share_instance_id(context,
share_instance_id,
include_admin_only=True):
def export_location_get_all_by_share_instance_id(
context, share_instance_id, include_admin_only=True,
):
"""Get all export locations of a share instance by its ID."""
return IMPL.share_export_locations_get_by_share_instance_id(
return IMPL.export_location_get_all_by_share_instance_id(
context, share_instance_id, include_admin_only=include_admin_only)
def share_export_locations_update(context, share_instance_id, export_locations,
delete=True):
def export_locations_update(
context, share_instance_id, export_locations, delete=True,
):
"""Update export locations of a share instance."""
return IMPL.share_export_locations_update(
return IMPL.export_locations_update(
context, share_instance_id, export_locations, delete)

View File

@ -1862,7 +1862,7 @@ def share_instance_delete(context, instance_id, session=None,
session = get_session()
with session.begin():
share_export_locations_update(context, instance_id, [], delete=True)
export_locations_update(context, instance_id, [], delete=True)
instance_ref = share_instance_get(context, instance_id,
session=session)
is_replica = instance_ref['replica_state'] is not None
@ -4143,9 +4143,11 @@ def _share_metadata_get_item(context, share_id, key):
# Export locations functions
############################
def _share_export_locations_get(context, share_instance_ids,
include_admin_only=True,
ignore_secondary_replicas=False, session=None):
def _export_location_get_all(
context, share_instance_ids,
include_admin_only=True,
ignore_secondary_replicas=False, session=None,
):
session = session or get_session()
if not isinstance(share_instance_ids, (set, list, tuple)):
@ -4179,17 +4181,19 @@ def _share_export_locations_get(context, share_instance_ids,
@require_context
@require_share_exists
def share_export_locations_get_by_share_id(context, share_id,
include_admin_only=True,
ignore_migration_destination=False,
ignore_secondary_replicas=False):
def export_location_get_all_by_share_id(
context, share_id,
include_admin_only=True,
ignore_migration_destination=False,
ignore_secondary_replicas=False,
):
share = share_get(context, share_id)
if ignore_migration_destination:
ids = [instance.id for instance in share.instances
if instance['status'] != constants.STATUS_MIGRATING_TO]
else:
ids = [instance.id for instance in share.instances]
rows = _share_export_locations_get(
rows = _export_location_get_all(
context, ids, include_admin_only=include_admin_only,
ignore_secondary_replicas=ignore_secondary_replicas)
return rows
@ -4197,31 +4201,32 @@ def share_export_locations_get_by_share_id(context, share_id,
@require_context
@require_share_instance_exists
def share_export_locations_get_by_share_instance_id(context,
share_instance_id,
include_admin_only=True):
rows = _share_export_locations_get(
def export_location_get_all_by_share_instance_id(
context, share_instance_id, include_admin_only=True,
):
rows = _export_location_get_all(
context, [share_instance_id], include_admin_only=include_admin_only)
return rows
@require_context
@require_share_exists
def share_export_locations_get(context, share_id):
def export_location_get_all(context, share_id):
# NOTE(vponomaryov): this method is kept for compatibility with
# old approach. New one uses 'share_export_locations_get_by_share_id'.
# old approach. New one uses 'export_location_get_all_by_share_id'.
# Which returns list of dicts instead of list of strings, as this one does.
share = share_get(context, share_id)
rows = _share_export_locations_get(
rows = _export_location_get_all(
context, share.instance.id, context.is_admin)
return [location['path'] for location in rows]
@require_context
def share_export_location_get_by_uuid(context, export_location_uuid,
ignore_secondary_replicas=False,
session=None):
def export_location_get_by_uuid(
context, export_location_uuid, ignore_secondary_replicas=False,
session=None,
):
session = session or get_session()
query = model_query(
@ -4249,8 +4254,9 @@ def share_export_location_get_by_uuid(context, export_location_uuid,
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
def share_export_locations_update(context, share_instance_id, export_locations,
delete):
def export_locations_update(
context, share_instance_id, export_locations, delete,
):
# NOTE(u_glide):
# Backward compatibility code for drivers,
# which return single export_location as string
@ -4279,7 +4285,7 @@ def share_export_locations_update(context, share_instance_id, export_locations,
session = get_session()
current_el_rows = _share_export_locations_get(
current_el_rows = _export_location_get_all(
context, share_instance_id, session=session)
def get_path_list_from_rows(rows):
@ -4334,7 +4340,7 @@ def share_export_locations_update(context, share_instance_id, export_locations,
export_location_metadata_update(
context, location_ref['uuid'], el.get('metadata'), session=session)
return get_path_list_from_rows(_share_export_locations_get(
return get_path_list_from_rows(_export_location_get_all(
context, share_instance_id, session=session))
@ -4345,7 +4351,7 @@ def share_export_locations_update(context, share_instance_id, export_locations,
def _export_location_metadata_get_query(context, export_location_uuid,
session=None):
session = session or get_session()
export_location_id = share_export_location_get_by_uuid(
export_location_id = export_location_get_by_uuid(
context, export_location_uuid).id
return model_query(
@ -4395,7 +4401,7 @@ def export_location_metadata_update(context, export_location_uuid, metadata,
export_location_metadata_delete(
context, export_location_uuid, keys=keys_for_deletion)
el = share_export_location_get_by_uuid(context, export_location_uuid)
el = export_location_get_by_uuid(context, export_location_uuid)
for meta_key, meta_value in metadata.items():
# NOTE(vponomaryov): we should use separate session
# for each meta_ref because of autoincrement of integer primary key

View File

@ -1013,8 +1013,8 @@ class API(base.Base):
share = self.db.share_create(context, share_data)
export_location_path = share_data.pop('export_location_path')
self.db.share_export_locations_update(context, share.instance['id'],
export_location_path)
self.db.export_locations_update(
context, share.instance['id'], export_location_path)
request_spec = self._get_request_spec_dict(
context, share, share_type, size=0,

View File

@ -499,7 +499,7 @@ class ShareManager(manager.SchedulerDependentManager):
share_instance_update_dict.get('export_locations')
)
if update_export_locations:
self.db.share_export_locations_update(
self.db.export_locations_update(
ctxt, share_instance['id'], update_export_locations)
share_server = self._get_share_server(ctxt, share_instance)
@ -565,7 +565,7 @@ class ShareManager(manager.SchedulerDependentManager):
"share '%(s_id)s'.",
{'s_id': share_instance['id']})
if export_locations:
self.db.share_export_locations_update(
self.db.export_locations_update(
ctxt, share_instance['id'], export_locations)
def _check_share_server_backend_limits(
@ -1647,7 +1647,7 @@ class ShareManager(manager.SchedulerDependentManager):
dest_share_server) or {}
if data_updates.get('export_locations'):
self.db.share_export_locations_update(
self.db.export_locations_update(
context, dest_share_instance['id'],
data_updates['export_locations'])
@ -2187,7 +2187,7 @@ class ShareManager(manager.SchedulerDependentManager):
raise exception.InvalidShareInstance(reason=msg)
if export_locations:
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_instance['id'], export_locations)
except Exception as e:
@ -2205,7 +2205,7 @@ class ShareManager(manager.SchedulerDependentManager):
export_locations = get_export_location(detail_data)
if export_locations:
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_instance['id'], export_locations)
else:
LOG.warning('Share instance information in exception '
@ -2414,7 +2414,7 @@ class ShareManager(manager.SchedulerDependentManager):
if replica_ref.get('export_locations'):
if isinstance(replica_ref.get('export_locations'), list):
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_replica['id'],
replica_ref.get('export_locations'))
else:
@ -2692,7 +2692,7 @@ class ShareManager(manager.SchedulerDependentManager):
'export_locations')
if(updated_export_locs is not None
and isinstance(updated_export_locs, list)):
self.db.share_export_locations_update(
self.db.export_locations_update(
context, updated_replica['id'],
updated_export_locs)
@ -2961,7 +2961,7 @@ class ShareManager(manager.SchedulerDependentManager):
# that driver has calculated to avoid incompatibilities with one
# provided by user.
if 'export_locations' in share_update:
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_instance['id'],
share_update.pop('export_locations'),
delete=True)
@ -4744,9 +4744,8 @@ class ShareManager(manager.SchedulerDependentManager):
values.pop('id')
export_locations = values.pop('export_locations')
self.db.share_instance_update(context, share['id'], values)
self.db.share_export_locations_update(context,
share['id'],
export_locations)
self.db.export_locations_update(
context, share['id'], export_locations)
except Exception:
with excutils.save_and_reraise_exception():
@ -5370,7 +5369,7 @@ class ShareManager(manager.SchedulerDependentManager):
'status': status})
LOG.debug(msg)
if export_locations:
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_instance['id'], export_locations)
def _validate_check_compatibility_result(
@ -5983,7 +5982,7 @@ class ShareManager(manager.SchedulerDependentManager):
update_export_location = (
share_updates[share_instance['id']].get('export_locations'))
if update_export_location:
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_instance['id'], update_export_location)
snapshot_updates = model_update.get('snapshot_updates', {})
@ -6466,7 +6465,7 @@ class ShareManager(manager.SchedulerDependentManager):
share_updates = model_update.get('share_updates', {})
for share_instance_id, export_locations in share_updates.items():
self.db.share_export_locations_update(
self.db.export_locations_update(
context, share_instance_id, export_locations)
snapshot_updates = model_update.get('snapshot_updates', {})

View File

@ -54,7 +54,7 @@ class ShareExportLocationsAPITest(test.TestCase):
self.share_instance_id = self.share.instance.id
self.req = self._get_request()
paths = ['fake1/1/', 'fake2/2', 'fake3/3']
db.share_export_locations_update(
db.export_locations_update(
self.ctxt['admin'], self.share_instance_id, paths, False)
@ddt.data({'role': 'admin', 'version': '2.9'},
@ -154,7 +154,7 @@ class ShareExportLocationsAPITest(test.TestCase):
'is_admin_only': True,
'metadata': {'foo': 'bar'},
}
db.share_export_locations_update(
db.export_locations_update(
self.ctxt['admin'], self.share_instance_id, el_data, True)
index_result = self.controller.index(self.req, self.share['id'])
el_id = index_result['export_locations'][0]['id']
@ -191,7 +191,7 @@ class ShareExportLocationsAPITest(test.TestCase):
{'path': 'myshare.mydomain/active-replica-exp2',
'is_admin_only': False},
]
db.share_export_locations_update(
db.export_locations_update(
self.ctxt['user'], active_replica_id, exports)
# Replicas
@ -208,9 +208,9 @@ class ShareExportLocationsAPITest(test.TestCase):
{'path': 'myshare.mydomain/outofsync-replica-exp',
'is_admin_only': False}
]
db.share_export_locations_update(
db.export_locations_update(
self.ctxt['user'], share_replica2.id, replica2_exports)
db.share_export_locations_update(
db.export_locations_update(
self.ctxt['user'], share_replica3.id, replica3_exports)
req = self._get_request(version=version)

View File

@ -52,7 +52,7 @@ class ShareInstanceExportLocationsAPITest(test.TestCase):
self.share_instance_id = self.share.instance.id
self.req = self._get_request()
paths = ['fake1/1/', 'fake2/2', 'fake3/3']
db.share_export_locations_update(
db.export_locations_update(
self.ctxt['admin'], self.share_instance_id, paths, False)
@ddt.data({'role': 'admin', 'version': '2.9'},

View File

@ -87,7 +87,7 @@ class ShareInstancesAPITest(test.TestCase):
]
test_instances = other_instances + last_instance
db.share_export_locations_update(
db.export_locations_update(
self.admin_context, test_instances[0]['id'],
'/admin/export/location', False)

View File

@ -60,7 +60,7 @@ class ShareReplicaExportLocationsAPITest(test.TestCase):
{'path': 'myshare.mydomain/active-replica-exp2',
'is_admin_only': False},
]
db.share_export_locations_update(
db.export_locations_update(
self.ctxt, self.active_replica_id, exports)
# Replicas
@ -82,9 +82,9 @@ class ShareReplicaExportLocationsAPITest(test.TestCase):
{'path': 'myshare.mydomain/outofsync-replica-exp2',
'is_admin_only': False}
]
db.share_export_locations_update(
db.export_locations_update(
self.ctxt, self.share_replica2.id, replica2_exports)
db.share_export_locations_update(
db.export_locations_update(
self.ctxt, self.share_replica3.id, replica3_exports)
@ddt.data(('user', '2.47'), ('admin', GRADUATION_VERSION))
@ -155,8 +155,8 @@ class ShareReplicaExportLocationsAPITest(test.TestCase):
{'path': 'myshare.mydomain/non-replicated-share-2',
'is_admin_only': False},
]
db.share_export_locations_update(self.ctxt, instance_id, exports)
updated_exports = db.share_export_locations_get_by_share_id(
db.export_locations_update(self.ctxt, instance_id, exports)
updated_exports = db.export_location_get_all_by_share_id(
self.ctxt, non_replicated_share.id)
self.assertRaises(exc.HTTPNotFound, self.controller.index, self.req,

View File

@ -557,13 +557,12 @@ class ShareDatabaseAPITestCase(test.TestCase):
def test_share_instance_get_all_by_export_location(self, type):
share = db_utils.create_share()
initial_location = ['fake_export_location']
db_api.share_export_locations_update(self.ctxt, share.instance['id'],
initial_location, False)
db_api.export_locations_update(
self.ctxt, share.instance['id'], initial_location, False)
if type == 'id':
export_location = (
db_api.share_export_locations_get_by_share_id(self.ctxt,
share['id']))
export_location = db_api.export_location_get_all_by_share_id(
self.ctxt, share['id'])
value = export_location[0]['uuid']
else:
value = 'fake_export_location'
@ -631,10 +630,10 @@ class ShareDatabaseAPITestCase(test.TestCase):
def test_share_get_all_by_export_location(self, type):
share = db_utils.create_share()
initial_location = ['fake_export_location']
db_api.share_export_locations_update(self.ctxt, share.instance['id'],
initial_location, False)
db_api.export_locations_update(
self.ctxt, share.instance['id'], initial_location, False)
if type == 'id':
export_location = db_api.share_export_locations_get_by_share_id(
export_location = db_api.export_location_get_all_by_share_id(
self.ctxt, share['id'])
value = export_location[0]['uuid']
else:
@ -650,8 +649,8 @@ class ShareDatabaseAPITestCase(test.TestCase):
def test_share_get_all_by_export_location_not_exist(self, type):
share = db_utils.create_share()
initial_location = ['fake_export_location']
db_api.share_export_locations_update(self.ctxt, share.instance['id'],
initial_location, False)
db_api.export_locations_update(
self.ctxt, share.instance['id'], initial_location, False)
filter = {'export_location_' + type: 'export_location_not_exist'}
actual_result = db_api.share_get_all(self.ctxt, filters=filter)
@ -2215,13 +2214,13 @@ class ShareExportLocationsDatabaseAPITestCase(test.TestCase):
update_locations = ['fake4/4', 'fake2/2', 'fake3/3']
# add initial locations
db_api.share_export_locations_update(self.ctxt, share.instance['id'],
initial_locations, False)
db_api.export_locations_update(
self.ctxt, share.instance['id'], initial_locations, False)
# update locations
db_api.share_export_locations_update(self.ctxt, share.instance['id'],
update_locations, True)
actual_result = db_api.share_export_locations_get(self.ctxt,
share['id'])
db_api.export_locations_update(
self.ctxt, share.instance['id'], update_locations, True)
actual_result = db_api.export_location_get_all(
self.ctxt, share['id'])
# actual result should contain locations in exact same order
self.assertEqual(actual_result, update_locations)
@ -2230,10 +2229,10 @@ class ShareExportLocationsDatabaseAPITestCase(test.TestCase):
share = db_utils.create_share()
initial_location = 'fake1/1/'
db_api.share_export_locations_update(self.ctxt, share.instance['id'],
initial_location, False)
actual_result = db_api.share_export_locations_get(self.ctxt,
share['id'])
db_api.export_locations_update(
self.ctxt, share.instance['id'], initial_location, False)
actual_result = db_api.export_location_get_all(
self.ctxt, share['id'])
self.assertEqual(actual_result, [initial_location])
@ -2247,13 +2246,13 @@ class ShareExportLocationsDatabaseAPITestCase(test.TestCase):
{'path': 'fake3/3/', 'is_admin_only': True},
]
db_api.share_export_locations_update(
db_api.export_locations_update(
self.ctxt, share.instance['id'], locations, delete=False)
user_result = db_api.share_export_locations_get(ctxt_user, share['id'])
user_result = db_api.export_location_get_all(ctxt_user, share['id'])
self.assertEqual([], user_result)
admin_result = db_api.share_export_locations_get(
admin_result = db_api.export_location_get_all(
self.ctxt, share['id'])
self.assertEqual(3, len(admin_result))
for location in locations:
@ -2269,15 +2268,15 @@ class ShareExportLocationsDatabaseAPITestCase(test.TestCase):
{'path': 'fake3/3/', 'is_admin_only': False},
]
db_api.share_export_locations_update(
db_api.export_locations_update(
self.ctxt, share.instance['id'], locations, delete=False)
user_result = db_api.share_export_locations_get(ctxt_user, share['id'])
user_result = db_api.export_location_get_all(ctxt_user, share['id'])
self.assertEqual(3, len(user_result))
for location in locations:
self.assertIn(location['path'], user_result)
admin_result = db_api.share_export_locations_get(
admin_result = db_api.export_location_get_all(
self.ctxt, share['id'])
self.assertEqual(3, len(admin_result))
for location in locations:
@ -2289,13 +2288,13 @@ class ShareExportLocationsDatabaseAPITestCase(test.TestCase):
share = db_utils.create_share()
locations = ['fake1/1/', 'fake2/2', 'fake3/3']
db_api.share_export_locations_update(
db_api.export_locations_update(
self.ctxt, share.instance['id'], locations, delete=False)
user_result = db_api.share_export_locations_get(ctxt_user, share['id'])
user_result = db_api.export_location_get_all(ctxt_user, share['id'])
self.assertEqual(locations, user_result)
admin_result = db_api.share_export_locations_get(
admin_result = db_api.export_location_get_all(
self.ctxt, share['id'])
self.assertEqual(locations, admin_result)
@ -2325,12 +2324,12 @@ class ShareInstanceExportLocationsMetadataDatabaseAPITestCase(test.TestCase):
self.initial_locations = ['/fake/foo/', '/fake/bar', '/fake/quuz']
self.shown_locations = ['/fake/foo/', '/fake/bar']
for i in range(0, 3):
db_api.share_export_locations_update(
db_api.export_locations_update(
self.ctxt, instances[i]['id'], self.initial_locations[i],
delete=False)
def _get_export_location_uuid_by_path(self, path):
els = db_api.share_export_locations_get_by_share_id(
els = db_api.export_location_get_all_by_share_id(
self.ctxt, self.share.id)
export_location_uuid = None
for el in els:
@ -2340,21 +2339,21 @@ class ShareInstanceExportLocationsMetadataDatabaseAPITestCase(test.TestCase):
return export_location_uuid
def test_get_export_locations_by_share_id(self):
els = db_api.share_export_locations_get_by_share_id(
els = db_api.export_location_get_all_by_share_id(
self.ctxt, self.share.id)
self.assertEqual(3, len(els))
for path in self.shown_locations:
self.assertTrue(any([path in el.path for el in els]))
def test_get_export_locations_by_share_id_ignore_migration_dest(self):
els = db_api.share_export_locations_get_by_share_id(
els = db_api.export_location_get_all_by_share_id(
self.ctxt, self.share.id, ignore_migration_destination=True)
self.assertEqual(2, len(els))
for path in self.shown_locations:
self.assertTrue(any([path in el.path for el in els]))
def test_get_export_locations_by_share_instance_id(self):
els = db_api.share_export_locations_get_by_share_instance_id(
els = db_api.export_location_get_all_by_share_instance_id(
self.ctxt, self.share.instance.id)
self.assertEqual(1, len(els))
for path in [self.shown_locations[1]]:

View File

@ -1149,7 +1149,7 @@ class ShareAPITestCase(test.TestCase):
self.mock_object(self.scheduler_rpcapi, 'manage_share')
self.mock_object(db_api, 'share_create',
mock.Mock(return_value=share))
self.mock_object(db_api, 'share_export_locations_update')
self.mock_object(db_api, 'export_locations_update')
self.mock_object(db_api, 'share_get',
mock.Mock(return_value=share))
self.mock_object(share_types, 'get_share_type',
@ -1197,7 +1197,7 @@ class ShareAPITestCase(test.TestCase):
self.context, filters=filters)
db_api.share_create.assert_called_once_with(self.context, share_data)
db_api.share_get.assert_called_once_with(self.context, share['id'])
db_api.share_export_locations_update.assert_called_once_with(
db_api.export_locations_update.assert_called_once_with(
self.context, share.instance['id'], export_location)
self.scheduler_rpcapi.manage_share.assert_called_once_with(
self.context, share['id'], driver_options, expected_request_spec)

View File

@ -215,8 +215,7 @@ class ShareManagerTestCase(test.TestCase):
self.mock_object(self.share_manager.db, 'share_instance_get',
mock.Mock(side_effect=[instances[0], instances[2],
instances[4]]))
self.mock_object(self.share_manager.db,
'share_export_locations_update')
self.mock_object(self.share_manager.db, 'export_locations_update')
mock_ensure_shares = self.mock_object(
self.share_manager.driver, 'ensure_shares',
mock.Mock(return_value=fake_update_instances))
@ -236,7 +235,7 @@ class ShareManagerTestCase(test.TestCase):
self.share_manager.ensure_driver_resources(self.context)
exports_update = self.share_manager.db.share_export_locations_update
exports_update = self.share_manager.db.export_locations_update
mock_backend_info_update.assert_called_once_with(
utils.IsAMatcher(context.RequestContext),
self.share_manager.host,
@ -456,7 +455,7 @@ class ShareManagerTestCase(test.TestCase):
mock.Mock(side_effect=[instances[0], instances[2],
instances[4]]))
self.mock_object(self.share_manager.db,
'share_export_locations_update')
'export_locations_update')
mock_ensure_shares = self.mock_object(
self.share_manager.driver, 'ensure_shares',
mock.Mock(return_value=fake_update_instances))
@ -482,7 +481,7 @@ class ShareManagerTestCase(test.TestCase):
self.share_manager.init_host()
# verification of call
exports_update = self.share_manager.db.share_export_locations_update
exports_update = self.share_manager.db.export_locations_update
self.share_manager.driver.do_setup.assert_called_once_with(
utils.IsAMatcher(context.RequestContext))
(self.share_manager.driver.check_for_setup_error.
@ -1100,7 +1099,7 @@ class ShareManagerTestCase(test.TestCase):
mock.Mock(return_value=[]))
mock_replica_update_call = self.mock_object(db, 'share_replica_update')
mock_export_locs_update_call = self.mock_object(
db, 'share_export_locations_update')
db, 'export_locations_update')
mock_log_error = self.mock_object(manager.LOG, 'error')
mock_log_info = self.mock_object(manager.LOG, 'info')
self.mock_object(db, 'share_instance_access_get',
@ -1163,7 +1162,7 @@ class ShareManagerTestCase(test.TestCase):
mock.Mock(return_value=[]))
mock_replica_update_call = self.mock_object(db, 'share_replica_update')
mock_export_locs_update_call = self.mock_object(
db, 'share_export_locations_update')
db, 'export_locations_update')
mock_log_info = self.mock_object(manager.LOG, 'info')
mock_log_warning = self.mock_object(manager.LOG, 'warning')
mock_log_error = self.mock_object(manager.LOG, 'error')
@ -1227,7 +1226,7 @@ class ShareManagerTestCase(test.TestCase):
'progress': '100%'}),
]
mock_export_locs_update_call = self.mock_object(
db, 'share_export_locations_update')
db, 'export_locations_update')
mock_log_info = self.mock_object(manager.LOG, 'info')
mock_log_warning = self.mock_object(manager.LOG, 'warning')
mock_log_error = self.mock_object(manager.LOG, 'warning')
@ -1293,7 +1292,7 @@ class ShareManagerTestCase(test.TestCase):
mock_replica_update_call = self.mock_object(db, 'share_replica_update')
mock_export_locs_update_call = self.mock_object(
db, 'share_export_locations_update')
db, 'export_locations_update')
mock_log_info = self.mock_object(manager.LOG, 'info')
mock_log_warning = self.mock_object(manager.LOG, 'warning')
mock_log_error = self.mock_object(manager.LOG, 'warning')
@ -1632,7 +1631,7 @@ class ShareManagerTestCase(test.TestCase):
db, 'share_snapshot_instance_update')
mock_info_log = self.mock_object(manager.LOG, 'info')
mock_export_locs_update = self.mock_object(
db, 'share_export_locations_update')
db, 'export_locations_update')
mock_replica_update = self.mock_object(db, 'share_replica_update')
call_1 = mock.call(mock.ANY, replica['id'],
{'status': constants.STATUS_AVAILABLE,
@ -1704,7 +1703,7 @@ class ShareManagerTestCase(test.TestCase):
mock.Mock(return_value=updated_replica_list))
mock_info_log = self.mock_object(manager.LOG, 'info')
mock_export_locs_update = self.mock_object(
db, 'share_export_locations_update')
db, 'export_locations_update')
mock_replica_update = self.mock_object(db, 'share_replica_update')
reset_replication_change_updates = {
'replica_state': constants.STATUS_ACTIVE,
@ -3277,9 +3276,9 @@ class ShareManagerTestCase(test.TestCase):
self.mock_object(share_types, 'provision_filter_on_size', mock.Mock())
self.mock_object(
self.share_manager.db,
'share_export_locations_update',
'export_locations_update',
mock.Mock(side_effect=(
self.share_manager.db.share_export_locations_update)))
self.share_manager.db.export_locations_update)))
self.mock_object(share_types,
'get_share_type_extra_specs',
mock.Mock(return_value=str(dhss)))
@ -3319,13 +3318,13 @@ class ShareManagerTestCase(test.TestCase):
else:
mock_manage.assert_called_once_with(mock.ANY, driver_options)
if export_locations:
(self.share_manager.db.share_export_locations_update.
(self.share_manager.db.export_locations_update.
assert_called_once_with(
utils.IsAMatcher(context.RequestContext),
share.instance['id'], export_locations, delete=True))
else:
self.assertFalse(
self.share_manager.db.share_export_locations_update.called)
self.share_manager.db.export_locations_update.called)
valid_share_data = {
'status': constants.STATUS_AVAILABLE, 'launched_at': mock.ANY}
if replication_type:
@ -5051,7 +5050,7 @@ class ShareManagerTestCase(test.TestCase):
self.mock_object(self.share_manager.db, 'share_group_update')
self.mock_object(self.share_manager.db, 'share_instance_update')
self.mock_object(self.share_manager.db,
'share_export_locations_update')
'export_locations_update')
fake_share_update = {'id': fake_share['id'],
'foo': 'bar',
@ -5074,7 +5073,7 @@ class ShareManagerTestCase(test.TestCase):
{'foo': 'bar',
'status': share_status or constants.STATUS_AVAILABLE,
'progress': exp_progress})
self.share_manager.db.share_export_locations_update.assert_any_call(
self.share_manager.db.export_locations_update.assert_any_call(
mock.ANY, 'fake_share_id', fake_export_locations)
self.share_manager.db.share_group_update.assert_any_call(
mock.ANY, 'fake_id', {
@ -6349,7 +6348,7 @@ class ShareManagerTestCase(test.TestCase):
self.share_manager.db, 'share_access_get_all_for_instance',
mock.Mock(return_value=fake_rules))
self.mock_object(
self.share_manager.db, 'share_export_locations_update')
self.share_manager.db, 'export_locations_update')
self.mock_object(self.share_manager.driver, 'migration_complete',
mock.Mock(return_value=fake_return_data))
self.mock_object(
@ -6383,7 +6382,7 @@ class ShareManagerTestCase(test.TestCase):
self.share_manager.db.share_server_get.assert_has_calls([
mock.call(self.context, 'fake_src_server_id'),
mock.call(self.context, 'fake_dest_server_id')])
(self.share_manager.db.share_export_locations_update.
(self.share_manager.db.export_locations_update.
assert_called_once_with(self.context, dest_instance['id'],
'fake_export_locations'))
self.share_manager.driver.migration_complete.assert_called_once_with(
@ -8442,7 +8441,7 @@ class ShareManagerTestCase(test.TestCase):
db_si_update = self.mock_object(self.share_manager.db,
'share_instance_update')
db_el_update = self.mock_object(self.share_manager.db,
'share_export_locations_update')
'export_locations_update')
in_progress_instances = [x for x in instances
if x['status'] ==
@ -9550,7 +9549,7 @@ class ShareManagerTestCase(test.TestCase):
mock_service_get_by_args = self.mock_object(
db, 'service_get_by_args', mock.Mock(return_value=fake_service))
mock_instance_update = self.mock_object(db, 'share_instance_update')
mock_el_update = self.mock_object(db, 'share_export_locations_update')
mock_el_update = self.mock_object(db, 'export_locations_update')
mock_snap_el_update = self.mock_object(
db, 'share_snapshot_instance_export_locations_update')
mock_reset_access_rules = self.mock_object(
@ -10331,7 +10330,7 @@ class ShareManagerTestCase(test.TestCase):
mock_db_backend_details_set = self.mock_object(
self.share_manager.db, 'share_server_backend_details_set')
mock_db_export_share_update = self.mock_object(
self.share_manager.db, 'share_export_locations_update')
self.share_manager.db, 'export_locations_update')
mock_db_snapshot_update = self.mock_object(
self.share_manager.db, 'share_snapshot_instance_update')
mock_db_export_snap_update = self.mock_object(