manila.i18n._

Here are the examples of the python api manila.i18n._ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

199 Examples 7

Example 1

Project: manila Source File: standalone_network_plugin.py
    def _get_network(self):
        """Returns IPNetwork object calculated from gateway and netmask."""
        if not isinstance(self.gateway, six.string_types):
            raise exception.NetworkBadConfigurationException(
                _("Configuration option 'standalone_network_plugin_gateway' "
                  "is required and has improper value '%s'.") % self.gateway)
        if not isinstance(self.mask, six.string_types):
            raise exception.NetworkBadConfigurationException(
                _("Configuration option 'standalone_network_plugin_mask' is "
                  "required and has improper value '%s'.") % self.mask)
        try:
            return netaddr.IPNetwork(self.gateway + '/' + self.mask)
        except netaddr.AddrFormatError as e:
            raise exception.NetworkBadConfigurationException(
                reason=e)

Example 2

Project: manila Source File: container_helper.py
    def execute(self, name=None, cmd=None):
        if name is None:
            raise exception.ManilaException(_("Container name not specified."))
        if cmd is None or (type(cmd) is not list):
            raise exception.ManilaException(_("Missing or malformed command."))
        LOG.debug("Executing inside a container %s.", name)
        cmd = ["docker", "exec", "-i", name] + cmd
        result = self._inner_execute(cmd)
        LOG.debug("Run result: %s.", result)
        return result

Example 3

Project: manila Source File: share_export_locations.py
    def _verify_share(self, context, share_id):
        try:
            db_api.share_get(context, share_id)
        except exception.NotFound:
            msg = _("Share '%s' not found.") % share_id
            raise exc.HTTPNotFound(explanation=msg)

Example 4

Project: manila Source File: nova.py
    def server_get_by_name_or_id(self, context, instance_name_or_id):
        try:
            server = utils.find_resource(
                novaclient(context).servers, instance_name_or_id)
        except nova_exception.CommandError:
            # we did not find the server in the current tenant,
            # and proceed searching in all tenants
            try:
                server = utils.find_resource(
                    novaclient(context).servers, instance_name_or_id,
                    all_tenants=True)
            except nova_exception.CommandError as e:
                msg = _("Failed to get Nova VM. %s") % e
                raise exception.ManilaException(msg)
        return _untranslate_server_summary_view(server)

Example 5

Project: manila Source File: share_replicas.py
    @wsgi.Controller.api_version(MIN_SUPPORTED_API_VERSION, experimental=True)
    @wsgi.Controller.authorize
    def delete(self, req, id):
        """Delete a replica."""
        context = req.environ['manila.context']

        try:
            replica = db.share_replica_get(context, id)
        except exception.ShareReplicaNotFound:
            msg = _("No replica exists with ID %s.")
            raise exc.HTTPNotFound(explanation=msg % id)

        try:
            self.share_api.delete_share_replica(context, replica)
        except exception.ReplicationException as e:
            raise exc.HTTPBadRequest(explanation=six.text_type(e))

        return webob.Response(status_int=202)

Example 6

Project: manila Source File: quota_sets.py
    def _validate_quota_limit(self, limit, minimum, maximum, force_update):
        # NOTE: -1 is a flag value for unlimited
        if limit < -1:
            msg = _("Quota limit must be -1 or greater.")
            raise webob.exc.HTTPBadRequest(explanation=msg)
        if ((limit < minimum and not force_update) and
           (maximum != -1 or (maximum == -1 and limit != -1))):
            msg = _("Quota limit must be greater than %s.") % minimum
            raise webob.exc.HTTPBadRequest(explanation=msg)
        if maximum != -1 and limit > maximum:
            msg = _("Quota limit must be less than %s.") % maximum
            raise webob.exc.HTTPBadRequest(explanation=msg)

Example 7

