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


Python VPCConnection.get_all_subnets方法代码示例

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


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

示例1: get_subnet2

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
def get_subnet2(name, region):
    vpc = VPCConnection(aws_access_key_id=access_key, aws_secret_access_key=secret_key)
    subnet = vpc.get_all_subnets(filters={'tag-value': name})
    subnetid = str(subnet)
    subnetid = (subnetid.split(":"))[1] 
    subnetid = subnetid.replace("]", '')
    return subnetid
开发者ID:panxincheng,项目名称:Python,代码行数:9,代码来源:Provision_AWS_v2.py

示例2: get_subnet_vpc_id

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
 def get_subnet_vpc_id(self, subnet_id):
     vpc_conn = VPCConnection()
     subnets = vpc_conn.get_all_subnets(
         filters={'subnet_id': subnet_id})
     if len(subnets) == 1:
         vpc_id = subnets[0].vpc_id
         return vpc_id
     elif len(subnets) == 0:
         raise NoSubnetReturned("No subnets returned")
     else:
         raise Exception("More than 1 subnet returned")
开发者ID:msambol,项目名称:Tyr,代码行数:13,代码来源:server.py

示例3: get_subnet_availability_zone

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
    def get_subnet_availability_zone(self, subnet_id):
        self.log.info(
            "getting zone for subnet {subnet_id}".format(subnet_id=subnet_id))
        vpc_conn = VPCConnection()
        filters = {'subnet-id': subnet_id}
        subnets = vpc_conn.get_all_subnets(filters=filters)

        if len(subnets) == 1:
            availability_zone = subnets[0].availability_zone

            log_message = 'Subnet {subnet_id} is in ' \
                          'availability zone {availability_zone}'
            self.log.info(log_message.format(
                            subnet_id=subnet_id,
                            availability_zone=availability_zone))
            return availability_zone
开发者ID:msambol,项目名称:Tyr,代码行数:18,代码来源:server.py

