Storing tags on create db instance and getting tags back in list_tags_for_resource
This commit is contained in:
parent
6559d11dd5
commit
2dde94c9be
@ -14,7 +14,7 @@ class RDS2Response(BaseResponse):
|
|||||||
return rds2_backends[self.region]
|
return rds2_backends[self.region]
|
||||||
|
|
||||||
def _get_db_kwargs(self):
|
def _get_db_kwargs(self):
|
||||||
return {
|
args = {
|
||||||
"auto_minor_version_upgrade": self._get_param('AutoMinorVersionUpgrade'),
|
"auto_minor_version_upgrade": self._get_param('AutoMinorVersionUpgrade'),
|
||||||
"allocated_storage": self._get_int_param('AllocatedStorage'),
|
"allocated_storage": self._get_int_param('AllocatedStorage'),
|
||||||
"availability_zone": self._get_param("AvailabilityZone"),
|
"availability_zone": self._get_param("AvailabilityZone"),
|
||||||
@ -39,7 +39,16 @@ class RDS2Response(BaseResponse):
|
|||||||
"security_groups": self._get_multi_param('DBSecurityGroups.member'),
|
"security_groups": self._get_multi_param('DBSecurityGroups.member'),
|
||||||
"storage_type": self._get_param("StorageType"),
|
"storage_type": self._get_param("StorageType"),
|
||||||
# VpcSecurityGroupIds.member.N
|
# VpcSecurityGroupIds.member.N
|
||||||
|
"tags": []
|
||||||
}
|
}
|
||||||
|
count = 1
|
||||||
|
while self._get_param('Tags.member.{}.Key'.format(count)):
|
||||||
|
args["tags"].append({
|
||||||
|
"Key": self._get_param('Tags.member.{}.Key'.format(count)),
|
||||||
|
"Value": self._get_param('Tags.member.{}.Value'.format(count))
|
||||||
|
})
|
||||||
|
count += 1
|
||||||
|
return args
|
||||||
|
|
||||||
def _get_db_replica_kwargs(self):
|
def _get_db_replica_kwargs(self):
|
||||||
return {
|
return {
|
||||||
@ -414,9 +423,10 @@ LIST_TAGS_FOR_RESOURCE_TEMPLATE = \
|
|||||||
{"TagList": [
|
{"TagList": [
|
||||||
{%- for tag in tags -%}
|
{%- for tag in tags -%}
|
||||||
{%- if loop.index != 1 -%},{%- endif -%}
|
{%- if loop.index != 1 -%},{%- endif -%}
|
||||||
{%- for key in tag -%}
|
{
|
||||||
{"Value": "{{ tag[key] }}", "Key": "{{ key }}"}
|
"Key": "{{ tag['Key'] }}",
|
||||||
{%- endfor -%}
|
"Value": "{{ tag['Value'] }}"
|
||||||
|
}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
]},
|
]},
|
||||||
"ResponseMetadata": {
|
"ResponseMetadata": {
|
||||||
|
@ -277,15 +277,19 @@ def test_list_tags():
|
|||||||
conn = boto.rds2.connect_to_region("us-west-2")
|
conn = boto.rds2.connect_to_region("us-west-2")
|
||||||
result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:foo')
|
result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:foo')
|
||||||
result['ListTagsForResourceResponse']['ListTagsForResourceResult']['TagList'].should.equal([])
|
result['ListTagsForResourceResponse']['ListTagsForResourceResult']['TagList'].should.equal([])
|
||||||
conn.create_db_instance(db_instance_identifier='db-master-1',
|
conn.create_db_instance(db_instance_identifier='db-with-tags',
|
||||||
allocated_storage=10,
|
allocated_storage=10,
|
||||||
engine='postgres',
|
engine='postgres',
|
||||||
db_instance_class='db.m1.small',
|
db_instance_class='db.m1.small',
|
||||||
master_username='root',
|
master_username='root',
|
||||||
master_user_password='hunter2',
|
master_user_password='hunter2',
|
||||||
db_security_groups=["my_sg"],
|
db_security_groups=["my_sg"],
|
||||||
tags=[{'Key': 'foo', 'Value': 'bar'}])
|
tags=[('foo', 'bar'), ('foo1', 'bar1')])
|
||||||
result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:db-master-1')
|
result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:db-with-tags')
|
||||||
|
result['ListTagsForResourceResponse']['ListTagsForResourceResult']['TagList'].should.equal([{'Value': 'bar',
|
||||||
|
'Key': 'foo'},
|
||||||
|
{'Value': 'bar1',
|
||||||
|
'Key': 'foo1'}])
|
||||||
|
|
||||||
#@disable_on_py3()
|
#@disable_on_py3()
|
||||||
#@mock_rds2
|
#@mock_rds2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user