Project: manila Source File: filter.py
    def _max_attempts(self):
        max_attempts = CONF.scheduler_max_attempts
        if max_attempts < 1:
            msg = _("Invalid value for 'scheduler_max_attempts', "
                    "must be >=1")
            raise exception.InvalidParameterValue(err=msg)
        return max_attempts

Example 8

Project: manila Source File: share_metadata.py
    def update_all(self, req, share_id, body):
        try:
            metadata = body['metadata']
        except (TypeError, KeyError):
            expl = _('Malformed request body')
            raise exc.HTTPBadRequest(explanation=expl)

        context = req.environ['manila.context']
        new_metadata = self._update_share_metadata(context, share_id,
                                                   metadata, delete=True)
        return {'metadata': new_metadata}

Example 9

Project: manila Source File: driver.py
    @utils.synchronized("veth-lock", external=True)
    def _setup_server(self, network_info, metadata=None):
        msg = "Creating share server '%s'."
        server_id = self._get_container_name(network_info["server_id"])
        LOG.debug(msg % server_id)

        veths_before = self._get_veth_state()
        try:
            self.container.start_container(server_id)
        except Exception as e:
            raise exception.ManilaException(_("Cannot create container: %s") %
                                            e)
        veths_after = self._get_veth_state()

        veth = self._get_corresponding_veth(veths_before, veths_after)
        self._connect_to_network(server_id, network_info, veth)
        LOG.info(_LI("Container %s was created."), server_id)
        return {"id": network_info["server_id"]}

Example 10

Project: manila Source File: share_metadata.py
    def delete(self, req, share_id, id):
        """Deletes an existing metadata."""
        context = req.environ['manila.context']

        metadata = self._get_metadata(context, share_id)

        if id not in metadata:
            msg = _("Metadata item was not found")
            raise exc.HTTPNotFound(explanation=msg)

        try:
            share = self.share_api.get(context, share_id)
            self.share_api.delete_share_metadata(context, share, id)
        except exception.NotFound:
            msg = _('share does not exist')
            raise exc.HTTPNotFound(explanation=msg)
        return webob.Response(status_int=200)

Example 11

Project: manila Source File: share_types.py
    def _verify_if_non_public_share_type(self, context, share_type_id):
        try:
            share_type = share_types.get_share_type(context, share_type_id)

            if share_type['is_public']:
                msg = _("Type access modification is not applicable to "
                        "public share type.")
                raise webob.exc.HTTPConflict(explanation=msg)

        except exception.ShareTypeNotFound as err:
            raise webob.exc.HTTPNotFound(explanation=six.text_type(err))

Example 12

Project: manila Source File: share_types.py
    def _check_body(self, body, action_name):
        if not self.is_valid_body(body, action_name):
            raise webob.exc.HTTPBadRequest()
        access = body[action_name]
        project = access.get('project')
        if not uuidutils.is_uuid_like(project):
            msg = _("Bad project format: "
                    "project is not in proper format (%s)") % project
            raise webob.exc.HTTPBadRequest(explanation=msg)

Example 13

Project: manila Source File: cgsnapshots.py
    @wsgi.Controller.api_version('2.4', experimental=True)
    @wsgi.Controller.authorize('get_cgsnapshot')
    def show(self, req, id):
        """Return data about the given cgsnapshot."""
        context = req.environ['manila.context']

        try:
            cg = self.cg_api.get_cgsnapshot(context, id)
        except exception.NotFound:
            msg = _("Consistency group snapshot %s not found.") % id
            raise exc.HTTPNotFound(explanation=msg)

        return self._view_builder.detail(req, cg)

Example 14

Project: manila Source File: ip_lib.py
    def execute(self, cmds, addl_env=None, check_exit_code=True):
        if addl_env is None:
            addl_env = dict()

        if not self._parent.namespace:
            raise Exception(_('No namespace defined for parent'))
        else:
            env_params = []
            if addl_env:
                env_params = (['env'] + ['%s=%s' % pair
                              for pair in sorted(addl_env.items())])
            total_cmd = (['ip', 'netns', 'exec', self._parent.namespace] +
                         env_params + list(cmds))
            return utils.execute(*total_cmd, run_as_root=True,
                                 check_exit_code=check_exit_code)