示例4: create_instance_args

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
def create_instance_args():
    """
    Looks up security group, subnet
    and returns arguments to pass into
    ec2.run_instances() including
    user data
    """

    vpc = VPCConnection()
    subnet = vpc.get_all_subnets(
        filters={
            'tag:aws:cloudformation:stack-name': stack_name,
            'tag:play': args.play}
    )
    if len(subnet) < 1:
        sys.stderr.write("ERROR: Expected at least one subnet, got {}\n".format(
            len(subnet)))
        sys.exit(1)
    subnet_id = subnet[0].id
    vpc_id = subnet[0].vpc_id

    security_group_id = get_instance_sec_group(vpc_id)

    if args.identity:
        config_secure = 'true'
        with open(args.identity) as f:
            identity_contents = f.read()
    else:
        config_secure = 'false'
        identity_contents = "dummy"

    user_data = """#!/bin/bash
set -x
set -e
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
base_dir="/var/tmp/edx-cfg"
extra_vars="$base_dir/extra-vars-$$.yml"
secure_identity="$base_dir/secure-identity"
git_ssh="$base_dir/git_ssh.sh"
configuration_version="{configuration_version}"
configuration_secure_version="{configuration_secure_version}"
configuration_private_version="{configuration_private_version}"
environment="{environment}"
deployment="{deployment}"
play="{play}"
config_secure={config_secure}
git_repo_name="configuration"
git_repo="https://github.com/edx/$git_repo_name"
git_repo_secure="{configuration_secure_repo}"
git_repo_secure_name=$(basename $git_repo_secure .git)
git_repo_private="{configuration_private_repo}"
git_repo_private_name=$(basename $git_repo_private .git)
secure_vars_file={secure_vars_file}
environment_deployment_secure_vars="$base_dir/$git_repo_secure_name/ansible/vars/{environment}-{deployment}.yml"
deployment_secure_vars="$base_dir/$git_repo_secure_name/ansible/vars/{deployment}.yml"
instance_id=\\
$(curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null)
instance_ip=\\
$(curl http://169.254.169.254/latest/meta-data/local-ipv4 2>/dev/null)
instance_type=\\
$(curl http://169.254.169.254/latest/meta-data/instance-type 2>/dev/null)
playbook_dir="$base_dir/{playbook_dir}"

if $config_secure; then
    git_cmd="env GIT_SSH=$git_ssh git"
else
    git_cmd="git"
fi

ANSIBLE_ENABLE_SQS=true
SQS_NAME={queue_name}
SQS_REGION=us-east-1
SQS_MSG_PREFIX="[ $instance_id $instance_ip $environment-$deployment $play ]"
PYTHONUNBUFFERED=1
HIPCHAT_TOKEN={hipchat_token}
HIPCHAT_ROOM={hipchat_room}
HIPCHAT_MSG_PREFIX="$environment-$deployment-$play: "
HIPCHAT_FROM="ansible-$instance_id"
HIPCHAT_MSG_COLOR=$(echo -e "yellow\\ngreen\\npurple\\ngray" | shuf | head -1)
# environment for ansible
export ANSIBLE_ENABLE_SQS SQS_NAME SQS_REGION SQS_MSG_PREFIX PYTHONUNBUFFERED
export HIPCHAT_TOKEN HIPCHAT_ROOM HIPCHAT_MSG_PREFIX HIPCHAT_FROM HIPCHAT_MSG_COLOR

if [[ ! -x /usr/bin/git || ! -x /usr/bin/pip ]]; then
    echo "Installing pkg dependencies"
    /usr/bin/apt-get update
    /usr/bin/apt-get install -y git python-pip python-apt \\
        git-core build-essential python-dev libxml2-dev \\
        libxslt-dev curl --force-yes
fi


rm -rf $base_dir
mkdir -p $base_dir
cd $base_dir

cat << EOF > $git_ssh
#!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no -i "$secure_identity" "\[email protected]"
EOF
#.........这里部分代码省略.........
开发者ID:117111302,项目名称:configuration,代码行数:103,代码来源:abbey.py

示例5: create_instance_args

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
def create_instance_args():
    """
    Looks up security group, subnet
    and returns arguments to pass into
    ec2.run_instances() including
    user data
    """

    vpc = VPCConnection()
    subnet = vpc.get_all_subnets(
        filters={
            'tag:aws:cloudformation:stack-name': stack_name,
            'tag:play': args.play}
    )
    if len(subnet) < 1:
        sys.stderr.write("ERROR: Expected at least one subnet, got {}\n".format(
            len(subnet)))
        sys.exit(1)
    subnet_id = subnet[0].id
    vpc_id = subnet[0].vpc_id

    security_group_id = get_instance_sec_group(vpc_id)

    if args.identity:
        config_secure = 'true'
        with open(args.identity) as f:
            identity_file = f.read()
    else:
        config_secure = 'false'
        identity_file = "dummy"

    user_data = """#!/bin/bash
set -x
set -e
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
base_dir="/var/tmp/edx-cfg"
extra_vars="$base_dir/extra-vars-$$.yml"
secure_identity="$base_dir/secure-identity"
git_ssh="$base_dir/git_ssh.sh"
configuration_version="{configuration_version}"
configuration_secure_version="{configuration_secure_version}"
environment="{environment}"
deployment="{deployment}"
play="{play}"
config_secure={config_secure}
git_repo_name="configuration"
git_repo="https://github.com/edx/$git_repo_name"
git_repo_secure="{configuration_secure_repo}"
git_repo_secure_name="{configuration_secure_repo_basename}"
secure_vars_file="$base_dir/$git_repo_secure_name/{secure_vars}"
instance_id=\\
$(curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null)
instance_ip=\\
$(curl http://169.254.169.254/latest/meta-data/local-ipv4 2>/dev/null)
instance_type=\\
$(curl http://169.254.169.254/latest/meta-data/instance-type 2>/dev/null)
playbook_dir="$base_dir/configuration/playbooks/edx-east"

if $config_secure; then
    git_cmd="env GIT_SSH=$git_ssh git"
else
    git_cmd="git"
fi

ANSIBLE_ENABLE_SQS=true
SQS_NAME={queue_name}
SQS_REGION=us-east-1
SQS_MSG_PREFIX="[ $instance_id $instance_ip $environment-$deployment $play ]"
PYTHONUNBUFFERED=1

# environment for ansible
export ANSIBLE_ENABLE_SQS SQS_NAME SQS_REGION SQS_MSG_PREFIX PYTHONUNBUFFERED

if [[ ! -x /usr/bin/git || ! -x /usr/bin/pip ]]; then
    echo "Installing pkg dependencies"
    /usr/bin/apt-get update
    /usr/bin/apt-get install -y git python-pip python-apt \\
        git-core build-essential python-dev libxml2-dev \\
        libxslt-dev curl --force-yes
fi


rm -rf $base_dir
mkdir -p $base_dir
cd $base_dir

cat << EOF > $git_ssh
#!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no -i "$secure_identity" "\[email protected]"
EOF

chmod 755 $git_ssh

if $config_secure; then
    cat << EOF > $secure_identity
{identity_file}
EOF
fi

cat << EOF >> $extra_vars
#.........这里部分代码省略.........
开发者ID:lg2578,项目名称:configuration,代码行数:103,代码来源:abbey.py

示例6: create_instance_args

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
def create_instance_args():
    """
    Looks up security group, subnet
    and returns arguments to pass into
    ec2.run_instances() including
    user data
    """

    security_group_id = None

    grp_details = ec2.get_all_security_groups()

    for grp in grp_details:
        if grp.name == args.security_group:
            security_group_id = grp.id
            break
    if not security_group_id:
        print "Unable to lookup id for security group {}".format(
            args.security_group)
        sys.exit(1)

    vpc = VPCConnection()
    subnet = vpc.get_all_subnets(
        filters={
            'tag:aws:cloudformation:stack-name': stack_name,
            'tag:Application': args.application}
    )
    if len(subnet) != 1:
        sys.stderr.write("ERROR: Expected 1 admin subnet, got {}\n".format(
            len(subnet)))
        sys.exit(1)
    subnet_id = subnet[0].id

    if args.identity:
        config_secure = 'true'
        with open(args.identity) as f:
            identity_file = f.read()
    else:
        config_secure = 'false'
        identity_file = "dummy"

    user_data = """#!/bin/bash
set -x
set -e
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
base_dir="/var/tmp/edx-cfg"
extra_vars="$base_dir/extra-vars-$$.yml"
secure_identity="$base_dir/secure-identity"
git_ssh="$base_dir/git_ssh.sh"
configuration_version="{configuration_version}"
configuration_secure_version="{configuration_secure_version}"
environment="{environment}"
deployment="{deployment}"
play="{play}"
config_secure={config_secure}
secure_vars_file="$base_dir/configuration-secure\\
/ansible/vars/$environment/$environment-$deployment.yml"
instance_id=\\
$(curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null)
instance_ip=\\
$(curl http://169.254.169.254/latest/meta-data/local-ipv4 2>/dev/null)
instance_type=\\
$(curl http://169.254.169.254/latest/meta-data/instance-type 2>/dev/null)
playbook_dir="$base_dir/configuration/playbooks/edx-east"
git_repo="https://github.com/edx/configuration"
git_repo_secure="[email protected]:edx/configuration-secure"

if $config_secure; then
    git_cmd="env GIT_SSH=$git_ssh git"
else
    git_cmd="git"
fi

ANSIBLE_ENABLE_SQS=true
SQS_NAME={queue_name}
SQS_REGION=us-east-1
SQS_MSG_PREFIX="[ $instance_id $instance_ip $environment-$deployment $play ]"
PYTHONUNBUFFERED=1

# environment for ansible
export ANSIBLE_ENABLE_SQS SQS_NAME SQS_REGION SQS_MSG_PREFIX PYTHONUNBUFFERED

if [[ ! -x /usr/bin/git || ! -x /usr/bin/pip ]]; then
    echo "Installing pkg dependencies"
    /usr/bin/apt-get update
    /usr/bin/apt-get install -y git python-pip python-apt \\
        git-core build-essential python-dev libxml2-dev \\
        libxslt-dev curl --force-yes
fi


rm -rf $base_dir
mkdir -p $base_dir
cd $base_dir

cat << EOF > $git_ssh
#!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no -i "$secure_identity" "\[email protected]"
EOF

#.........这里部分代码省略.........
开发者ID:mitra-varuna,项目名称:configuration,代码行数:103,代码来源:abbey.py

示例7:

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
                    region_id, vpcregionconn.get_all_vpn_gateways()
                )
            )

            if sqsconnection:
                maps['queues'].append(vpn_queues_rm(
                    region_id, sqsconnection.get_all_queues()
                ))
            else:
                log.error(
                    'Cannot initiate SQSConnection to %s region, '
                    'VPN Queues will not be populated for this region',
                    region.name)

            maps['VPC subnets'].append(vpc_subnets_rm(
                region_id, vpcregionconn.get_all_subnets()
            ))

            # Instances
            maps['instances'].append(instances_rm(
                region_id,
                device,
                ec2regionconn.get_only_instances(filters=INSTANCE_FILTERS),
                images,
                instance_states,
                ec2regionconn
            ))

            # Images
            if images:
                maps['images'].append(
开发者ID:zenoss,项目名称:ZenPacks.zenoss.AWS,代码行数:33,代码来源:EC2.py

示例8: VPCConnection

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
#conn = boto.ec2.connect_to_region(aws_access_key_id=configObj['keys'][0]['aws_access_key'],
#                                  aws_secret_access_key=configObj['keys'][0]['aws_secret_key'])

#print conn

regions = boto.ec2.regions(aws_access_key_id=configObj['keys'][0]['aws_access_key'],
                       aws_secret_access_key=configObj['keys'][0]['aws_secret_key'])

print regions

conn = VPCConnection(aws_access_key_id=configObj['keys'][0]['aws_access_key'],
                    aws_secret_access_key=configObj['keys'][0]['aws_secret_key'],
                    region=regions[1],
                    proxy='bne-app-proxy.au.fcl.internal',
                    proxy_port=3128
                    )
filter = [('state','available')]

vpc_status_list = conn.get_all_vpcs(None, filter)

#print type(vpc_status_list)

for vpc in vpc_status_list:
    for tag,value in vpc.tags.items():
        print tag+ " value: "+value
    subnet_filter =  [('vpcId',vpc.id)]
    vpc_subnets_list = conn.get_all_subnets(None, subnet_filter)
    print vpc_subnets_list

开发者ID:monk-ee,项目名称:painofglass,代码行数:30,代码来源:test_vpc.py

示例9: VPCConnection

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
        aws_access_key_id=secrets['aws_access_key_id'],
        aws_secret_access_key=secrets['aws_secret_access_key']
    )
    vpc = VPCConnection(
        aws_access_key_id=secrets['aws_access_key_id'],
        aws_secret_access_key=secrets['aws_secret_access_key'],
        region=conn.region
    )
else:
    conn = connect_to_region(args.region)
    vpc = VPCConnection(region=conn.region)


res = conn.get_all_instances()
instances = reduce(lambda a, b: a + b, [r.instances for r in res])
used_ips = [i.private_ip_address for i in instances]

subnets = vpc.get_all_subnets(subnet_ids=config["subnet_ids"])
blocks = [s.cidr_block for s in subnets]

available_ips = []
for b in blocks:
    # skip first 4 IPs (they are sometimes "reserved") and the last one
    # (broadcast)
    for ip in list(IP(b))[3:-1]:
        if str(ip) not in used_ips:
            available_ips.append(ip)
sample = random.sample(available_ips, args.number)
for ip in sample:
    print ip
开发者ID:jhopkinsmoz,项目名称:build-cloud-tools,代码行数:32,代码来源:free_ips.py

示例10: get_subnet

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
def get_subnet(name, region):
    vpc = VPCConnection(aws_access_key_id=access_key, aws_secret_access_key=secret_key)
    subnet = vpc.get_all_subnets(filters={'tag-value': name})
    return subnet
开发者ID:panxincheng,项目名称:Python,代码行数:6,代码来源:Provision_AWS_v2.py

示例11: str

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
    print "New VPC created: ", aws_vpc_id, "\n"
else:
    # Return 1st object from list
    aws_vpc_id = str(exist_vpc.pop(0))[4:]
    print "Identical CIDR already used. Skipped creation."
    print "Existing VPC ID: {}\n".format(aws_vpc_id)
    # Use existing VPC
    new_vpc = vpcc.get_all_vpcs(filters=[("cidrBlock", VPC_CIDR)])
"""
   # Doesn't work due to VPC dependency
    print "Requested VPC already exists! Will attempt to delete vpc and recreate"
    del_status = vpcc.delete_vpc(aws_vpc_id)
    print "Deletion Completed", del_status
"""

exist_subnet1 = vpcc.get_all_subnets(filters=[("cidrBlock", VPC_SUBNET1)])
exist_subnet2 = vpcc.get_all_subnets(filters=[("cidrBlock", VPC_SUBNET2)])

if not len(exist_subnet1):
    print "Creating new subnet ..."
    new_subnet1 = vpcc.create_subnet(aws_vpc_id, VPC_SUBNET1, AVAIL_ZONE1, dry_run=BOOLEAN_DRYRUN)
    subnet1_id = new_subnet1.id
    print "New subnet 1 ID: {}\n".format(subnet1_id)
else:
    print "Subnet with {} already exists.  Skipped creation".format(VPC_SUBNET1)
    subnet1_id = str(exist_subnet1.pop(0))[7:]
    print "Existing subnet 1 ID: {}\n".format(subnet1_id)

if not len(exist_subnet2):
    print "Creating new subnet2 ..."
    new_subnet2 = vpcc.create_subnet(aws_vpc_id, VPC_SUBNET2, AVAIL_ZONE2, dry_run=BOOLEAN_DRYRUN)
开发者ID:AnthonyWC,项目名称:aws_boto,代码行数:33,代码来源:deploy.py

示例12: process

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
    def process(self, device, results, log):
        log.info(
            'Modeler %s processing data for device %s',
            self.name(), device.id)

        accesskey = getattr(device, 'ec2accesskey', None)
        secretkey = getattr(device, 'ec2secretkey', None)

        old_logger = boto.log.error
        boto.log.error = lambda x: x
        try:
            if not secretkey or not accesskey:
                raise EC2ResponseError('', '', '')
            ec2conn = EC2Connection(accesskey, secretkey)
            s3connection = S3Connection(accesskey, secretkey)
            ec2_regions = ec2conn.get_all_regions()
        except EC2ResponseError:
            log.error('Invalid Keys. '
                      'Check your EC2 Access Key and EC2 Secret Key.')
            return
        finally:
            boto.log.error = old_logger

        maps = collections.OrderedDict([
            ('regions', []),
            ('s3buckets', []),
            ('instance types', []),
            ('zones', []),
            ('VPCs', []),
            ('VPC subnets', []),
            ('VPNGateways', []),
            ('images', []),
            ('instances', []),
            ('volumes', []),
            ('snapshots', []),
            ('queues', []),
            ('elastic_ips', []),
            ('reservations', []),
            ('account', []),
            ('reserved_instances', []),
        ])

        image_filters = []

        region_oms = []
        for region in ec2_regions:
            region_id = prepId(region.name)

            region_oms.append(ObjectMap(data={
                'id': region_id,
                'title': region.name,
            }))

            ec2regionconn = EC2Connection(accesskey, secretkey, region=region)
            vpcregionconn = VPCConnection(accesskey, secretkey, region=region)
            sqsconnection = boto.sqs.connect_to_region(
                region.name,
                aws_access_key_id=accesskey,
                aws_secret_access_key=secretkey
            )
            # Zones
            maps['zones'].append(
                zones_rm(
                    region_id, ec2regionconn.get_all_zones())
            )

            # VPCs
            maps['VPCs'].append(
                vpcs_rm(
                    region_id, vpcregionconn.get_all_vpcs())
            )

            # VPNGateways
            maps['VPNGateways'].append(
                vpn_gateways_rm(
                    region_id, vpcregionconn.get_all_vpn_gateways()
                )
            )

            maps['queues'].append(vpn_queues_rm(
                region_id, sqsconnection.get_all_queues()
            ))

            maps['VPC subnets'].append(vpc_subnets_rm(
                region_id, vpcregionconn.get_all_subnets()
            ))

            # Instances
            maps['instances'].append(instances_rm(
                region_id,
                device,
                ec2regionconn.get_only_instances(filters=INSTANCE_FILTERS),
                image_filters
            ))

            # Images
            if image_filters:
                maps['images'].append(
                    images_rm(region_id, ec2regionconn.get_all_images(
                        image_ids=image_filters))
#.........这里部分代码省略.........
开发者ID:ifosch,项目名称:ZenPacks.zenoss.AWS,代码行数:103,代码来源:EC2.py

示例13: process

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_subnets [as 别名]
    def process(self, device, results, log):
        log.info(
            'Modeler %s processing data for device %s',
            self.name(), device.id)

        accesskey = getattr(device, 'ec2accesskey', None)
        if not accesskey:
            log.error('%s: EC2 access key not set. Not discovering.')
            return

        secretkey = getattr(device, 'ec2secretkey', None)
        if not secretkey:
            log.error('%s: EC2 secret key not set. Not discovering.')
            return

        maps = collections.OrderedDict([
            ('regions', []),
            ('instance types', []),
            ('zones', []),
            ('VPCs', []),
            ('VPC subnets', []),
            ('instances', []),
            ('volumes', []),
            ('account', []),
            ])

        instance_filters = {
            'instance-state-name': [
                'pending',
                'running',
                'shutting-down',
                'stopping',
                'stopped',
                ],
            }

        ec2conn = EC2Connection(accesskey, secretkey)

        region_oms = []
        for region in ec2conn.get_all_regions():
            region_id = prepId(region.name)

            region_oms.append(ObjectMap(data={
                'id': region_id,
                'title': region.name,
                }))

            ec2regionconn = EC2Connection(accesskey, secretkey, region=region)
            vpcregionconn = VPCConnection(accesskey, secretkey, region=region)

            # Zones
            maps['zones'].append(
                zones_rm(
                    region_id,
                    ec2regionconn.get_all_zones()))

            # VPCs
            maps['VPCs'].append(
                vpcs_rm(
                    region_id,
                    vpcregionconn.get_all_vpcs()))

            # VPC Subnets
            maps['VPC subnets'].append(
                vpc_subnets_rm(
                    region_id,
                    vpcregionconn.get_all_subnets()))

            # Instances
            maps['instances'].append(
                instances_rm(
                    region_id,
                    ec2regionconn.get_all_instances(
                        filters=instance_filters)))

            # Volumes
            maps['volumes'].append(
                volumes_rm(
                    region_id,
                    ec2regionconn.get_all_volumes()))

        # Regions
        maps['regions'].append(RelationshipMap(
            relname='regions',
            modname=MODULE_NAME['EC2Region'],
            objmaps=region_oms))

        # Trigger discovery of instance guest devices.
        maps['account'].append(ObjectMap(data={
            'setDiscoverGuests': True,
            }))

        return list(chain.from_iterable(maps.itervalues()))
开发者ID:BoxxyMays,项目名称:ZenPacks.zenoss.AWS,代码行数:95,代码来源:EC2.py


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