"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "manila/share/api.py" between
manila-11.0.0.tar.gz and manila-11.0.1.tar.gz

About: OpenStack Manila provides “Shared Filesystems as a service”.
The "Victoria" series (latest release).

api.py  (manila-11.0.0):api.py  (manila-11.0.1)
skipping to change at line 771 skipping to change at line 771
def update_share_replica(self, context, share_replica): def update_share_replica(self, context, share_replica):
if not share_replica['host']: if not share_replica['host']:
msg = _("Share replica does not have a valid host.") msg = _("Share replica does not have a valid host.")
raise exception.InvalidHost(reason=msg) raise exception.InvalidHost(reason=msg)
self.share_rpcapi.update_share_replica(context, share_replica) self.share_rpcapi.update_share_replica(context, share_replica)
def manage(self, context, share_data, driver_options): def manage(self, context, share_data, driver_options):
shares = self.get_all(context, {
# Check whether there's a share already with the provided options:
filters = {
'export_location_path': share_data['export_location_path'],
'host': share_data['host'], 'host': share_data['host'],
'export_location': share_data['export_location'], }
'share_proto': share_data['share_proto'], share_server_id = share_data.get('share_server_id')
'share_type_id': share_data['share_type_id'] if share_server_id:
}) filters['share_server_id'] = share_data['share_server_id']
already_managed = self.db.share_instances_get_all(context,
filters=filters)
if already_managed:
LOG.error("Found an existing share with export location %s!",
share_data['export_location_path'])
msg = _("A share already exists with the export path specified.")
raise exception.InvalidShare(reason=msg)
share_type_id = share_data['share_type_id'] share_type_id = share_data['share_type_id']
share_type = share_types.get_share_type(context, share_type_id) share_type = share_types.get_share_type(context, share_type_id)
share_server_id = share_data.get('share_server_id')
dhss = share_types.parse_boolean_extra_spec( dhss = share_types.parse_boolean_extra_spec(
'driver_handles_share_servers', 'driver_handles_share_servers',
share_type['extra_specs']['driver_handles_share_servers']) share_type['extra_specs']['driver_handles_share_servers'])
if dhss and not share_server_id: if dhss and not share_server_id:
msg = _("Share Server ID parameter is required when managing a " msg = _("Share Server ID parameter is required when managing a "
"share using a share type with " "share using a share type with "
"driver_handles_share_servers extra-spec set to True.") "driver_handles_share_servers extra-spec set to True.")
raise exception.InvalidInput(reason=msg) raise exception.InvalidInput(reason=msg)
if not dhss and share_server_id: if not dhss and share_server_id:
skipping to change at line 822 skipping to change at line 832
share_data.update({ share_data.update({
'user_id': context.user_id, 'user_id': context.user_id,
'project_id': context.project_id, 'project_id': context.project_id,
'status': constants.STATUS_MANAGING, 'status': constants.STATUS_MANAGING,
'scheduled_at': timeutils.utcnow(), 'scheduled_at': timeutils.utcnow(),
}) })
share_data.update( share_data.update(
self.get_share_attributes_from_share_type(share_type)) self.get_share_attributes_from_share_type(share_type))
LOG.debug("Manage: Found shares %s.", len(shares)) share = self.db.share_create(context, share_data)
export_location = share_data.pop('export_location')
if len(shares) == 0:
share = self.db.share_create(context, share_data)
else:
msg = _("Share already exists.")
raise exception.InvalidShare(reason=msg)
export_location_path = share_data.pop('export_location_path')
self.db.share_export_locations_update(context, share.instance['id'], self.db.share_export_locations_update(context, share.instance['id'],
export_location) export_location_path)
request_spec = self._get_request_spec_dict( request_spec = self._get_request_spec_dict(
share, share_type, size=0, share_proto=share_data['share_proto'], share, share_type, size=0, share_proto=share_data['share_proto'],
host=share_data['host']) host=share_data['host'])
# NOTE(ganso): Scheduler is called to validate if share type # NOTE(ganso): Scheduler is called to validate if share type
# provided can fit in host provided. It will invoke manage upon # provided can fit in host provided. It will invoke manage upon
# successful validation. # successful validation.
self.scheduler_rpcapi.manage_share(context, share['id'], self.scheduler_rpcapi.manage_share(context, share['id'],
driver_options, request_spec) driver_options, request_spec)
skipping to change at line 1771 skipping to change at line 1774
sort_dir='desc'): sort_dir='desc'):
policy.check_policy(context, 'share', 'get_all') policy.check_policy(context, 'share', 'get_all')
if search_opts is None: if search_opts is None:
search_opts = {} search_opts = {}
LOG.debug("Searching for shares by: %s", search_opts) LOG.debug("Searching for shares by: %s", search_opts)
# Prepare filters # Prepare filters
filters = {} filters = {}
if 'export_location_id' in search_opts:
filters['export_location_id'] = search_opts.pop( filter_keys = [
'export_location_id') 'display_name', 'share_group_id', 'display_name~',
if 'export_location_path' in search_opts: 'display_description', 'display_description~', 'snapshot_id',
filters['export_location_path'] = search_opts.pop( 'status', 'share_type_id', 'project_id', 'export_location_id',
'export_location_path') 'export_location_path', 'limit', 'offset', 'host',
'share_network_id']
for key in filter_keys:
if key in search_opts:
filters[key] = search_opts.pop(key)
if 'metadata' in search_opts: if 'metadata' in search_opts:
filters['metadata'] = search_opts.pop('metadata') filters['metadata'] = search_opts.pop('metadata')
if not isinstance(filters['metadata'], dict): if not isinstance(filters['metadata'], dict):
msg = _("Wrong metadata filter provided: " msg = _("Wrong metadata filter provided: "
"%s.") % six.text_type(filters['metadata']) "%s.") % six.text_type(filters['metadata'])
raise exception.InvalidInput(reason=msg) raise exception.InvalidInput(reason=msg)
if 'extra_specs' in search_opts: if 'extra_specs' in search_opts:
# Verify policy for extra-specs access # Verify policy for extra-specs access
policy.check_policy(context, 'share_types_extra_spec', 'index') policy.check_policy(context, 'share_types_extra_spec', 'index')
filters['extra_specs'] = search_opts.pop('extra_specs') filters['extra_specs'] = search_opts.pop('extra_specs')
if not isinstance(filters['extra_specs'], dict): if not isinstance(filters['extra_specs'], dict):
msg = _("Wrong extra specs filter provided: " msg = _("Wrong extra specs filter provided: "
"%s.") % six.text_type(filters['extra_specs']) "%s.") % six.text_type(filters['extra_specs'])
raise exception.InvalidInput(reason=msg) raise exception.InvalidInput(reason=msg)
if 'limit' in search_opts:
filters['limit'] = search_opts.pop('limit')
if 'offset' in search_opts:
filters['offset'] = search_opts.pop('offset')
if not (isinstance(sort_key, six.string_types) and sort_key): if not (isinstance(sort_key, six.string_types) and sort_key):
msg = _("Wrong sort_key filter provided: " msg = _("Wrong sort_key filter provided: "
"'%s'.") % six.text_type(sort_key) "'%s'.") % six.text_type(sort_key)
raise exception.InvalidInput(reason=msg) raise exception.InvalidInput(reason=msg)
if not (isinstance(sort_dir, six.string_types) and sort_dir): if not (isinstance(sort_dir, six.string_types) and sort_dir):
msg = _("Wrong sort_dir filter provided: " msg = _("Wrong sort_dir filter provided: "
"'%s'.") % six.text_type(sort_dir) "'%s'.") % six.text_type(sort_dir)
raise exception.InvalidInput(reason=msg) raise exception.InvalidInput(reason=msg)
is_public = search_opts.pop('is_public', False) is_public = search_opts.pop('is_public', False)
is_public = strutils.bool_from_string(is_public, strict=True) is_public = strutils.bool_from_string(is_public, strict=True)
# Get filtered list of shares # Get filtered list of shares
if 'host' in search_opts: if 'host' in filters:
policy.check_policy(context, 'share', 'list_by_host') policy.check_policy(context, 'share', 'list_by_host')
if 'share_server_id' in search_opts: if 'share_server_id' in search_opts:
# NOTE(vponomaryov): this is project_id independent # NOTE(vponomaryov): this is project_id independent
policy.check_policy(context, 'share', 'list_by_share_server_id') policy.check_policy(context, 'share', 'list_by_share_server_id')
shares = self.db.share_get_all_by_share_server( shares = self.db.share_get_all_by_share_server(
context, search_opts.pop('share_server_id'), filters=filters, context, search_opts.pop('share_server_id'), filters=filters,
sort_key=sort_key, sort_dir=sort_dir) sort_key=sort_key, sort_dir=sort_dir)
elif (context.is_admin and utils.is_all_tenants(search_opts)): elif (context.is_admin and utils.is_all_tenants(search_opts)):
shares = self.db.share_get_all( shares = self.db.share_get_all(
context, filters=filters, sort_key=sort_key, sort_dir=sort_dir) context, filters=filters, sort_key=sort_key, sort_dir=sort_dir)
 End of changes. 9 change blocks. 
28 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)