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


Python Misc.generate_password方法代码示例

本文整理汇总了Python中misc.Misc.generate_password方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.generate_password方法的具体用法?Python Misc.generate_password怎么用?Python Misc.generate_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misc.Misc的用法示例。


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

示例1: run_workflow

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import generate_password [as 别名]
    def run_workflow(self):
        from misc import Misc
        from core.awsrequests import awsrequests
        AWSreq = awsrequests(session=self.account['session'])
        region = self.account['cli_arguments']['region_name']
        print ""
        print "Step %s: Creating ec2 keys" % (self.increment_step(),)
        if not Misc.confirm("Has the keys for all envs been created with syntax default-env syntax?", resp=True):
            exit(1)

        print ""
        print "Step %s: Creating bucket for cloudformation" % (self.increment_step(),)
        if Misc.confirm("Should we create the s3 bucket for cloudformation?", resp=True):
            bucket_name = raw_input("What should the bucket name be (ex: xively-devops-templates-dr ): ")
            AWSreq.create_s3_bucket(name=bucket_name, location=region)
        else:
            print "Assuming bucket is already created"
            bucket_name = raw_input("What is the bucket name?")

        print ""
        print "Step %s: Upload xively_cloudformation repo to the s3 bucket" % (self.increment_step(),)
        while not Misc.confirm("Is the upload finished?", resp=False):
            print "Finish upload before continue"

        print ""
        print "Step %s: Run cloudformation template for infrastructure?" % (self.increment_step(),)
        if Misc.confirm("Should we run the cloudformation template", resp=False):
            # FIXME test if works
            cloudformation_template_name = raw_input(
                "What is the name of template to run (ex. VPC_dr_account.template ): ")
            url = "https://s3.amazonaws.com/" + bucket_name + "/" + cloudformation_template_name
            awsrequests.create_cloudformation_stack(stackname="vpc-infrastructure", templateurl=url)
        else:
            print "Assuming the stack has already been run."

        print ""
        print "Step %s: Run cloudformation template for users base" % (self.increment_step(),)
        if Misc.confirm("Should we run the cloudformation template?", resp=False):
            # FIXME test if works
            cloudformation_template_name = raw_input(
                "What is the name of template to run (ex. prod_account_iam.template ): ")
            url = "https://s3.amazonaws.com/" + bucket_name + "/" + cloudformation_template_name
            awsrequests.create_cloudformation_stack(stackname="devops-users", templateurl=url)
        else:
            print "Assuming the stack has already been run."
        devops_groupname = raw_input("Name of the generated devops group? ")

        print ""
        print "Step %s: Start amon.py to deploy to environement" % (self.increment_step(),)
        while not Misc.confirm("Is the packer generation started", resp=False):
            print "Start before we continue"

        print ""
        print "Step %s: Creating devops users" % (self.increment_step(),)
        devops_yaml = Misc.get_yaml(yamlfile="devops_users.yaml")
        for user in devops_yaml['users']:
            print "Checking user %s" % (user,)
            create_password = True
            if not AWSreq.iam_user_exists(username=user):
                print "Creating user %s" % (user,)
                AWSreq.create_iam_user(username=user, dryrun=False, path="/")
            else:
                login_profile = AWSreq.get_login_profile(username=user)
                if login_profile is not None:
                    create_password = False
            if create_password:
                user_password = Misc.generate_password(size=10)
                AWSreq.create_iam_login_profile(username=user, password=user_password)
                print "Username: %s generated password is: %s" % (user, user_password)
            user_groups = AWSreq.iam_user_groups(username=user)
            if devops_groupname not in user_groups[user]:
                print "Need to add to group"
                AWSreq.add_iam_user_to_group(username=user, groupname=devops_groupname)
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:75,代码来源:drone.py


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