Пример #1
0
def check_shares(data):
    if not data:
        return

    paths = (share.get('path') for share in data)
    paths = [path for path in paths if path is not None]
    if len(paths) != len(set(paths)):
        raise ex.InvalidDataException(
            _('Multiple shares cannot be mounted to the same path.'))

    for path in paths:
        if not path.startswith('/') or '\x00' in path:
            raise ex.InvalidDataException(
                _('Paths must be absolute Linux paths starting with "/" '
                  'and may not contain nulls.'))

    client = manila.client()
    for share in data:
        manila_share = manila.get_share(client, share['id'])
        if not manila_share:
            raise ex.InvalidReferenceException(
                _("Requested share id %s does not exist.") % share['id'])

        share_type = manila_share.share_proto
        if share_type not in shares.SUPPORTED_SHARE_TYPES:
            raise ex.InvalidReferenceException(
                _("Requested share id %(id)s is of type %(type)s, which is "
                  "not supported by Sahara.") % {
                      "id": share['id'],
                      "type": share_type
                  })
Пример #2
0
def check_shares(data):
    if not data:
        return

    paths = (share.get('path') for share in data)
    paths = [path for path in paths if path is not None]
    if len(paths) != len(set(paths)):
        raise ex.InvalidDataException(
            _('Multiple shares cannot be mounted to the same path.'))

    for path in paths:
        if not path.startswith('/') or '\x00' in path:
            raise ex.InvalidDataException(
                _('Paths must be absolute Linux paths starting with "/"'
                  'and may not contain nulls.'))

    client = manila.client()
    for share in data:
        manila_share = manila.get_share(client, share['id'])
        if not manila_share:
            raise ex.InvalidReferenceException(
                _("Requested share id %s does not exist.") % share['id'])

        share_type = manila_share.share_proto
        if share_type not in shares.SUPPORTED_SHARE_TYPES:
            raise ex.InvalidReferenceException(
                _("Requested share id %(id)s is of type %(type)s, which is "
                  "not supported by Sahara.")
                % {"id": share['id'], "type": share_type})
Пример #3
0
 def create_from_id(cls, share_id, client):
     """Factory method for creation from a share_id of unknown type."""
     share = manila.get_share(client, share_id, raise_on_error=True)
     mounter_class = _share_types[share.share_proto]
     return mounter_class(share, client)
Пример #4
0
 def create_from_id(cls, share_id, client):
     """Factory method for creation from a share_id of unknown type."""
     share = manila.get_share(client, share_id,
                              raise_on_error=True)
     mounter_class = _share_types[share.share_proto]
     return mounter_class(share, client)