Added DB Security Group Create/List/Delete/Authorize
This commit is contained in:
parent
eb23980937
commit
8614b50898
3 changed files with 155 additions and 103 deletions
|
|
@ -266,6 +266,8 @@ class SecurityGroup(object):
|
|||
self.ip_ranges = []
|
||||
self.ec2_security_groups = []
|
||||
self.tags = []
|
||||
self.owner_id = '1234567890'
|
||||
self.vpc_id = None
|
||||
|
||||
def to_xml(self):
|
||||
template = Template("""<DBSecurityGroup>
|
||||
|
|
@ -294,6 +296,21 @@ class SecurityGroup(object):
|
|||
</DBSecurityGroup>""")
|
||||
return template.render(security_group=self)
|
||||
|
||||
def to_json(self):
|
||||
template = Template("""{
|
||||
"DBSecurityGroupDescription": "{{ security_group.description }}",
|
||||
"DBSecurityGroupName": "{{ security_group.group_name }}",
|
||||
"EC2SecurityGroups": {{ security_group.ec2_security_groups }},
|
||||
"IPRanges": [{%- for ip in security_group.ip_ranges -%}
|
||||
{%- if loop.index != 1 -%},{%- endif -%}
|
||||
"{{ ip }}"
|
||||
{%- endfor -%}
|
||||
],
|
||||
"OwnerId": "{{ security_group.owner_id }}",
|
||||
"VpcId": "{{ security_group.vpc_id }}"
|
||||
}""")
|
||||
return template.render(security_group=self)
|
||||
|
||||
def authorize_cidr(self, cidr_ip):
|
||||
self.ip_ranges.append(cidr_ip)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue