Merge pull request #1 from behanceops/more-rds2-support
More rds2 support
This commit is contained in:
commit
23ff33b145
@ -339,6 +339,29 @@ class SubnetGroup(object):
|
|||||||
</DBSubnetGroup>""")
|
</DBSubnetGroup>""")
|
||||||
return template.render(subnet_group=self)
|
return template.render(subnet_group=self)
|
||||||
|
|
||||||
|
def to_json(self):
|
||||||
|
template = Template("""{
|
||||||
|
"DBSubnetGroup": {
|
||||||
|
"VpcId": "{{ subnet_group.vpc_id }}",
|
||||||
|
"SubnetGroupStatus": "{{ subnet_group.status }}",
|
||||||
|
"DBSubnetGroupDescription": "{{ subnet_group.description }}",
|
||||||
|
"DBSubnetGroupName": "{{ subnet_group.subnet_name }}",
|
||||||
|
"Subnets": {
|
||||||
|
"Subnet": [
|
||||||
|
{% for subnet in subnet_group.subnets %}{
|
||||||
|
"SubnetStatus": "Active",
|
||||||
|
"SubnetIdentifier": "{{ subnet.id }}",
|
||||||
|
"SubnetAvailabilityZone": {
|
||||||
|
"Name": "{{ subnet.availability_zone }}",
|
||||||
|
"ProvisionedIopsCapable": "false"
|
||||||
|
}
|
||||||
|
}{%- if not loop.last -%},{%- endif -%}{% endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}""")
|
||||||
|
return template.render(subnet_group=self)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
||||||
properties = cloudformation_json['Properties']
|
properties = cloudformation_json['Properties']
|
||||||
|
@ -139,7 +139,6 @@ class RDS2Response(BaseResponse):
|
|||||||
template = self.response_template(AUTHORIZE_SECURITY_GROUP_TEMPLATE)
|
template = self.response_template(AUTHORIZE_SECURITY_GROUP_TEMPLATE)
|
||||||
return template.render(security_group=security_group)
|
return template.render(security_group=security_group)
|
||||||
|
|
||||||
# TODO: Update function to new method
|
|
||||||
def create_dbsubnet_group(self):
|
def create_dbsubnet_group(self):
|
||||||
subnet_name = self._get_param('DBSubnetGroupName')
|
subnet_name = self._get_param('DBSubnetGroupName')
|
||||||
description = self._get_param('DBSubnetGroupDescription')
|
description = self._get_param('DBSubnetGroupDescription')
|
||||||
@ -149,7 +148,6 @@ class RDS2Response(BaseResponse):
|
|||||||
template = self.response_template(CREATE_SUBNET_GROUP_TEMPLATE)
|
template = self.response_template(CREATE_SUBNET_GROUP_TEMPLATE)
|
||||||
return template.render(subnet_group=subnet_group)
|
return template.render(subnet_group=subnet_group)
|
||||||
|
|
||||||
# TODO: Update function to new method
|
|
||||||
def describe_dbsubnet_groups(self):
|
def describe_dbsubnet_groups(self):
|
||||||
subnet_name = self._get_param('DBSubnetGroupName')
|
subnet_name = self._get_param('DBSubnetGroupName')
|
||||||
subnet_groups = self.backend.describe_subnet_groups(subnet_name)
|
subnet_groups = self.backend.describe_subnet_groups(subnet_name)
|
||||||
@ -303,27 +301,28 @@ AUTHORIZE_SECURITY_GROUP_TEMPLATE = """<AuthorizeDBSecurityGroupIngressResponse
|
|||||||
</ResponseMetadata>
|
</ResponseMetadata>
|
||||||
</AuthorizeDBSecurityGroupIngressResponse>"""
|
</AuthorizeDBSecurityGroupIngressResponse>"""
|
||||||
|
|
||||||
CREATE_SUBNET_GROUP_TEMPLATE = """<CreateDBSubnetGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
CREATE_SUBNET_GROUP_TEMPLATE = """{
|
||||||
<CreateDBSubnetGroupResult>
|
"CreateDBSubnetGroupResponse": {
|
||||||
{{ subnet_group.to_xml() }}
|
"CreateDBSubnetGroupResult":
|
||||||
</CreateDBSubnetGroupResult>
|
{{ subnet_group.to_json() }},
|
||||||
<ResponseMetadata>
|
"ResponseMetadata": { "RequestId": "3a401b3f-bb9e-11d3-f4c6-37db295f7674" }
|
||||||
<RequestId>3a401b3f-bb9e-11d3-f4c6-37db295f7674</RequestId>
|
}
|
||||||
</ResponseMetadata>
|
}"""
|
||||||
</CreateDBSubnetGroupResponse>"""
|
|
||||||
|
|
||||||
DESCRIBE_SUBNET_GROUPS_TEMPLATE = """<DescribeDBSubnetGroupsResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
DESCRIBE_SUBNET_GROUPS_TEMPLATE = """{
|
||||||
<DescribeDBSubnetGroupsResult>
|
"DescribeDBSubnetGroupsResponse": {
|
||||||
<DBSubnetGroups>
|
"DescribeDBSubnetGroupsResult": {
|
||||||
|
"DBSubnetGroups": [
|
||||||
{% for subnet_group in subnet_groups %}
|
{% for subnet_group in subnet_groups %}
|
||||||
{{ subnet_group.to_xml() }}
|
{{ subnet_group.to_json() }}{%- if not loop.last -%},{%- endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</DBSubnetGroups>
|
],
|
||||||
</DescribeDBSubnetGroupsResult>
|
"Marker": null
|
||||||
<ResponseMetadata>
|
},
|
||||||
<RequestId>b783db3b-b98c-11d3-fbc7-5c0aad74da7c</RequestId>
|
"ResponseMetadata": { "RequestId": "b783db3b-b98c-11d3-fbc7-5c0aad74da7c" }
|
||||||
</ResponseMetadata>
|
}
|
||||||
</DescribeDBSubnetGroupsResponse>"""
|
}"""
|
||||||
|
|
||||||
|
|
||||||
DELETE_SUBNET_GROUP_TEMPLATE = """<DeleteDBSubnetGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
DELETE_SUBNET_GROUP_TEMPLATE = """<DeleteDBSubnetGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
||||||
<ResponseMetadata>
|
<ResponseMetadata>
|
||||||
|
@ -3,6 +3,7 @@ from .responses import RDS2Response
|
|||||||
|
|
||||||
url_bases = [
|
url_bases = [
|
||||||
"https?://rds.(.+).amazonaws.com",
|
"https?://rds.(.+).amazonaws.com",
|
||||||
|
"https?://rds.amazonaws.com",
|
||||||
]
|
]
|
||||||
|
|
||||||
url_paths = {
|
url_paths = {
|
||||||
|
@ -322,21 +322,31 @@ def test_delete_non_existant_database():
|
|||||||
# list(subnet_group.subnet_ids).should.equal(subnet_ids)
|
# list(subnet_group.subnet_ids).should.equal(subnet_ids)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#@mock_ec2
|
@mock_ec2
|
||||||
#@mock_rds2
|
@mock_rds2
|
||||||
#def test_describe_database_subnet_group():
|
def test_describe_database_subnet_group():
|
||||||
# vpc_conn = boto.vpc.connect_to_region("us-west-2")
|
vpc_conn = boto.vpc.connect_to_region("us-west-2")
|
||||||
# vpc = vpc_conn.create_vpc("10.0.0.0/16")
|
vpc = vpc_conn.create_vpc("10.0.0.0/16")
|
||||||
# subnet = vpc_conn.create_subnet(vpc.id, "10.1.0.0/24")
|
subnet = vpc_conn.create_subnet(vpc.id, "10.1.0.0/24")
|
||||||
#
|
|
||||||
# conn = boto.rds2.connect_to_region("us-west-2")
|
conn = boto.rds2.connect_to_region("us-west-2")
|
||||||
# conn.create_db_subnet_group("db_subnet1", "my db subnet", [subnet.id])
|
conn.create_db_subnet_group("db_subnet1", "my db subnet", [subnet.id])
|
||||||
# conn.create_db_subnet_group("db_subnet2", "my db subnet", [subnet.id])
|
conn.create_db_subnet_group("db_subnet2", "my db subnet", [subnet.id])
|
||||||
#
|
|
||||||
# list(conn.get_all_db_subnet_groups()).should.have.length_of(2)
|
resp = conn.describe_db_subnet_groups()
|
||||||
# list(conn.get_all_db_subnet_groups("db_subnet1")).should.have.length_of(1)
|
groups_resp = resp['DescribeDBSubnetGroupsResponse']
|
||||||
#
|
|
||||||
# conn.get_all_db_subnet_groups.when.called_with("not-a-subnet").should.throw(BotoServerError)
|
subnet_groups = groups_resp['DescribeDBSubnetGroupsResult']['DBSubnetGroups']
|
||||||
|
subnet_groups.should.have.length_of(2)
|
||||||
|
|
||||||
|
subnets = groups_resp['DescribeDBSubnetGroupsResult']['DBSubnetGroups'][0]['DBSubnetGroup']['Subnets']
|
||||||
|
subnets.should.have.length_of(1)
|
||||||
|
|
||||||
|
list(resp).should.have.length_of(1)
|
||||||
|
list(groups_resp).should.have.length_of(2)
|
||||||
|
list(conn.describe_db_subnet_groups("db_subnet1")).should.have.length_of(1)
|
||||||
|
|
||||||
|
conn.describe_db_subnet_groups.when.called_with("not-a-subnet").should.throw(BotoServerError)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#@mock_ec2
|
#@mock_ec2
|
||||||
|
Loading…
Reference in New Issue
Block a user