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

Python utils.generate_random_password函数代码示例

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

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



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

示例1: __init__

    def __init__(self, password=None, *args, **kwargs):
        if password is None:
            password = utils.generate_random_password()

        # TODO(pmalik): Name should really be 'Administrator' instead.
        super(CouchbaseRootUser, self).__init__("root", password=password,
                                                *args, **kwargs)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:7,代码来源:models.py


示例2: enable_root

    def enable_root(cls, root_password=None):
        """Enable access with the sys user and/or
           reset the sys password.
        """
        if root_password:
            sys_pwd = root_password
        else:
            sys_pwd = utils.generate_random_password(password_length=30)

        ora_admin = OracleAdmin()
        databases, marker = ora_admin.list_databases()
        for database in databases:
            oradb = models.OracleSchema.deserialize_schema(database)
            with LocalOracleClient(oradb.name, service=True) as client:
                client.execute('alter user sys identified by "%s"' %
                               sys_pwd)

        oracnf = OracleConfig()
        oracnf.enable_root()
        oracnf.sys_password = sys_pwd
        LOG.debug('enable_root completed')

        user = models.RootUser()
        user.name = "sys"
        user.host = "%"
        user.password = sys_pwd
        return user.serialize()
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:27,代码来源:service.py


示例3: _add_query_routers

 def _add_query_routers(self, query_routers, config_server_ips,
                        admin_password=None):
     """Configure the given query routers for the cluster.
     If this is a new_cluster an admin user will be created with a randomly
     generated password, else the password needs to be retrieved from
     and existing query router.
     """
     LOG.debug('adding new query router(s) %s with config server '
               'ips %s' % ([i.id for i in query_routers],
                           config_server_ips))
     for query_router in query_routers:
         try:
             LOG.debug("calling add_config_servers on query router %s"
                       % query_router.id)
             guest = self.get_guest(query_router)
             guest.add_config_servers(config_server_ips)
             if not admin_password:
                 LOG.debug("creating cluster admin user")
                 admin_password = utils.generate_random_password()
                 guest.create_admin_user(admin_password)
             else:
                 guest.store_admin_password(admin_password)
         except Exception:
             LOG.exception(_("error adding config servers"))
             self.update_statuses_on_failure(self.id)
             return False
     return True
开发者ID:Hopebaytech,项目名称:trove,代码行数:27,代码来源:taskmanager.py


示例4: _create_replication_user

    def _create_replication_user(self):
        replication_user = None
        replication_password = utils.generate_random_password(16)

        mysql_user = models.MySQLUser()
        mysql_user.password = replication_password

        retry_count = 0

        while replication_user is None:
            try:
                mysql_user.name = 'slave_' + str(uuid.uuid4())[:8]
                MySqlAdmin().create_user([mysql_user.serialize()])
                LOG.debug("Trying to create replication user " +
                          mysql_user.name)
                replication_user = {
                    'name': mysql_user.name,
                    'password': replication_password
                }
            except Exception:
                retry_count += 1
                if retry_count > 5:
                    LOG.error(_("Replication user retry count exceeded"))
                    raise

        return replication_user
开发者ID:paramtech,项目名称:tesora-trove,代码行数:26,代码来源:mysql_base.py


示例5: create_database

 def create_database(self, databases):
     """Create the given database(s)."""
     dbName = None
     db_create_failed = []
     LOG.debug("Creating Oracle databases.")
     ora_conf = OracleConfig()
     for database in databases:
         oradb = models.OracleSchema.deserialize_schema(database)
         dbName = oradb.name
         ora_conf.db_name = dbName
         LOG.debug("Creating Oracle database: %s." % dbName)
         try:
             sys_pwd = utils.generate_random_password(password_length=30)
             ora_conf.sys_password = sys_pwd
             run_command(system.CREATE_DB_COMMAND %
                         {'gdbname': dbName, 'sid': dbName,
                          'pswd': sys_pwd, 'db_ram': CONF.get(MANAGER).db_ram_size,
                          'template': CONF.get(MANAGER).template})
             client = LocalOracleClient(sid=dbName, service=True, user_id='sys', password=sys_pwd)
             self._create_admin_user(client)
             self.create_cloud_user_role(database)
         except exception.ProcessExecutionError:
             LOG.exception(_(
                 "There was an error creating database: %s.") % dbName)
             db_create_failed.append(dbName)
             pass
     if len(db_create_failed) > 0:
         LOG.exception(_("Creating the following databases failed: %s.") %
                       db_create_failed)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:29,代码来源:service.py


