当前位置: 首页>>代码示例>>Python>>正文


Python i18n._LI函数代码示例

本文整理汇总了Python中trove.common.i18n._LI函数的典型用法代码示例。如果您正苦于以下问题:Python _LI函数的具体用法?Python _LI怎么用?Python _LI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_LI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: instance_root_create

 def instance_root_create(self, req, body, instance_id,
                          cluster_instances=None):
     LOG.info(_LI("Enabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     user_name = context.user
     password = ClusterRootController._get_password_from_body(body)
     root = models.ClusterRoot.create(context, instance_id, user_name,
                                      password, cluster_instances)
     return wsgi.Result(views.RootCreatedView(root).data(), 200)
开发者ID:Hopebaytech,项目名称:trove,代码行数:10,代码来源:service.py

示例2: root_index

 def root_index(self, req, tenant_id, instance_id, is_cluster):
     """Returns True if root is enabled; False otherwise."""
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='show_root')
     LOG.info(_LI("Getting root enabled for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     is_root_enabled = models.Root.load(context, instance_id)
     return wsgi.Result(views.RootEnabledView(is_root_enabled).data(), 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:10,代码来源:service.py

示例3: instance_root_index

 def instance_root_index(self, req, tenant_id, instance_id):
     LOG.info(_LI("Getting root enabled for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     try:
         is_root_enabled = models.ClusterRoot.load(context, instance_id)
     except exception.UnprocessableEntity:
         raise exception.UnprocessableEntity(
             "Cluster %s is not ready." % instance_id)
     return wsgi.Result(views.RootEnabledView(is_root_enabled).data(), 200)
开发者ID:Hopebaytech,项目名称:trove,代码行数:10,代码来源:service.py

示例4: root_create

 def root_create(self, req, body, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='enable_root')
     LOG.info(_LI("Enabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     user_name = context.user
     password = DefaultRootController._get_password_from_body(body)
     root = models.Root.create(context, instance_id,
                               user_name, password)
     return wsgi.Result(views.RootCreatedView(root).data(), 200)
开发者ID:Hopebaytech,项目名称:trove,代码行数:12,代码来源:service.py

示例5: root_delete

 def root_delete(self, req, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='disable_root')
     LOG.info(_LI("Disabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     is_root_enabled = common_utils.Root.load(context, instance_id)
     if not is_root_enabled:
         raise exception.UserNotFound(uuid="root")
     common_utils.Root.delete(context, instance_id)
     return wsgi.Result(None, 200)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:12,代码来源:service.py

示例6: instance_root_create

 def instance_root_create(self, req, body, instance_id,
                          cluster_instances=None):
     LOG.info(_LI("Enabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     user_name = context.user
     if body:
         password = body['password'] if 'password' in body else None
     else:
         password = None
     root = models.VerticaRoot.create(context, instance_id, user_name,
                                      password, cluster_instances)
     return wsgi.Result(views.RootCreatedView(root).data(), 200)
开发者ID:magictour,项目名称:trove,代码行数:13,代码来源:service.py

示例7: root_create

 def root_create(self, req, body, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='enable_root')
     LOG.info(_LI("Enabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     user_name = context.user
     if body:
         password = body['password'] if 'password' in body else None
     else:
         password = None
     root = models.Root.create(context, instance_id,
                               user_name, password)
     return wsgi.Result(views.RootCreatedView(root).data(), 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:15,代码来源:service.py

示例8: root_delete

 def root_delete(self, req, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='disable_root')
     LOG.info(_LI("Disabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     try:
         found_user = self._find_root_user(context, instance_id)
     except (ValueError, AttributeError) as e:
         raise exception.BadRequest(msg=str(e))
     if not found_user:
         raise exception.UserNotFound(uuid="root")
     models.Root.delete(context, instance_id)
     return wsgi.Result(None, 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:15,代码来源:service.py

示例9: edit

    def edit(self, req, id, body, tenant_id):
        """
        Updates the instance to set or unset one or more attributes.
        """
        LOG.info(_LI("Editing instance for tenant id %s."), tenant_id)
        LOG.debug("req: %s", strutils.mask_password(req))
        LOG.debug("body: %s", strutils.mask_password(body))
        context = req.environ[wsgi.CONTEXT_KEY]

        instance = models.Instance.load(context, id)

        args = {}
        args['detach_replica'] = ('replica_of' in body['instance'] or
                                  'slave_of' in body['instance'])

        if 'name' in body['instance']:
            args['name'] = body['instance']['name']
        if 'configuration' in body['instance']:
            args['configuration_id'] = self._configuration_parse(context, body)
        if 'datastore_version' in body['instance']:
            args['datastore_version'] = body['instance'].get(
                'datastore_version')

        self._modify_instance(context, req, instance, **args)
        return wsgi.Result(None, 202)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:25,代码来源:service.py

示例10: create

    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_LI("Creating a database instance for tenant '%s'"),
                 tenant_id)
        LOG.debug("req : '%s'\n\n", strutils.mask_password(req))
        LOG.debug("body : '%s'\n\n", strutils.mask_password(body))
        context = req.environ[wsgi.CONTEXT_KEY]
        context.notification = notification.DBaaSInstanceCreate(context,
                                                                request=req)
        datastore_args = body['instance'].get('datastore', {})
        datastore, datastore_version = (
            datastore_models.get_datastore_version(**datastore_args))
        image_id = datastore_version.image_id
        name = body['instance']['name']
        flavor_ref = body['instance']['flavorRef']
        flavor_id = utils.get_id_from_href(flavor_ref)

        configuration = self._configuration_parse(context, body)
        databases = populate_validated_databases(
            body['instance'].get('databases', []))
        database_names = [database.get('_name', '') for database in databases]
        users = None
        try:
            users = populate_users(body['instance'].get('users', []),
                                   database_names)
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)

        if 'volume' in body['instance']:
            volume_info = body['instance']['volume']
            volume_size = int(volume_info['size'])
            volume_type = volume_info.get('type')
        else:
            volume_size = None
            volume_type = None

        if 'restorePoint' in body['instance']:
            backupRef = body['instance']['restorePoint']['backupRef']
            backup_id = utils.get_id_from_href(backupRef)
        else:
            backup_id = None

        availability_zone = body['instance'].get('availability_zone')
        nics = body['instance'].get('nics')

        slave_of_id = body['instance'].get('replica_of',
                                           # also check for older name
                                           body['instance'].get('slave_of'))
        replica_count = body['instance'].get('replica_count')
        instance = models.Instance.create(context, name, flavor_id,
                                          image_id, databases, users,
                                          datastore, datastore_version,
                                          volume_size, backup_id,
                                          availability_zone, nics,
                                          configuration, slave_of_id,
                                          replica_count=replica_count,
                                          volume_type=volume_type)

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:60,代码来源:service.py

示例11: delete

    def delete(self, req, tenant_id, instance_id, id):
        LOG.info(_LI("Delete instance '%(id)s'\n"
                     "req : '%(req)s'\n\n") %
                 {"id": instance_id, "req": req})
        context = req.environ[wsgi.CONTEXT_KEY]
        self.authorize_target_action(context, 'user:delete', instance_id)

        database_id = correct_id_with_req(id, req)
        context.notification = notification.DBaaSDatabaseDelete(context,
                                                                request=req)

        client = self.create_guest_client(context, instance_id)
        with StartNotification(context, instance_id=instance_id,
                               dbname=database_id):

            try:
                if self.is_reserved_id(database_id):
                    raise exception.ReservedDatabaseId(name=database_id)

                model = self.find_database(client, database_id)
                if not model:
                    raise exception.DatabaseNotFound(uuid=database_id)

                self.delete_database(client, model)
            except (ValueError, AttributeError) as e:
                raise exception.BadRequest(str(e))

        return wsgi.Result(None, 202)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:28,代码来源:service.py

示例12: update_all

    def update_all(self, req, body, tenant_id, instance_id):
        """Change the password of one or more users."""
        LOG.info(_LI("Updating user password for instance '%(id)s'\n"
                     "req : '%(req)s'\n\n") %
                 {"id": instance_id, "req": strutils.mask_password(req)})
        context = req.environ[wsgi.CONTEXT_KEY]
        self.authorize_target_action(context, 'user:update_all', instance_id)

        context.notification = notification.DBaaSUserChangePassword(
            context, request=req)
        users = body['users']
        usernames = [user['name'] for user in users]
        client = self.create_guest_client(context, instance_id)
        with StartNotification(context, instance_id=instance_id,
                               username=",".join(usernames)):

            try:
                user_models = self.parse_users_from_request(users)
                for model in user_models:
                    user_id = self.get_user_id(model)
                    if self.is_reserved_id(user_id):
                        raise exception.ReservedUserId(name=user_id)
                    if not self.find_user(client, user_id):
                        raise exception.UserNotFound(uuid=user_id)

                self.change_passwords(client, user_models)
            except (ValueError, AttributeError) as e:
                raise exception.BadRequest(str(e))

        return wsgi.Result(None, 202)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:30,代码来源:service.py

示例13: update

    def update(self, req, body, tenant_id, instance_id, id):
        LOG.info(_LI("Updating user attributes for instance '%(id)s'\n"
                     "req : '%(req)s'\n\n") %
                 {"id": instance_id, "req": strutils.mask_password(req)})
        context = req.environ[wsgi.CONTEXT_KEY]
        self.authorize_target_action(context, 'user:update', instance_id)

        user_id = correct_id_with_req(id, req)

        updates = body['user']
        context.notification = notification.DBaaSUserUpdateAttributes(
            context, request=req)
        client = self.create_guest_client(context, instance_id)
        with StartNotification(context, instance_id=instance_id,
                               username=user_id):

            try:
                if self.is_reserved_id(user_id):
                    raise exception.ReservedUserId(name=user_id)

                model = self.find_user(client, user_id)
                if not model:
                    raise exception.UserNotFound(uuid=user_id)

                new_user_id = self.apply_user_updates(model, updates)
                if (new_user_id is not None and
                        self.find_user(client, new_user_id)):
                    raise exception.UserAlreadyExists(name=new_user_id)

                self.update_user(client, user_id, updates)
            except (ValueError, AttributeError) as e:
                raise exception.BadRequest(str(e))

        return wsgi.Result(None, 202)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:34,代码来源:service.py

示例14: enable_root

 def enable_root(self, root_password=None):
     """Resets the root password."""
     LOG.info(_LI("Enabling root."))
     user = models.RootUser()
     user.name = "root"
     user.host = "%"
     user.password = root_password or utils.generate_random_password()
     if not self.is_root_enabled():
         self._create_user(user.name, user.password, 'pseudosuperuser')
     else:
         LOG.debug("Updating %s password." % user.name)
         try:
             out, err = system.exec_vsql_command(
                 self._get_database_password(),
                 system.ALTER_USER_PASSWORD % (user.name, user.password))
             if err:
                 if err.is_warning():
                     LOG.warning(err)
                 else:
                     LOG.error(err)
                     raise RuntimeError(_("Failed to update %s "
                                          "password.") % user.name)
         except exception.ProcessExecutionError:
             LOG.error(_("Failed to update %s password.") % user.name)
             raise RuntimeError(_("Failed to update %s password.")
                                % user.name)
     return user.serialize()
开发者ID:melvinj1123,项目名称:trove,代码行数:27,代码来源:service.py

示例15: action

 def action(self, req, body, tenant_id, id):
     """
     Handles requests that modify existing instances in some manner. Actions
     could include 'resize', 'restart', 'reset_password'
     :param req: http request object
     :param body: deserialized body of the request as a dict
     :param tenant_id: the tenant id for whom owns the instance
     :param id: instance id
     """
     LOG.debug("instance action req : '%s'\n\n", req)
     if not body:
         raise exception.BadRequest(_("Invalid request body."))
     context = req.environ[wsgi.CONTEXT_KEY]
     instance = models.Instance.load(context, id)
     _actions = {
         'restart': self._action_restart,
         'resize': self._action_resize,
         'reset_password': self._action_reset_password,
         'promote_to_replica_source':
         self._action_promote_to_replica_source,
         'eject_replica_source': self._action_eject_replica_source,
     }
     selected_action = None
     action_name = None
     for key in body:
         if key in _actions:
             selected_action = _actions[key]
             action_name = key
     LOG.info(_LI("Performing %(action_name)s action against "
                  "instance %(instance_id)s for tenant '%(tenant_id)s'"),
              {'action_name': action_name, 'instance_id': id,
               'tenant_id': tenant_id})
     return selected_action(instance, body)
开发者ID:magictour,项目名称:trove,代码行数:33,代码来源:service.py


注:本文中的trove.common.i18n._LI函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。