summaryrefslogtreecommitdiff
path: root/boto/ec2/ec2object.py
diff options
context:
space:
mode:
Diffstat (limited to 'boto/ec2/ec2object.py')
-rw-r--r--boto/ec2/ec2object.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/boto/ec2/ec2object.py b/boto/ec2/ec2object.py
index 7756bee7..265678c6 100644
--- a/boto/ec2/ec2object.py
+++ b/boto/ec2/ec2object.py
@@ -15,7 +15,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
@@ -40,7 +40,7 @@ class EC2Object(object):
def endElement(self, name, value, connection):
setattr(self, name, value)
-
+
class TaggedEC2Object(EC2Object):
"""
Any EC2 resource that can be tagged should be represented
@@ -62,7 +62,7 @@ class TaggedEC2Object(EC2Object):
else:
return None
- def add_tag(self, key, value=''):
+ def add_tag(self, key, value='', dry_run=False):
"""
Add a tag to this object. Tag's are stored by AWS and can be used
to organize and filter resources. Adding a tag involves a round-trip
@@ -76,12 +76,16 @@ class TaggedEC2Object(EC2Object):
If you want only the tag name and no value, the
value should be the empty string.
"""
- status = self.connection.create_tags([self.id], {key : value})
+ status = self.connection.create_tags(
+ [self.id],
+ {key : value},
+ dry_run=dry_run
+ )
if self.tags is None:
self.tags = TagSet()
self.tags[key] = value
- def remove_tag(self, key, value=None):
+ def remove_tag(self, key, value=None, dry_run=False):
"""
Remove a tag from this object. Removing a tag involves a round-trip
to the EC2 service.
@@ -102,6 +106,10 @@ class TaggedEC2Object(EC2Object):
tags = {key : value}
else:
tags = [key]
- status = self.connection.delete_tags([self.id], tags)
+ status = self.connection.delete_tags(
+ [self.id],
+ tags,
+ dry_run=dry_run
+ )
if key in self.tags:
del self.tags[key]