示例6: _create_admin_user

 def _create_admin_user(self, context):
     """Create an administrative user for Trove.
     Force password encryption.
     """
     password = utils.generate_random_password()
     os_admin = {"_name": self.ADMIN_USER, "_password": password, "_databases": [{"_name": self.ADMIN_USER}]}
     self._create_user(context, os_admin, True, *self.ADMIN_OPTIONS)
开发者ID:magictour,项目名称:trove,代码行数:7,代码来源:users.py


示例7: 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


示例8: _generate_database_password

 def _generate_database_password(self):
     """Generate and write the password to vertica.cnf file."""
     config = ConfigParser.ConfigParser()
     config.add_section('credentials')
     config.set('credentials', 'dbadmin_password',
                utils.generate_random_password())
     self.write_config(config)
开发者ID:magictour,项目名称:trove,代码行数:7,代码来源:service.py


示例9: secure

    def secure(self, config_contents, overrides):
        LOG.info(_("Generating admin password."))
        admin_password = utils.generate_random_password()
        service_base.clear_expired_password()
        engine = sqlalchemy.create_engine("mysql://root:@127.0.0.1:3306",
                                          echo=True)
        with LocalSqlClient(engine) as client:
            self._remove_anonymous_user(client)
            self._create_admin_user(client, admin_password)
        self.stop_db()
        self._reset_configuration(config_contents, admin_password)
        self._apply_user_overrides(overrides)
        self.start_mysql()
        # TODO(cp16net) figure out reason for PXC not updating the password
        try:
            with LocalSqlClient(engine) as client:
                query = text("select Host, User from mysql.user;")
                client.execute(query)
        except Exception:
            LOG.debug('failed to query mysql')
        # creating the admin user after the config files are written because
        # percona pxc was not commiting the grant for the admin user after
        # removing the annon users.
        self._wait_for_mysql_to_be_really_alive(
            CONF.timeout_wait_for_service)
        with LocalSqlClient(engine) as client:
            self._create_admin_user(client, admin_password)
        self.stop_db()

        self._reset_configuration(config_contents, admin_password)
        self._apply_user_overrides(overrides)
        self.start_mysql()
        self._wait_for_mysql_to_be_really_alive(
            CONF.timeout_wait_for_service)
        LOG.debug("MySQL secure complete.")
开发者ID:paramtech,项目名称:tesora-trove,代码行数:35,代码来源:service.py


示例10: secure

    def secure(self):
        """Create the Trove admin user.

        The service should not be running at this point.
        This will enable role-based access control (RBAC) by default.
        """
        if self.status.is_running:
            raise RuntimeError(_("Cannot secure the instance. "
                                 "The service is still running."))

        temp_changeid = 'localhost_auth_bypass'
        self.configuration_manager.apply_system_override(
            {'setParameter': {'enableLocalhostAuthBypass': True}},
            temp_changeid)
        try:
            self.configuration_manager.apply_system_override(
                {'security': {'authorization': 'enabled'}})
            self.start_db(update_db=False)
            password = utils.generate_random_password()
            self.create_admin_user(password)
            LOG.debug("MongoDB secure complete.")
        finally:
            self.configuration_manager.remove_system_override(
                temp_changeid)
            self.stop_db()
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:25,代码来源:service.py


示例11: _generate_root_password

 def _generate_root_password(client):
     """Generate and set a random root password and forget about it."""
     localhost = "localhost"
     uu = sql_query.UpdateUser("root", host=localhost,
                               clear=utils.generate_random_password())
     t = text(str(uu))
     client.execute(t)
开发者ID:zjtheone,项目名称:trove,代码行数:7,代码来源:service.py


示例12: secure

    def secure(self, update_user=None, password=None):
        """Configure the Trove administrative user.
        Update an existing user if given.
        Create a new one using the default database credentials
        otherwise and drop the built-in user when finished.
        """
        LOG.info(_('Configuring Trove superuser.'))

        if password is None:
            password = utils.generate_random_password()

        admin_username = update_user.name if update_user else self._ADMIN_USER
        os_admin = models.CassandraUser(admin_username, password)

        if update_user:
            CassandraAdmin(update_user).alter_user_password(os_admin)
        else:
            cassandra = models.CassandraUser(
                self.default_superuser_name, self.default_superuser_password)
            CassandraAdmin(cassandra)._create_superuser(os_admin)
            CassandraAdmin(os_admin).drop_user(cassandra)

        self._update_admin_credentials(os_admin)

        return os_admin
开发者ID:gongwayne,项目名称:Openstack,代码行数:25,代码来源:service.py


示例13: root

 def root(cls, name=None, password=None, *args, **kwargs):
     if not name:
         name = cls.root_username
     if not password:
         password = utils.generate_random_password()
     user = cls(name, password, *args, **kwargs)
     user.make_root()
     return user
开发者ID:Tesora,项目名称:tesora-trove,代码行数:8,代码来源:models.py


示例14: _mangle_config_command_name

 def _mangle_config_command_name(self):
     """Hide the 'CONFIG' command from the clients by renaming it to a
     random string known only to the guestagent.
     Return the mangled name.
     """
     mangled = utils.generate_random_password()
     self._rename_command('CONFIG', mangled)
     return mangled
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:8,代码来源:service.py


示例15: _secure

 def _secure(self, context):
     # Create a new administrative user for Trove and also
     # disable the built-in superuser.
     self.create_database(context, [{"_name": self.ADMIN_USER}])
     self._create_admin_user(context)
     pgutil.PG_ADMIN = self.ADMIN_USER
     postgres = {"_name": self.PG_BUILTIN_ADMIN, "_password": utils.generate_random_password()}
     self.alter_user(context, postgres, "NOSUPERUSER", "NOLOGIN")
开发者ID:slodha,项目名称:trove,代码行数:8,代码来源:manager.py


示例16: _generate_root_password

 def _generate_root_password(client):
     """Generate and set a random root password and forget about it."""
     localhost = "localhost"
     uu = sql_query.SetPassword(
         models.MySQLUser.root_username, host=localhost,
         new_password=utils.generate_random_password())
     t = text(str(uu))
     client.execute(t)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:8,代码来源:service.py


示例17: __init__

 def __init__(self, password=None):
     super(MySQLRootUser, self).__init__()
     self._name = "root"
     self._host = "%"
     if password is None:
         self._password = utils.generate_random_password()
     else:
         self._password = password
开发者ID:slodha,项目名称:trove,代码行数:8,代码来源:models.py


示例18: __init__

    def __init__(self, password=None, *args, **kwargs):
        if password is None:
            pwd_len = min(self.MAX_PASSWORD_LEN, CONF.default_password_length)
            password = utils.generate_random_password(pwd_len)

        # TODO(pmalik): Name should really be 'Administrator' instead.
        super(CouchbaseRootUser, self).__init__("root", password=password,
                                                *args, **kwargs)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:8,代码来源:models.py


示例19: _create_admin_user

 def _create_admin_user(self, context, databases=None):
     """Create an administrative user for Trove.
     Force password encryption.
     """
     password = utils.generate_random_password()
     os_admin = models.PostgreSQLUser(self.ADMIN_USER, password)
     if databases:
         os_admin.databases.extend([db.serialize() for db in databases])
     self._create_user(context, os_admin, True, *self.ADMIN_OPTIONS)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:9,代码来源:users.py


示例20: enable_root

 def enable_root(self, password=None):
     """Create a user 'root' with role 'root'."""
     if not password:
         LOG.debug('Generating root user password.')
         password = utils.generate_random_password()
     root_user = models.MongoDBUser(name='admin.root', password=password)
     root_user.roles = {'db': 'admin', 'role': 'root'}
     self.create_validated_user(root_user)
     return root_user.serialize()
开发者ID:Hopebaytech,项目名称:trove,代码行数:9,代码来源:service.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.generate_uuid函数代码示例发布时间:2022-05-27
下一篇:
Python utils.execute_with_timeout函数代码示例发布时间: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