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


Python boto.cloudformation方法代码示例

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


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

示例1: get_stack_instance_details

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def get_stack_instance_details(stack):
    global ec2
    global elb_conn

    instances_info = \
        ec2.get_only_instances(filters={'tag:aws:cloudformation:stack-id': stack.stack_id})
    instances_health = elb_conn.describe_instance_health(stack.stack_name)

    instances = list()
    for ii in instances_info:
        for ih in instances_health:
            if ih.instance_id == ii.id:
                instance = {'instance_id': ii.id, 'private_ip': ii.private_ip_address,
                            'launch_time': parse_time(ii.launch_time)}

                if ih.state == 'InService':
                    instance['role'] = 'MASTER'
                else:
                    instance['role'] = 'REPLICA'

                instances.append(instance)

    instances.sort(key=lambda k: (k['role'], k['instance_id']))

    return instances 
开发者ID:zalando,项目名称:spilo,代码行数:27,代码来源:spilo.py

示例2: get_stack_name

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def get_stack_name(node_addr, aws_config):
    """Get the name of the CloudFormation stack a node belongs to."""
    import boto.ec2
    conn = boto.ec2.connect_to_region(
        aws_config['ec2_region'],
        aws_access_key_id=aws_config['ec2_access_key'],
        aws_secret_access_key=aws_config['ec2_secret_key'])

    reservations = conn.get_all_reservations()
    for resv in reservations:
        for inst in resv.instances:
            # Non-HA MGTs don't have a tagged interface.
            if inst.private_ip_address == node_addr:
                return inst.tags['aws:cloudformation:stack-name']

            for iface in inst.interfaces:
                iface.update()
                if iface.private_ip_address == node_addr:
                    return inst.tags.get('aws:cloudformation:stack-name') 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:21,代码来源:icel.py

示例3: _get_mgt_ip_addr

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _get_mgt_ip_addr(stack_name, aws_config):
    import boto.ec2
    conn = boto.ec2.connect_to_region(
        aws_config['ec2_region'],
        aws_access_key_id=aws_config['ec2_access_key'],
        aws_secret_access_key=aws_config['ec2_secret_key'])

    reservations = conn.get_all_reservations(
        filters={
            'tag:Name': 'mgt*',
            'tag:aws:cloudformation:stack-name': stack_name,
        }
    )
    for resv in reservations:
        for inst in resv.instances:
            for iface in inst.interfaces:
                iface.update()
                if iface.tags.get('lustre:server_role') == 'mgt':
                    # HA MGTs have a tagged interface.
                    return iface.private_ip_address

            # Non-HA MGTs don't.
            return inst.private_ip_address

    return None 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:27,代码来源:icel.py

示例4: _wait_for_stack

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _wait_for_stack(self, stack_id):
        """
        Wait for stack completion.
        """
        logging.warning("waiting for cloudformation completion")
        stacks = self.cf.describe_stacks(stack_id)
        for stack in stacks:
            while(True):
                try:
                    if stack.stack_status == "CREATE_COMPLETE":
                        return True
                    elif stack.stack_status == "CREATE_FAILED":
                        logging.warning("cloudformation FAILED")
                        return False
                    else:
                        stack.update()
                        time.sleep(4)
                except:
                    logging.error("could not fetch stack status (%s)" % str(stack_id))
                    return False 
开发者ID:jhorey,项目名称:ferry,代码行数:22,代码来源:awslauncher.py

示例5: get_item

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def get_item(self, resource_type, key):
        conn = boto.cloudformation.connect_to_region(self.region)
        stack = conn.describe_stacks(stack_name_or_id=self.stack_name)[0]
        if resource_type in ['parameter', 'output']:
            attr = "{0}s".format(resource_type)
            return [item.value for item in
                    getattr(stack, attr) if item.key == key]
        elif resource_type == 'resource_id':
            return [stack.describe_resources(key)[0].physical_resource_id]
        else:
            raise errors.AnsibleError(
                "unknown resource type {0}".format(resource_type)) 
开发者ID:mesosphere-backup,项目名称:dcos-bootstrap,代码行数:14,代码来源:cloudformation.py

示例6: testenv

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def testenv(request):
    testenv = dict()
    testenv['cf_conn'] = boto.cloudformation.connect_to_region(region_for_tests)
    testenv['cft'] = request.param
    return testenv 