Example 15

Project: manila Source File: share_metadata.py
    def _get_metadata(self, context, share_id):
        try:
            share = self.share_api.get(context, share_id)
            meta = self.share_api.get_share_metadata(context, share)
        except exception.NotFound:
            msg = _('share does not exist')
            raise exc.HTTPNotFound(explanation=msg)
        return meta

Example 16

Project: manila Source File: base.py
Function: schedule_create_consistency_group
    def schedule_create_consistency_group(self, context, group_id,
                                          request_spec,
                                          filter_properties):
        """Must override schedule method for scheduler to work."""
        raise NotImplementedError(_(
            "Must implement schedule_create_consistency_group"))

Example 17

Project: manila Source File: shares.py
    @wsgi.Controller.api_version('2.22', experimental=True)
    @wsgi.action("migration_cancel")
    @wsgi.Controller.authorize
    def migration_cancel(self, req, id, body):
        """Attempts to cancel share migration."""
        context = req.environ['manila.context']
        try:
            share = self.share_api.get(context, id)
        except exception.NotFound:
            msg = _("Share %s not found.") % id
            raise exc.HTTPNotFound(explanation=msg)
        self.share_api.migration_cancel(context, share)
        return webob.Response(status_int=202)

Example 18

Project: manila Source File: evaluator.py
    def eval(self):
        prod = self.value[0].eval()
        for op, val in _operatorOperands(self.value[1:]):
            try:
                if op == '*':
                    prod *= val.eval()
                elif op == '/':
                    prod /= float(val.eval())
            except ZeroDivisionError as e:
                msg = _("ZeroDivisionError: %s") % six.text_type(e)
                raise exception.EvaluatorParseException(reason=msg)
        return prod

Example 19

Project: manila Source File: __init__.py
    def __init__(self, ext_mgr=None):
        if ext_mgr is None:
            if self.ExtensionManager:
                ext_mgr = self.ExtensionManager()
            else:
                raise Exception(_("Must specify an ExtensionManager class"))

        mapper = ProjectMapper()
        self.resources = {}
        self._setup_routes(mapper, ext_mgr)
        self._setup_ext_routes(mapper, ext_mgr)
        self._setup_extensions(ext_mgr)
        super(APIRouter, self).__init__(mapper)

Example 20

Project: manila Source File: driver.py
    def check_for_setup_error(self, *args, **kwargs):
        host_id = self.configuration.safe_get("neutron_host_id")
        neutron_class = importutils.import_class(
            'manila.network.neutron.neutron_network_plugin.'
            'NeutronNetworkPlugin'
        )
        actual_class = importutils.import_class(
            self.configuration.safe_get("network_api_class"))
        if host_id is None and issubclass(actual_class, neutron_class):
            msg = _("%s requires neutron_host_id to be "
                    "specified.") % neutron_class
            raise exception.ManilaException(msg)
        elif host_id is None:
            LOG.warning(_LW("neutron_host_id is not specified. This driver "
                            "might not work as expected without it."))

Example 21

Project: manila Source File: share_instance_export_locations.py
    def _verify_share_instance(self, context, share_instance_id):
        try:
            db_api.share_instance_get(context, share_instance_id)
        except exception.NotFound:
            msg = _("Share instance '%s' not found.") % share_instance_id
            raise exc.HTTPNotFound(explanation=msg)

Example 22

Project: manila Source File: share_replicas.py
    @wsgi.Controller.api_version(MIN_SUPPORTED_API_VERSION, experimental=True)
    @wsgi.Controller.authorize
    def show(self, req, id):
        """Return data about the given replica."""
        context = req.environ['manila.context']

        try:
            replica = db.share_replica_get(context, id)
        except exception.ShareReplicaNotFound:
            msg = _("Replica %s not found.") % id
            raise exc.HTTPNotFound(explanation=msg)

        return self._view_builder.detail(req, replica)

