• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python i18n._LI函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: index_all_master

 def index_all_master(self, req, tenant_id):
     """Return all instances that has no slave node."""
     LOG.info(_LI("Listing database instances with no slave for tenant '%s'"), tenant_id)
     LOG.debug("req : '%s'\n\n", req)
     context = req.environ[wsgi.CONTEXT_KEY]
     clustered_q = req.GET.get('include_clustered', '').lower()
     include_clustered = clustered_q == 'true'
     servers, marker = models.Instances.load(context, include_clustered)
     view = views.MasterInstancesView(servers, req=req)
     return wsgi.Result(view.data(), 200)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:10,代码来源:service.py


示例17: backups

 def backups(self, req, tenant_id, id):
     """Return all backups for the specified instance."""
     LOG.info(_LI("Listing backups for instance '%s'"),
              id)
     LOG.debug("req : '%s'\n\n", req)
     context = req.environ[wsgi.CONTEXT_KEY]
     backups, marker = backup_model.list_for_instance(context, id)
     view = backup_views.BackupViews(backups)
     paged = pagination.SimplePaginatedDataView(req.url, 'backups', view,
                                                marker)
     return wsgi.Result(paged.data(), 200)
开发者ID:magictour,项目名称:trove,代码行数:11,代码来源:service.py


示例18: delete

 def delete(self, req, tenant_id, id):
     """Delete a single instance."""
     LOG.info(_LI("Deleting database instance '%(instance_id)s' for tenant "
                  "'%(tenant_id)s'"),
              {'instance_id': id, 'tenant_id': tenant_id})
     LOG.debug("req : '%s'\n\n", req)
     # TODO(hub-cap): turn this into middleware
     context = req.environ[wsgi.CONTEXT_KEY]
     instance = models.load_any_instance(context, id)
     instance.delete()
     # TODO(cp16net): need to set the return code correctly
     return wsgi.Result(None, 202)
开发者ID:magictour,项目名称:trove,代码行数:12,代码来源:service.py


示例19: show

    def show(self, req, tenant_id, id):
        """Return a single instance."""
        LOG.info(_LI("Showing database instance '%(instance_id)s' for tenant "
                     "'%(tenant_id)s'"),
                 {'instance_id': id, 'tenant_id': tenant_id})
        LOG.debug("req : '%s'\n\n", req)

        context = req.environ[wsgi.CONTEXT_KEY]
        server = models.load_instance_with_guest(models.DetailInstance,
                                                 context, id)
        return wsgi.Result(views.InstanceDetailView(server,
                                                    req=req).data(), 200)
开发者ID:magictour,项目名称:trove,代码行数:12,代码来源:service.py


示例20: index

 def index(self, req, tenant_id):
     """Return all instances."""
     LOG.info(_LI("Listing database instances for tenant '%s'"), tenant_id)
     LOG.debug("req : '%s'\n\n", req)
     context = req.environ[wsgi.CONTEXT_KEY]
     clustered_q = req.GET.get('include_clustered', '').lower()
     include_clustered = clustered_q == 'true'
     servers, marker = models.Instances.load(context, include_clustered)
     view = views.InstancesView(servers, req=req)
     paged = pagination.SimplePaginatedDataView(req.url, 'instances', view,
                                                marker)
     return wsgi.Result(paged.data(), 200)
开发者ID:magictour,项目名称:trove,代码行数:12,代码来源:service.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python remote.create_cinder_client函数代码示例发布时间:2022-05-27
下一篇:
Python i18n._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap