correctly getting the vpc address back
This commit is contained in:
parent
c3e4b5401c
commit
9ae144bad8
@ -300,27 +300,30 @@ class SecurityRule(object):
|
||||
|
||||
|
||||
class SecurityGroup(object):
|
||||
def __init__(self, group_id, name, description):
|
||||
def __init__(self, group_id, name, description, vpc_id=None):
|
||||
self.id = group_id
|
||||
self.name = name
|
||||
self.description = description
|
||||
self.ingress_rules = []
|
||||
self.egress_rules = []
|
||||
self.vpc_id = vpc_id
|
||||
|
||||
|
||||
class SecurityGroupBackend(object):
|
||||
|
||||
def __init__(self):
|
||||
self.groups = {}
|
||||
self.vpc_groups = {}
|
||||
|
||||
super(SecurityGroupBackend, self).__init__()
|
||||
|
||||
def create_security_group(self, name, description, force=False):
|
||||
def create_security_group(self, name, description, vpc_id=None, force=False):
|
||||
group_id = random_security_group_id()
|
||||
if not force:
|
||||
existing_group = self.get_security_group_from_name(name)
|
||||
if existing_group:
|
||||
return None
|
||||
group = SecurityGroup(group_id, name, description)
|
||||
group = SecurityGroup(group_id, name, description, vpc_id=vpc_id)
|
||||
self.groups[group_id] = group
|
||||
return group
|
||||
|
||||
|
@ -31,7 +31,8 @@ class SecurityGroups(object):
|
||||
def create_security_group(self):
|
||||
name = self.querystring.get('GroupName')[0]
|
||||
description = self.querystring.get('GroupDescription')[0]
|
||||
group = ec2_backend.create_security_group(name, description)
|
||||
vpc_id = self.querystring.get("VpcId", [None])[0]
|
||||
group = ec2_backend.create_security_group(name, description, vpc_id=vpc_id)
|
||||
if not group:
|
||||
# There was an exisitng group
|
||||
return "There was an existing security group with name {0}".format(name), dict(status=409)
|
||||
@ -83,7 +84,7 @@ DESCRIBE_SECURITY_GROUPS_RESPONSE = """<DescribeSecurityGroupsResponse xmlns="ht
|
||||
<groupId>{{ group.id }}</groupId>
|
||||
<groupName>{{ group.name }}</groupName>
|
||||
<groupDescription>{{ group.description }}</groupDescription>
|
||||
<vpcId/>
|
||||
<vpcId>{{ group.vpc_id if group.vpc_id != None}}</vpcId>
|
||||
<ipPermissions>
|
||||
{% for rule in group.ingress_rules %}
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user