Example 23

Project: manila Source File: shares.py
    @staticmethod
    def _validate_common_name(access):
        """Validate common name passed by user.

        'access' is used as the certificate's CN (common name)
        to which access is allowed or denied by the backend.
        The standard allows for just about any string in the
        common name. The meaning of a string depends on its
        interpretation and is limited to 64 characters.
        """
        if len(access) == 0 or len(access) > 64:
            exc_str = _('Invalid CN (common name). Must be 1-64 chars long')
            raise webob.exc.HTTPBadRequest(explanation=exc_str)

Example 24

Project: manila Source File: share_snapshot_instances.py
    @wsgi.Controller.api_version('2.19')
    @wsgi.Controller.authorize
    def show(self, req, id):
        context = req.environ['manila.context']
        try:
            snapshot_instance = db.share_snapshot_instance_get(
                context, id)
        except exception.ShareSnapshotInstanceNotFound:
            msg = (_("Snapshot instance %s not found.") % id)
            raise exc.HTTPNotFound(explanation=msg)
        return self._view_builder.detail(req, snapshot_instance)

Example 25

Project: manila Source File: share_types_extra_specs.py
    @wsgi.Controller.authorize
    def update(self, req, type_id, id, body=None):
        context = req.environ['manila.context']
        if not body:
            expl = _('Request body empty')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        self._check_type(context, type_id)
        if id not in body:
            expl = _('Request body and URI mismatch')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        if len(body) > 1:
            expl = _('Request body contains too many items')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        self._verify_extra_specs(body, False)
        db.share_type_extra_specs_update_or_create(context, type_id, body)
        notifier_info = dict(type_id=type_id, id=id)
        notifier = rpc.get_notifier('shareTypeExtraSpecs')
        notifier.info(context, 'share_type_extra_specs.update', notifier_info)
        return body

Example 26

Project: manila Source File: share_types.py
    @staticmethod
    def _parse_is_public(is_public):
        """Parse is_public into something usable.

        * True: API should list public share types only
        * False: API should list private share types only
        * None: API should list both public and private share types
        """
        if is_public is None:
            # preserve default value of showing only public types
            return True
        elif six.text_type(is_public).lower() == "all":
            return None
        else:
            try:
                return strutils.bool_from_string(is_public, strict=True)
            except ValueError:
                msg = _('Invalid is_public filter [%s]') % is_public
                raise exc.HTTPBadRequest(explanation=msg)

Example 27

Project: manila Source File: share_types.py
    @wsgi.Controller.authorize
    def show(self, req, id):
        """Return a single share type item."""
        context = req.environ['manila.context']
        try:
            share_type = share_types.get_share_type(context, id)
        except exception.NotFound:
            msg = _("Share type not found.")
            raise exc.HTTPNotFound(explanation=msg)

        share_type['id'] = six.text_type(share_type['id'])
        req.cache_db_share_type(share_type)
        return self._view_builder.show(req, share_type)

Example 28

Project: manila Source File: share_types_extra_specs.py
    def _check_key_names(self, keys):
        if not common.validate_key_names(keys):
            expl = _('Key names can only contain alphanumeric characters, '
                     'underscores, periods, colons and hyphens.')

            raise webob.exc.HTTPBadRequest(explanation=expl)

Example 29

Project: manila Source File: client_auth.py
    def _load_auth_plugin(self):
        if self.admin_auth:
            return self.admin_auth
        self.auth_plugin = ks_loading.load_auth_from_conf_options(
            CONF, self.group)

        if self.deprecated_opts_for_v2 and not self.auth_plugin:
            LOG.warning(_LW("Not specifying auth options is deprecated"))
            self.auth_plugin = v2.Password().load_from_options(
                **self.deprecated_opts_for_v2)

        if self.auth_plugin:
            return self.auth_plugin

        msg = _('Cannot load auth plugin for %s') % self.group
        raise self.exception_module.Unauthorized(message=msg)

