Implementing RDS Snapshots
This commit is contained in:
parent
8956151e07
commit
63f01039c3
4 changed files with 221 additions and 2 deletions
|
|
@ -39,7 +39,7 @@ class RDS2Response(BaseResponse):
|
|||
"region": self.region,
|
||||
"security_groups": self._get_multi_param('DBSecurityGroups.DBSecurityGroupName'),
|
||||
"storage_encrypted": self._get_param("StorageEncrypted"),
|
||||
"storage_type": self._get_param("StorageType"),
|
||||
"storage_type": self._get_param("StorageType", 'standard'),
|
||||
# VpcSecurityGroupIds.member.N
|
||||
"tags": list(),
|
||||
}
|
||||
|
|
@ -150,6 +150,27 @@ class RDS2Response(BaseResponse):
|
|||
template = self.response_template(REBOOT_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def create_db_snapshot(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
db_snapshot_identifier = self._get_param('DBSnapshotIdentifier')
|
||||
tags = self._get_param('Tags', [])
|
||||
snapshot = self.backend.create_snapshot(db_instance_identifier, db_snapshot_identifier, tags)
|
||||
template = self.response_template(CREATE_SNAPSHOT_TEMPLATE)
|
||||
return template.render(snapshot=snapshot)
|
||||
|
||||
def describe_db_snapshots(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
db_snapshot_identifier = self._get_param('DBSnapshotIdentifier')
|
||||
snapshots = self.backend.describe_snapshots(db_instance_identifier, db_snapshot_identifier)
|
||||
template = self.response_template(DESCRIBE_SNAPSHOTS_TEMPLATE)
|
||||
return template.render(snapshots=snapshots)
|
||||
|
||||
def delete_db_snapshot(self):
|
||||
db_snapshot_identifier = self._get_param('DBSnapshotIdentifier')
|
||||
snapshot = self.backend.delete_snapshot(db_snapshot_identifier)
|
||||
template = self.response_template(DELETE_SNAPSHOT_TEMPLATE)
|
||||
return template.render(snapshot=snapshot)
|
||||
|
||||
def list_tags_for_resource(self):
|
||||
arn = self._get_param('ResourceName')
|
||||
template = self.response_template(LIST_TAGS_FOR_RESOURCE_TEMPLATE)
|
||||
|
|
@ -397,6 +418,42 @@ DELETE_DATABASE_TEMPLATE = """<DeleteDBInstanceResponse xmlns="http://rds.amazon
|
|||
</ResponseMetadata>
|
||||
</DeleteDBInstanceResponse>"""
|
||||
|
||||
CREATE_SNAPSHOT_TEMPLATE = """<CreateDBSnapshotResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
||||
<CreateDBSnapshotResult>
|
||||
{{ snapshot.to_xml() }}
|
||||
</CreateDBSnapshotResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>523e3218-afc7-11c3-90f5-f90431260ab4</RequestId>
|
||||
</ResponseMetadata>
|
||||
</CreateDBSnapshotResponse>
|
||||
"""
|
||||
|
||||
DESCRIBE_SNAPSHOTS_TEMPLATE = """<DescribeDBSnapshotsResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
||||
<DescribeDBSnapshotsResult>
|
||||
<DBSnapshots>
|
||||
{%- for snapshot in snapshots -%}
|
||||
{{ snapshot.to_xml() }}
|
||||
{%- endfor -%}
|
||||
</DBSnapshots>
|
||||
{% if marker %}
|
||||
<Marker>{{ marker }}</Marker>
|
||||
{% endif %}
|
||||
</DescribeDBSnapshotsResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>523e3218-afc7-11c3-90f5-f90431260ab4</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBSnapshotsResponse>"""
|
||||
|
||||
DELETE_SNAPSHOT_TEMPLATE = """<DeleteDBSnapshotResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
||||
<DeleteDBSnapshotResult>
|
||||
{{ snapshot.to_xml() }}
|
||||
</DeleteDBSnapshotResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>523e3218-afc7-11c3-90f5-f90431260ab4</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DeleteDBSnapshotResponse>
|
||||
"""
|
||||
|
||||
CREATE_SECURITY_GROUP_TEMPLATE = """<CreateDBSecurityGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
|
||||
<CreateDBSecurityGroupResult>
|
||||
{{ security_group.to_xml() }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue