1
# Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
2
# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
4
# Permission is hereby granted, free of charge, to any person obtaining a
5
# copy of this software and associated documentation files (the
6
# "Software"), to deal in the Software without restriction, including
7
# without limitation the rights to use, copy, modify, merge, publish, dis-
8
# tribute, sublicense, and/or sell copies of the Software, and to permit
9
# persons to whom the Software is furnished to do so, subject to the fol-
12
# The above copyright notice and this permission notice shall be included
13
# in all copies or substantial portions of the Software.
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
A name/value tag on an AutoScalingGroup resource.
27
:ivar key: The key of the tag.
28
:ivar value: The value of the tag.
29
:ivar propagate_at_launch: Boolean value which specifies whether the
30
new tag will be applied to instances launched after the tag is created.
31
:ivar resource_id: The name of the autoscaling group.
32
:ivar resource_type: The only supported resource type at this time
33
is "auto-scaling-group".
36
def __init__(self, connection=None, key=None, value=None,
37
propagate_at_launch=False, resource_id=None,
38
resource_type='auto-scaling-group'):
39
self.connection = connection
42
self.propagate_at_launch = propagate_at_launch
43
self.resource_id = resource_id
44
self.resource_type = resource_type
47
return 'Tag(%s=%s)' % (self.key, self.value)
49
def startElement(self, name, attrs, connection):
52
def endElement(self, name, value, connection):
57
elif name == 'PropogateAtLaunch':
58
if value.lower() == 'true':
59
self.propogate_at_launch = True
61
self.propogate_at_launch = False
62
elif name == 'ResourceId':
63
self.resource_id = value
64
elif name == 'ResourceType':
65
self.resource_type = value
67
def build_params(self, params, i):
69
Populates a dictionary with the name/value pairs necessary
70
to identify this Tag in a request.
72
prefix = 'Tags.member.%d.' % i
73
params[prefix+'ResourceId'] = self.resource_id
74
params[prefix+'ResourceType'] = self.resource_type
75
params[prefix+'Key'] = self.key
76
params[prefix+'Value'] = self.value
77
if self.propagate_at_launch:
78
params[prefix+'PropagateAtLaunch'] = 'true'
80
params[prefix+'PropagateAtLaunch'] = 'false'
83
return self.connection.delete_tags([self])