當前位置: 首頁>>代碼示例>>Python>>正文


Python Misc.get_yaml方法代碼示例

本文整理匯總了Python中misc.Misc.get_yaml方法的典型用法代碼示例。如果您正苦於以下問題:Python Misc.get_yaml方法的具體用法?Python Misc.get_yaml怎麽用?Python Misc.get_yaml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在misc.Misc的用法示例。


在下文中一共展示了Misc.get_yaml方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: translate_security_group

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import get_yaml [as 別名]
def translate_security_group(security_group, env_cidr):
    ipranges = Misc.get_yaml(landscape_path="ipranges.yaml")
    ret = []
    for rule in security_group['Properties']['SecurityGroupIngress']:
        if 'CidrIp' in rule:
            logger.debug("We have a CidrIp in the security group")
            if rule['CidrIp'] == "vpc":
                ret.append(change_sg_cidr(rule=rule, iprange=env_cidr))
            elif rule['CidrIp'] == "self":
                print "self"
            elif rule['CidrIp'] in ipranges:
                for iprange in ipranges[rule['CidrIp']]:
                    ret.append(change_sg_cidr(rule=rule, iprange=iprange))
        else:
            ret.append(rule)
    security_group['Properties']['SecurityGroupIngress'] = ret
    logger.debug(msg="Translated security group: %s" % (ret,))
    return security_group
開發者ID:s4mur4i,項目名稱:char-libv2,代碼行數:20,代碼來源:Translater.py

示例2: run_workflow

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import get_yaml [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.get_yaml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。