Example 30

Project: manila Source File: shares.py
    def _get_valid_resize_parameters(self, context, id, body, action):
        try:
            share = self.share_api.get(context, id)
        except exception.NotFound as e:
            raise webob.exc.HTTPNotFound(explanation=six.text_type(e))

        try:
            size = int(body.get(action,
                                body.get(action.split('os-')[-1]))['new_size'])
        except (KeyError, ValueError, TypeError):
            msg = _("New share size must be specified as an integer.")
            raise webob.exc.HTTPBadRequest(explanation=msg)

        return share, size

Example 31

Project: manila Source File: utils.py
def _validate_item(src_item, dest_item):
    src_sum, err = utils.execute(
        "sha256sum", "%s" % src_item, run_as_root=True)
    dest_sum, err = utils.execute(
        "sha256sum", "%s" % dest_item, run_as_root=True)
    if src_sum.split()[0] != dest_sum.split()[0]:
        msg = _("Data corrupted while copying. Aborting data copy.")
        raise exception.ShareDataCopyFailed(reason=msg)

Example 32

Project: manila Source File: consistency_groups.py
    @wsgi.Controller.api_version('2.4', experimental=True)
    @wsgi.Controller.authorize('get')
    def show(self, req, id):
        """Return data about the given CG."""
        context = req.environ['manila.context']

        try:
            cg = self.cg_api.get(context, id)
        except exception.NotFound:
            msg = _("Consistency group %s not found.") % id
            raise exc.HTTPNotFound(explanation=msg)

        return self._view_builder.detail(req, cg)

Example 33

Project: manila Source File: nova_network_plugin.py
    def __init__(self, *args, **kwargs):
        super(NovaSingleNetworkPlugin, self).__init__(*args, **kwargs)
        CONF.register_opts(
            nova_single_network_plugin_opts,
            group=self.config_group_name)
        self.net_id = getattr(CONF, self.config_group_name,
                              CONF).nova_single_network_plugin_net_id
        if not self.net_id:
            msg = _("Nova network is not set")
            LOG.error(msg)
            raise exception.NetworkBadConfigurationException(reason=msg)

Example 34

Project: manila Source File: wsgi.py
Function: validate_update
    def validate_update(self, body, status_attr='status'):
        update = {}
        try:
            update[status_attr] = body[status_attr]
        except (TypeError, KeyError):
            msg = _("Must specify '%s'") % status_attr
            raise webob.exc.HTTPBadRequest(explanation=msg)
        if update[status_attr] not in self.valid_statuses[status_attr]:
            expl = (_("Invalid state. Valid states: %s.") %
                    ", ".join(six.text_type(i) for i in
                              self.valid_statuses[status_attr]))
            raise webob.exc.HTTPBadRequest(explanation=expl)
        return update

Example 35

Project: manila Source File: __init__.py
    def _verify_share_network(self, share_server_id, share_network):
        if share_network is None:
            msg = _("'Share network' is not provided for setting up "
                    "network interfaces for 'Share server' "
                    "'%s'.") % share_server_id
            raise exception.NetworkBadConfigurationException(reason=msg)

Example 36

Project: manila Source File: shares.py
    @wsgi.Controller.api_version('2.22', experimental=True)
    @wsgi.action("migration_complete")
    @wsgi.Controller.authorize
    def migration_complete(self, req, id, body):
        """Invokes 2nd phase of share migration."""
        context = req.environ['manila.context']
        try:
            share = self.share_api.get(context, id)
        except exception.NotFound:
            msg = _("Share %s not found.") % id
            raise exc.HTTPNotFound(explanation=msg)
        self.share_api.migration_complete(context, share)
        return webob.Response(status_int=202)

Example 37

