Merge pull request #242 from djmitche/regionalize_vpcs

use the current ec2 backend, not necessarily us-east-1, for some operations
This commit is contained in:
Steve Pulec 2014-10-23 23:00:43 -04:00
commit 24f6034f25
2 changed files with 6 additions and 8 deletions

View File

@ -2,7 +2,6 @@ from __future__ import unicode_literals
from jinja2 import Template
from moto.core.responses import BaseResponse
from moto.ec2.models import ec2_backend
from moto.ec2.utils import filters_from_querystring
@ -10,19 +9,19 @@ class Subnets(BaseResponse):
def create_subnet(self):
vpc_id = self.querystring.get('VpcId')[0]
cidr_block = self.querystring.get('CidrBlock')[0]
subnet = ec2_backend.create_subnet(vpc_id, cidr_block)
subnet = self.ec2_backend.create_subnet(vpc_id, cidr_block)
template = Template(CREATE_SUBNET_RESPONSE)
return template.render(subnet=subnet)
def delete_subnet(self):
subnet_id = self.querystring.get('SubnetId')[0]
subnet = ec2_backend.delete_subnet(subnet_id)
subnet = self.ec2_backend.delete_subnet(subnet_id)
template = Template(DELETE_SUBNET_RESPONSE)
return template.render(subnet=subnet)
def describe_subnets(self):
filters = filters_from_querystring(self.querystring)
subnets = ec2_backend.get_all_subnets(filters)
subnets = self.ec2_backend.get_all_subnets(filters)
template = Template(DESCRIBE_SUBNETS_RESPONSE)
return template.render(subnets=subnets)

View File

@ -2,27 +2,26 @@ from __future__ import unicode_literals
from jinja2 import Template
from moto.core.responses import BaseResponse
from moto.ec2.models import ec2_backend
from moto.ec2.utils import filters_from_querystring, vpc_ids_from_querystring
class VPCs(BaseResponse):
def create_vpc(self):
cidr_block = self.querystring.get('CidrBlock')[0]
vpc = ec2_backend.create_vpc(cidr_block)
vpc = self.ec2_backend.create_vpc(cidr_block)
template = Template(CREATE_VPC_RESPONSE)
return template.render(vpc=vpc)
def delete_vpc(self):
vpc_id = self.querystring.get('VpcId')[0]
vpc = ec2_backend.delete_vpc(vpc_id)
vpc = self.ec2_backend.delete_vpc(vpc_id)
template = Template(DELETE_VPC_RESPONSE)
return template.render(vpc=vpc)
def describe_vpcs(self):
vpc_ids = vpc_ids_from_querystring(self.querystring)
filters = filters_from_querystring(self.querystring)
vpcs = ec2_backend.get_all_vpcs(vpc_ids=vpc_ids, filters=filters)
vpcs = self.ec2_backend.get_all_vpcs(vpc_ids=vpc_ids, filters=filters)
template = Template(DESCRIBE_VPCS_RESPONSE)
return template.render(vpcs=vpcs)