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


Python VPCConnection.create_vpc方法代码示例

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


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

示例1: TestRoute53PrivateZone

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
class TestRoute53PrivateZone(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        time_str = str(int(time.time()))
        self.route53 = Route53Connection()
        self.base_domain = 'boto-private-zone-test-%s.com' % time_str
        self.vpc = VPCConnection()
        self.test_vpc = self.vpc.create_vpc(cidr_block='10.11.0.0/16')
        # tag the vpc to make it easily identifiable if things go spang
        self.test_vpc.add_tag("Name", self.base_domain)
        self.zone = self.route53.get_zone(self.base_domain)
        if self.zone is not None:
            self.zone.delete()

    def test_create_private_zone(self):
        self.zone = self.route53.create_hosted_zone(self.base_domain,
                                                    private_zone=True,
                                                    vpc_id=self.test_vpc.id,
                                                    vpc_region='us-east-1')

    @classmethod
    def tearDownClass(self):
        if self.zone is not None:
            self.zone.delete()
        self.test_vpc.delete()
开发者ID:10sr,项目名称:hue,代码行数:27,代码来源:test_zone.py

示例2: _configure_environment

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
    def _configure_environment(self):
        """Create a new disco style environment VPC"""
        vpc_cidr = self.get_config("vpc_cidr")

        # Create VPC
        vpc_conn = VPCConnection()
        self.vpc = vpc_conn.create_vpc(self.get_config("vpc_cidr"))
        keep_trying(300, self.vpc.add_tag, "Name", self.environment_name)
        keep_trying(300, self.vpc.add_tag, "type", self.environment_type)
        logging.debug("vpc: %s", self.vpc)

        dhcp_options = self._configure_dhcp()
        self.vpc.connection.associate_dhcp_options(dhcp_options.id, self.vpc.id)

        # Enable DNS
        vpc_conn.modify_vpc_attribute(self.vpc.id, enable_dns_support=True)
        vpc_conn.modify_vpc_attribute(self.vpc.id, enable_dns_hostnames=True)

        # Create metanetworks (subnets, route_tables and security groups)
        for network in self.networks.itervalues():
            network.create()

        # Configure security group rules
        for network in self.networks.values():
            self._add_sg_rules(network)

        # Set up security group rules
        self._open_customer_ports()

        # Allow ICMP (ping, traceroute & etc) and DNS traffic for all subnets
        for network in self.networks.itervalues():
            self.vpc.connection.authorize_security_group(
                group_id=network.security_group.id,
                ip_protocol="icmp",
                from_port=-1,
                to_port=-1,
                cidr_ip=vpc_cidr
            )
            self.vpc.connection.authorize_security_group(
                group_id=network.security_group.id,
                ip_protocol="udp",
                from_port=53,
                to_port=53,
                cidr_ip=vpc_cidr
            )

        # Setup internet gateway
        internet_gateway = self.vpc.connection.create_internet_gateway()
        self.vpc.connection.attach_internet_gateway(internet_gateway.id, self.vpc.id)
        logging.debug("internet_gateway: %s", internet_gateway)
        self._add_igw_routes(internet_gateway)

        self._attach_vgw()
        self.configure_notifications()
        DiscoVPC.create_peering_connections(DiscoVPC.parse_peerings_config(self.vpc.id))
        self.rds.update_all_clusters_in_vpc()
开发者ID:Angakkuit,项目名称:asiaq-aws,代码行数:58,代码来源:disco_vpc.py

示例3: test_db_subnet_group

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
    def test_db_subnet_group(self):
        vpc_api  = VPCConnection()
        rds_api  = RDSConnection()
        vpc      = vpc_api.create_vpc('10.0.0.0/16')

        az_list = vpc_api.get_all_zones(filters={'state':'available'})
        subnet = list()
        n      = 0;
        for az in az_list:
            try:
                subnet.append(vpc_api.create_subnet(vpc.id, '10.0.'+str(n)+'.0/24',availability_zone=az.name))
                n = n+1
            except:
                pass

        grp_name     = 'db_subnet_group'+str(int(time.time()))
        subnet_group = rds_api.create_db_subnet_group(grp_name, grp_name, [subnet[0].id,subnet[1].id])
        if not _is_ok(subnet_group, vpc.id, grp_name, [subnet[0].id,subnet[1].id]):
            raise Exception("create_db_subnet_group returned bad values")

        rds_api.modify_db_subnet_group(grp_name, description='new description')
        subnet_grps = rds_api.get_all_db_subnet_groups(name=grp_name)
        if not _is_ok(subnet_grps[0], vpc.id, 'new description', [subnet[0].id,subnet[1].id]):
            raise Exception("modifying the subnet group desciption returned bad values")

        rds_api.modify_db_subnet_group(grp_name, subnet_ids=[subnet[1].id,subnet[2].id])
        subnet_grps = rds_api.get_all_db_subnet_groups(name=grp_name)
        if not _is_ok(subnet_grps[0], vpc.id, 'new description', [subnet[1].id,subnet[2].id]):
            raise Exception("modifying the subnet group subnets returned bad values")

        rds_api.delete_db_subnet_group(subnet_group.name)
        try:
            rds_api.get_all_db_subnet_groups(name=grp_name)
            raise Exception(subnet_group.name+" still accessible after delete_db_subnet_group")
        except:
            pass
            
        while n > 0:
            n = n-1
            vpc_api.delete_subnet(subnet[n].id)
        vpc_api.delete_vpc(vpc.id)
开发者ID:10sr,项目名称:hue,代码行数:43,代码来源:test_db_subnet_group.py

示例4: raw_input

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
Press 'Enter' when finished"
VPC_CIDR = raw_input()

print "Type the Name for VPC (to use as Tag), Press 'Enter' when finished"
VPC_NAME = raw_input()
"""


# boto.set_stream_logger("Stratus")
print "Boto Version: ", boto.Version, "\n"
# print boto.rds2.regions()

exist_vpc = vpcc.get_all_vpcs(filters=[("cidrBlock", VPC_CIDR)])

if not len(exist_vpc):
    new_vpc = vpcc.create_vpc(cidr_block=VPC_CIDR, instance_tenancy=VPC_TENANCY, dry_run=BOOLEAN_DRYRUN)
    aws_vpc_id = new_vpc.id
    print "No existing VPC"
    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
开发者ID:AnthonyWC,项目名称:aws_boto,代码行数:33,代码来源:deploy.py

示例5: VPCConnection

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
import boto
import boto.ec2
from boto.vpc import VPCConnection
import time

cloud_network		= '10.1.0.0/16'
blue_subnet 		= '10.1.0.0/24'
green_subnet 		= '10.1.1.0/24'
generic_linux_image	= 'ami-a250ecca'
nat_linux_image		= 'ami-184dc970'

connection			= VPCConnection()
private_cloud 		= connection.create_vpc(cloud_network)

time.sleep(2) #fix race condition later
private_cloud.add_tag('Name', 'virtual-private-cloud')
print ("created vpc", private_cloud.id)

private_subnet = connection.create_subnet(private_cloud.id, green_subnet)
time.sleep(2) #fix race condition later
private_subnet.add_tag('Name', 'green_subnet')
public_subnet = connection.create_subnet(private_cloud.id, blue_subnet)
time.sleep(2)
public_subnet.add_tag('Name', 'blue_subnet')
print "created public and private subnets"

igw = connection.create_internet_gateway()
connection.attach_internet_gateway(igw.id, private_cloud.id)

print "created and attached internet gateway"
开发者ID:kaiho,项目名称:awstests,代码行数:32,代码来源:create-environment.py

示例6: create_vpc

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
def create_vpc(region, vpc_cidr):
    ec2region = get_region(region)
    conn = VPCConnection(region=ec2region)
    return conn.create_vpc(vpc_cidr)
开发者ID:syokenz,项目名称:aws-scripts,代码行数:6,代码来源:vpc.py

示例7: create_security_group

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import create_vpc [as 别名]
def create_security_group(ec2_conn,vpc_id,security_group_name):
	        groups = ec2_conn.get_all_security_groups()
		for group in groups :
			if group.name == security_group_name :
				return group
		web = ec2_conn.create_security_group(security_group_name,vpc_id=vpc_id,description='ABC Talks Group')
		web.authorize('tcp',8080,8080,'0.0.0.0/0')
		return web
def create_network_interface(ec2_conn,domain='vpc',public=False,subnet=None,groups=None,description=None):
	elastic_network_interface = ec2_conn.create_network_interface(subnet,groups=groups,description=description)
	if public:
		elastic_ip_address = ec2_conn.allocate_address(domain=domain)
		associated_address = ec2_conn.associate_address(allocation_id=elastic_ip_address.allocation_id,network_interface_id=elastic_network_interface.id)
	return elastic_netowrk_interface 
vpc_connection = VPCConnection(aws_access_key_id='',aws_secret_access_key='')
vpc = vpc_connection.create_vpc('10.0.0.0/16')
print vpc.id
print vpc.state
time.sleep(60)
print vpc.state
subnet = vpc_connection.create_subnet(vpc.id,'10.0.0.0/25')
print subnet.state
print subnet.available_ip_address_count
ec2_conn = ec2.connect_to_region('us-east-1',aws_access_key_id='',aws_secret_access_key='')

web = create_security_group(ec2_conn,vpc.id,'abctalks1')
#address = address.Address(connection=ec2_conn,instance_id=ec2_instance.instances[0].id)
print address
network_interface = create_network_interface(ec2_conn,public=True,subnet=subnet,groups=[web.id],description='Storm Cluster')
ec2_instance = create_ec2_instance(ec2_conn,'ami-d05e75b8','abctalks',get_user_data(),web.id,subnet.id,network_interface)
开发者ID:ctaram,项目名称:AWS_Basics,代码行数:32,代码来源:vpn.py


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