Project: manila Source File: chance.py
    def _schedule(self, context, topic, request_spec, **kwargs):
        """Picks a host that is up at random."""

        elevated = context.elevated()
        hosts = self.hosts_up(elevated, topic)
        if not hosts:
            msg = _("Is the appropriate service running?")
            raise exception.NoValidHost(reason=msg)

        hosts = self._filter_hosts(request_spec, hosts, **kwargs)
        if not hosts:
            msg = _("Could not find another host")
            raise exception.NoValidHost(reason=msg)

        return hosts[int(random.random() * len(hosts))]

Example 38

Project: manila Source File: share_metadata.py
    def create(self, req, share_id, body):
        try:
            metadata = body['metadata']
        except (KeyError, TypeError):
            msg = _("Malformed request body")
            raise exc.HTTPBadRequest(explanation=msg)

        context = req.environ['manila.context']

        new_metadata = self._update_share_metadata(context,
                                                   share_id,
                                                   metadata,
                                                   delete=False)

        return {'metadata': new_metadata}

Example 39

Project: manila Source File: filter.py
    def host_passes_filters(self, context, host, request_spec,
                            filter_properties):

        elevated = context.elevated()

        filter_properties, share_properties = self._format_filter_properties(
            context, filter_properties, request_spec)

        hosts = self.host_manager.get_all_host_states_share(elevated)
        hosts = self.host_manager.get_filtered_hosts(hosts, filter_properties)
        hosts = self.host_manager.get_weighed_hosts(hosts, filter_properties)

        for tgt_host in hosts:
            if tgt_host.obj.host == host:
                return tgt_host.obj

        msg = (_('Cannot place share %(id)s on %(host)s')
               % {'id': request_spec['share_id'], 'host': host})
        raise exception.NoValidHost(reason=msg)

Example 40

Project: manila Source File: shares.py
    @wsgi.Controller.api_version('2.22', experimental=True)
    @wsgi.action("migration_get_progress")
    @wsgi.Controller.authorize
    def migration_get_progress(self, req, id, body):
        """Retrieve share migration progress for a given share."""
        context = req.environ['manila.context']
        try:
            share = self.share_api.get(context, id)
        except exception.NotFound:
            msg = _("Share %s not found.") % id
            raise exc.HTTPNotFound(explanation=msg)
        result = self.share_api.migration_get_progress(context, share)

        # refresh share model
        share = self.share_api.get(context, id)

        return self._migration_view_builder.get_progress(req, share, result)

Example 41

Project: manila Source File: container_helper.py
    def stop_container(self, name):
        LOG.debug("Stopping container %s.", name)
        cmd = ["docker", "stop", name]
        result = self._inner_execute(cmd) or ['', 1]
        if result[1] != '':
            raise exception.ManilaException(
                _("Container %s has failed to stop properly.") % name)
        LOG.info(_LI("Container %s is successfully stopped."), name)

Example 42

Project: manila Source File: wsgi.py
    def _from_json(self, datastring):
        try:
            return jsonutils.loads(datastring)
        except ValueError:
            msg = _("cannot understand JSON")
            raise exception.MalformedRequestBody(reason=msg)

Example 43

Project: manila Source File: driver.py
    def _get_helper(self, share):
        if share["share_proto"].upper() == "CIFS":
            helper = self._helpers.get("CIFS")
            if helper is not None:
                return helper(self.container,
                              share=share,
                              config=self.configuration)
            self._helpers["CIFS"] = importutils.import_class(
                self.configuration.container_protocol_helper)
            return self._helpers["CIFS"](self.container,
                                         share=share,
                                         config=self.configuration)
        else:
            raise exception.InvalidShare(
                reason=_("Wrong, unsupported or disabled protocol."))

Example 44

Project: manila Source File: share_export_locations.py
    @wsgi.Controller.api_version('2.9')
    @wsgi.Controller.authorize
    def show(self, req, share_id, export_location_uuid):
        """Return data about the requested export location."""
        context = req.environ['manila.context']
        self._verify_share(context, share_id)
        try:
            export_location = db_api.share_export_location_get_by_uuid(
                context, export_location_uuid)
        except exception.ExportLocationNotFound:
            msg = _("Export location '%s' not found.") % export_location_uuid
            raise exc.HTTPNotFound(explanation=msg)

        if export_location.is_admin_only and not context.is_admin:
            raise exc.HTTPForbidden()

        return self._view_builder.detail(req, export_location)

Example 45

Project: manila Source File: share_metadata.py
Function: show
    def show(self, req, share_id, id):
        """Return a single metadata item."""
        context = req.environ['manila.context']
        data = self._get_metadata(context, share_id)

        try:
            return {'meta': {id: data[id]}}
        except KeyError:
            msg = _("Metadata item was not found")
            raise exc.HTTPNotFound(explanation=msg)

Example 46

Project: manila Source File: common.py
def _get_limit_param(request):
    """Extract integer limit from request or fail."""
    try:
        limit = int(request.GET['limit'])
    except ValueError:
        msg = _('limit param must be an integer')
        raise webob.exc.HTTPBadRequest(explanation=msg)
    if limit < 0:
        msg = _('limit param must be positive')
        raise webob.exc.HTTPBadRequest(explanation=msg)
    return limit

Example 47

Project: manila Source File: wsgi.py
def action_peek_json(body):
    """Determine action to invoke."""

    try:
        decoded = jsonutils.loads(body)
    except ValueError:
        msg = _("cannot understand JSON")
        raise exception.MalformedRequestBody(reason=msg)

    # Make sure there's exactly one key...
    if len(decoded) != 1:
        msg = _("too many body keys")
        raise exception.MalformedRequestBody(reason=msg)

    # Return the action and the decoded body...
    return list(decoded.keys())[0]

Example 48

Project: manila Source File: shares.py
    @staticmethod
    def _validate_cephx_id(cephx_id):
        if not cephx_id:
            raise webob.exc.HTTPBadRequest(explanation=_(
                'Ceph IDs may not be empty'))

        # This restriction may be lifted in Ceph in the future:
        # http://tracker.ceph.com/issues/14626
        if not set(cephx_id) <= set(string.printable):
            raise webob.exc.HTTPBadRequest(explanation=_(
                'Ceph IDs must consist of ASCII printable characters'))

        # Periods are technically permitted, but we restrict them here
        # to avoid confusion where users are unsure whether they should
        # include the "client." prefix: otherwise they could accidentally
        # create "client.client.foobar".
        if '.' in cephx_id:
            raise webob.exc.HTTPBadRequest(explanation=_(
                'Ceph IDs may not contain periods'))

Example 49

Project: manila Source File: share_types_extra_specs.py
    @wsgi.Controller.authorize
    def delete(self, req, type_id, id):
        """Deletes an existing extra spec."""
        context = req.environ['manila.context']
        self._check_type(context, type_id)

        if id in share_types.get_undeletable_extra_specs():
            msg = _("Extra spec '%s' can't be deleted.") % id
            raise webob.exc.HTTPForbidden(explanation=msg)

        try:
            db.share_type_extra_specs_delete(context, type_id, id)
        except exception.ShareTypeExtraSpecsNotFound as error:
            raise webob.exc.HTTPNotFound(explanation=error.msg)

        notifier_info = dict(type_id=type_id, id=id)
        notifier = rpc.get_notifier('shareTypeExtraSpecs')
        notifier.info(context, 'share_type_extra_specs.delete', notifier_info)
        return webob.Response(status_int=202)

Example 50

Project: manila Source File: share_types.py
    @wsgi.Controller.authorize
    def default(self, req):
        """Return default volume type."""
        context = req.environ['manila.context']

        try:
            share_type = share_types.get_default_share_type(context)
        except exception.NotFound:
            msg = _("Share type not found")
            raise exc.HTTPNotFound(explanation=msg)

        if not share_type:
            msg = _("Default share type not found")
            raise exc.HTTPNotFound(explanation=msg)

        share_type['id'] = six.text_type(share_type['id'])
        return self._view_builder.show(req, share_type)
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4