Merge pull request #487 from a1exsh/bugfix/include-load-balancer-name-in-describe-tags-response
Fix ELB.describe_tags with multiple LoadBalancerNames.
This commit is contained in:
commit
fe090d7bb5
@ -277,6 +277,7 @@ class ELBResponse(BaseResponse):
|
||||
return template.render()
|
||||
|
||||
def describe_tags(self):
|
||||
elbs = []
|
||||
for key, value in self.querystring.items():
|
||||
if "LoadBalancerNames.member" in key:
|
||||
number = key.split('.')[2]
|
||||
@ -284,9 +285,10 @@ class ELBResponse(BaseResponse):
|
||||
elb = self.elb_backend.get_load_balancer(load_balancer_name)
|
||||
if not elb:
|
||||
raise LoadBalancerNotFound(load_balancer_name)
|
||||
elbs.append(elb)
|
||||
|
||||
template = self.response_template(DESCRIBE_TAGS_TEMPLATE)
|
||||
return template.render(tags=elb.tags)
|
||||
return template.render(load_balancers=elbs)
|
||||
|
||||
ADD_TAGS_TEMPLATE = """<AddTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
|
||||
<AddTagsResult/>
|
||||
@ -305,9 +307,11 @@ REMOVE_TAGS_TEMPLATE = """<RemoveTagsResponse xmlns="http://elasticloadbalancing
|
||||
DESCRIBE_TAGS_TEMPLATE = """<DescribeTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
|
||||
<DescribeTagsResult>
|
||||
<TagDescriptions>
|
||||
{% for elb in load_balancers %}
|
||||
<member>
|
||||
<LoadBalancerName>{{ elb.name }}</LoadBalancerName>
|
||||
<Tags>
|
||||
{% for key, value in tags.items() %}
|
||||
{% for key, value in elb.tags.items() %}
|
||||
<member>
|
||||
<Value>{{ value }}</Value>
|
||||
<Key>{{ key }}</Key>
|
||||
@ -315,6 +319,7 @@ DESCRIBE_TAGS_TEMPLATE = """<DescribeTagsResponse xmlns="http://elasticloadbalan
|
||||
{% endfor %}
|
||||
</Tags>
|
||||
</member>
|
||||
{% endfor %}
|
||||
</TagDescriptions>
|
||||
</DescribeTagsResult>
|
||||
<ResponseMetadata>
|
||||
|
@ -698,3 +698,24 @@ def test_add_remove_tags():
|
||||
tags.should.have.key('i').which.should.equal('b')
|
||||
tags.should.have.key('j').which.should.equal('c')
|
||||
|
||||
|
||||
client.create_load_balancer(
|
||||
LoadBalancerName='other-lb',
|
||||
Listeners=[{'Protocol':'tcp', 'LoadBalancerPort':433, 'InstancePort':8433}],
|
||||
AvailabilityZones=['us-east-1a', 'us-east-1b']
|
||||
)
|
||||
|
||||
client.add_tags(LoadBalancerNames=['other-lb'],
|
||||
Tags=[{
|
||||
'Key': 'other',
|
||||
'Value': 'something'
|
||||
}])
|
||||
|
||||
lb_tags = dict([(l['LoadBalancerName'], dict([(d['Key'], d['Value']) for d in l['Tags']]))
|
||||
for l in client.describe_tags(LoadBalancerNames=['my-lb', 'other-lb'])['TagDescriptions']])
|
||||
|
||||
lb_tags.should.have.key('my-lb')
|
||||
lb_tags.should.have.key('other-lb')
|
||||
|
||||
lb_tags['my-lb'].shouldnt.have.key('other')
|
||||
lb_tags['other-lb'].should.have.key('other').which.should.equal('something')
|
||||
|
Loading…
Reference in New Issue
Block a user