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


Python utils.get_name函数代码示例

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


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

示例1: test_get_name

    def test_get_name(self):
        nm = utils.random_name()

        class ObjWithName(object):
            name = nm

        obj = ObjWithName()
        self.assertEqual(utils.get_name(obj), nm)
        self.assertEqual(utils.get_name(obj.name), nm)
        self.assertRaises(exc.MissingName, utils.get_name, object())
开发者ID:naterh,项目名称:pyrax,代码行数:10,代码来源:test_utils.py

示例2: delete_user

 def delete_user(self, user):
     """
     Deletes the specified user. If no user by that name
     exists, no exception will be raised; instead, nothing at all
     is done.
     """
     name = utils.get_name(user)
     self._user_manager.delete(name)
开发者ID:216software,项目名称:pyrax,代码行数:8,代码来源:clouddatabases.py

示例3: delete_database

 def delete_database(self, name_or_obj):
     """
     Deletes the specified database. If no database by that name
     exists, no exception will be raised; instead, nothing at all
     is done.
     """
     name = utils.get_name(name_or_obj)
     self._database_manager.delete(name)
开发者ID:216software,项目名称:pyrax,代码行数:8,代码来源:clouddatabases.py

示例4: _get_db_names

 def _get_db_names(self, dbs, strict=True):
     """
     Accepts a single db (name or object) or a list of dbs, and returns a
     list of database names. If any of the supplied dbs do not exist, a
     NoSuchDatabase exception will be raised, unless you pass strict=False.
     """
     dbs = utils.coerce_string_to_list(dbs)
     db_names = [utils.get_name(db) for db in dbs]
     if strict:
         good_dbs = self.instance.list_databases()
         good_names = [utils.get_name(good_db) for good_db in good_dbs]
         bad_names = [db_name for db_name in db_names
                 if db_name not in good_names]
         if bad_names:
             bad = ", ".join(bad_names)
             raise exc.NoSuchDatabase("The following database(s) were not "
                     "found: %s" % bad)
     return db_names
开发者ID:216software,项目名称:pyrax,代码行数:18,代码来源:clouddatabases.py

示例5: _create_body

 def _create_body(self, name, img=None, cont=None, img_format=None, img_name=None):
     """
     Used to create a new task. Since tasks don't have names, the required
     'name' parameter is used for the type of task: 'import' or 'export'.
     """
     img = utils.get_id(img)
     cont = utils.get_name(cont)
     body = {"type": name}
     if name == "export":
         body["input"] = {"image_uuid": img, "receiving_swift_container": cont}
     else:
         nm = "%s/%s" % (cont, utils.get_name(img))
         body["input"] = {
             "image_properties": {"name": img_name or img},
             "import_from": nm,
             "import_from_format": img_format or DEFAULT_FORMAT,
         }
     return body
开发者ID:coreypobrien,项目名称:pyrax,代码行数:18,代码来源:image.py

示例6: revoke_user_access

    def revoke_user_access(self, user, db_names, strict=True):
        """
        Revokes access to the databases listed in `db_names` for the user.

        If any of the databases do not exist, a NoSuchDatabase exception will
        be raised, unless you specify `strict=False` in the call.
        """
        user = utils.get_name(user)
        db_names = self._get_db_names(db_names, strict=strict)
        bad_names = []
        for db_name in db_names:
            uri = "/%s/%s/databases/%s" % (self.uri_base, user, db_name)
            resp, resp_body = self.api.method_delete(uri)
开发者ID:216software,项目名称:pyrax,代码行数:13,代码来源:clouddatabases.py

示例7: list_user_access

 def list_user_access(self, user):
     """
     Returns a list of all database names for which the specified user
     has access rights.
     """
     user = utils.get_name(user)
     uri = "/%s/%s/databases" % (self.uri_base, user)
     try:
         resp, resp_body = self.api.method_get(uri)
     except exc.NotFound as e:
         raise exc.NoSuchDatabaseUser("User '%s' does not exist." % user)
     dbs = resp_body.get("databases", {})
     return [CloudDatabaseDatabase(self, db) for db in dbs]
开发者ID:216software,项目名称:pyrax,代码行数:13,代码来源:clouddatabases.py

示例8: change_user_password

    def change_user_password(self, user, new_pass):
        """
        Changes the password for the user to the supplied value.

        Returns None upon success; raises PasswordChangeFailed if the call
        does not complete successfully.
        """
        user = utils.get_name(user)
        body = {"users": [{"name": user, "password": new_pass}]}
        uri = "/%s" % self.uri_base
        resp, resp_body = self.api.method_put(uri, body=body)
        if resp.status > 299:
            raise exc.PasswordChangeFailed("Password for '%s' was not changed"
                    % user)
        return None
开发者ID:216software,项目名称:pyrax,代码行数:15,代码来源:clouddatabases.py

示例9: grant_user_access

    def grant_user_access(self, user, db_names, strict=True):
        """
        Gives access to the databases listed in `db_names` to the user. You may
        pass in either a single db or a list of dbs.

        If any of the databases do not exist, a NoSuchDatabase exception will
        be raised, unless you specify `strict=False` in the call.
        """
        user = utils.get_name(user)
        uri = "/%s/%s/databases" % (self.uri_base, user)
        db_names = self._get_db_names(db_names, strict=strict)
        dbs = [{"name": db_name} for db_name in db_names]
        body = {"databases": dbs}
        try:
            resp, resp_body = self.api.method_put(uri, body=body)
        except exc.NotFound as e:
            raise exc.NoSuchDatabaseUser("User '%s' does not exist." % user)
开发者ID:216software,项目名称:pyrax,代码行数:17,代码来源:clouddatabases.py


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