开发者ID:f5devcentral,项目名称:aws-deployments,代码行数:7,代码来源:test_cfts.py

示例7: _get_cf_connection

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _get_cf_connection(self):
        return self._get_connection(cloudformation) 
开发者ID:Yelp,项目名称:mycroft,代码行数:4,代码来源:create_mycroft.py

示例8: _delete_stack

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _delete_stack(stack_name, cluster_config):
    """Delete a Lustre CloudFormation stack.
    """
    import boto.cloudformation
    cf_conn = boto.cloudformation.connect_to_region(
        cluster_config['cloud']['ec2_region'],
        aws_access_key_id=cluster_config['cloud']['ec2_access_key'],
        aws_secret_access_key=cluster_config['cloud']['ec2_secret_key'])
    cf_conn.delete_stack(stack_name)
    sys.stdout.write('Waiting for stack to delete (this will take a few minutes)')
    sys.stdout.flush()
    _wait_for_stack(stack_name, 'DELETE_COMPLETE',
                    15 * 60, cluster_config['cloud'])

# The awscli(1) equivalent of this is:
#
# aws cloudformation create-stack --stack-name STACK_NAME \
#   --template-url TEMPLATE_URL \
#   --capabilities CAPABILITY_IAM \
#   --parameters \
#       ParameterKey=FsName,ParameterValue=scratch \
#       ParameterKey=AccessFrom,ParameterValue=0.0.0.0/0 \
#       ParameterKey=VpcId,ParameterValue=vpc-c0ffee \
#       ParameterKey=VpcPrivateCIDR,ParameterValue=a.b.c.d/e \
#       ParameterKey=VpcPublicSubnetId,ParameterValue=subnet-deadbeef \
#       ParameterKey=KeyName,ParameterValue=keypair@example.com \
#       ParameterKey=HTTPFrom,ParameterValue=0.0.0.0/0 \
#       ParameterKey=SSHFrom,ParameterValue=0.0.0.0/0 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:30,代码来源:icel.py

示例9: _wait_for_stack

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _wait_for_stack(stack_name, desired_state, wait_for, aws_config):
    import boto.cloudformation
    conn = boto.cloudformation.connect_to_region(
        aws_config['ec2_region'],
        aws_access_key_id=aws_config['ec2_access_key'],
        aws_secret_access_key=aws_config['ec2_secret_key'])

    stack = conn.describe_stacks(stack_name)[0]

    interval_length = 10
    for interval in xrange(wait_for / interval_length):
        stack.update()
        status = stack.stack_status

        if status == desired_state:
            print()
            return
        elif status.endswith('_IN_PROGRESS'):
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(interval_length)
            continue
        else:
            failed_events = [
                event
                for event
                 in stack.describe_events()
                 if event.resource_status.endswith('_FAILED')
            ]
            failed_descr = ','.join([
                '{}: {}'.format(
                    event.logical_resource_id, event.resource_status_reason)
                for event
                 in failed_events
            ])
            print()
            raise Exception(
                'Stack {} did not launch successfully: {}: {}'.format(
                stack_name, status, failed_descr))
    print() 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:42,代码来源:icel.py

示例10: _get_stack_param

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _get_stack_param(stack_name, param_name, aws_config):
    import boto.cloudformation
    conn = boto.cloudformation.connect_to_region(
        aws_config['ec2_region'],
        aws_access_key_id=aws_config['ec2_access_key'],
        aws_secret_access_key=aws_config['ec2_secret_key'])

    icel_stack = conn.describe_stacks(stack_name)[0]
    return [
        param.value
        for param
         in icel_stack.parameters
         if param.key == param_name
    ] 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:16,代码来源:icel.py

示例11: _init_aws_clients

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _init_aws_clients(self):
        # We will need to use both EC2 and VPC. 
        self.ec2 = boto.ec2.connect_to_region(self.default_dc,
                                              aws_access_key_id = self.aws_access_key,
                                              aws_secret_access_key = self.aws_secret_key)
        self.vpc = boto.vpc.VPCConnection(aws_access_key_id = self.aws_access_key,
                                          aws_secret_access_key = self.aws_secret_key)
        self.cf = boto.cloudformation.connect_to_region(self.default_dc, 
                                                        aws_access_key_id = self.aws_access_key,
                                                        aws_secret_access_key = self.aws_secret_key) 
开发者ID:jhorey,项目名称:ferry,代码行数:12,代码来源:awslauncher.py

示例12: __init__

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def __init__(self, region):
        self.region = region
        # TODO: Allow configuring these on the command line
        self.access_key_id = os.environ.get('BALANCED_AWS_ACCESS_KEY_ID', os.environ.get('AWS_ACCESS_KEY_ID'))
        self.secret_access_key = os.environ.get('BALANCED_AWS_SECRET_ACCESS_KEY', os.environ.get('AWS_SECRET_ACCESS_KEY'))
        # Connect to the right CloudFormation region
        for r in boto.cloudformation.regions():
            if r.name == self.region:
                break
        else:
            raise ValueError('Unknown region {0}'.format(region))
        self.cfn = boto.connect_cloudformation(self.access_key_id, self.secret_access_key, region=r)
        self.s3 = boto.connect_s3(self.access_key_id, self.secret_access_key)
        # Load and render all templates
        self.templates = self._load_templates() 
开发者ID:coderanger,项目名称:brix,代码行数:17,代码来源:__init__.py

示例13: _create_stack

# 需要导入模块: import boto [as 别名]
# 或者: from boto import cloudformation [as 别名]
def _create_stack(stack_name, template_url, lustre_net, cluster,
                  cluster_config, recreate):
    import boto
    import boto.cloudformation
    conn = boto.connect_vpc(
        aws_access_key_id=cluster_config['cloud']['ec2_access_key'],
        aws_secret_access_key=cluster_config['cloud']['ec2_secret_key'])

    cf_conn = boto.cloudformation.connect_to_region(
        cluster_config['cloud']['ec2_region'],
        aws_access_key_id=cluster_config['cloud']['ec2_access_key'],
        aws_secret_access_key=cluster_config['cloud']['ec2_secret_key'])

    for stack in cf_conn.list_stacks('CREATE_COMPLETE'):
        if stack.stack_name == stack_name:
            if recreate:
                _delete_stack(stack_name, cluster_config)
            else:
                raise Exception('Stack {} already exists.'.format(stack_name))

    for vpc in conn.get_all_vpcs():
        if cluster_config['cloud']['vpc'] in [vpc.tags.get('Name'), vpc.id]:
            break
    else:
        raise Exception('Elasticluster must be running in '
                        'an AWS VPC to start an ICEL stack.')

    public_subnet_name = '{}_cluster'.format(cluster)
    public_subnets = conn.get_all_subnets(
        filters={'vpcId': vpc.id, 'tag:Name': public_subnet_name})
    if len(public_subnets) > 1:
        raise Exception(
            'More than one subnet named {} exists in VPC {}/{}'.format(
                public_subnet_name, vpc.id, vpc.tags.get('Name')))
    if len(public_subnets) == 0:
        raise Exception(
            'A subnet named {} does not exist in VPC {}/{}'.format(
                public_subnet_name, vpc.id, vpc.tags.get('Name')))
    public_subnet = public_subnets[0]

    if not lustre_net:
        vpc_net = vpc.cidr_block.split('/')[0]
        vpc_net_int = struct.unpack('>L', socket.inet_aton(vpc_net))[0]
        lustre_net = socket.inet_ntoa(struct.pack('>L', vpc_net_int + 256))
        lustre_net = '{}/24'.format(lustre_net)

    aws_config = cluster_config["cloud"]
    cf_conn.create_stack(stack_name,
        template_url=template_url,
        capabilities=['CAPABILITY_IAM'],
        parameters=(
            ('FsName', 'scratch'),
            ('AccessFrom', vpc.cidr_block),
            ('NATInstanceType', "m3.medium" if aws_config["ec2_region"] == "us-east-1" else "m1.small"),
            ('VpcId', vpc.id),
            ('VpcPrivateCIDR', lustre_net),
            ('VpcPublicSubnetId', public_subnet.id),
            ('KeyName', cluster_config['login']['user_key_name']),
            ('HTTPFrom', '0.0.0.0/0'),
            ('SSHFrom', '0.0.0.0/0'),
        )) 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:63,代码来源:icel.py


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