summaryrefslogtreecommitdiff
path: root/boto/ec2/instance.py
diff options
context:
space:
mode:
Diffstat (limited to 'boto/ec2/instance.py')
-rw-r--r--boto/ec2/instance.py96
1 files changed, 60 insertions, 36 deletions
diff --git a/boto/ec2/instance.py b/boto/ec2/instance.py
index e0137705..254fe230 100644
--- a/boto/ec2/instance.py
+++ b/boto/ec2/instance.py
@@ -149,9 +149,9 @@ class Reservation(EC2Object):
else:
setattr(self, name, value)
- def stop_all(self):
+ def stop_all(self, dry_run=False):
for instance in self.instances:
- instance.stop()
+ instance.stop(dry_run=dry_run)
class Instance(TaggedEC2Object):
@@ -406,7 +406,7 @@ class Instance(TaggedEC2Object):
def _update(self, updated):
self.__dict__.update(updated.__dict__)
- def update(self, validate=False):
+ def update(self, validate=False, dry_run=False):
"""
Update the instance's state information by making a call to fetch
the current instance attributes from the service.
@@ -418,7 +418,7 @@ class Instance(TaggedEC2Object):
raise a ValueError exception if no data is
returned from EC2.
"""
- rs = self.connection.get_all_reservations([self.id])
+ rs = self.connection.get_all_reservations([self.id], dry_run=dry_run)
if len(rs) > 0:
r = rs[0]
for i in r.instances:
@@ -428,15 +428,15 @@ class Instance(TaggedEC2Object):
raise ValueError('%s is not a valid Instance ID' % self.id)
return self.state
- def terminate(self):
+ def terminate(self, dry_run=False):
"""
Terminate the instance
"""
- rs = self.connection.terminate_instances([self.id])
+ rs = self.connection.terminate_instances([self.id], dry_run=dry_run)
if len(rs) > 0:
self._update(rs[0])
- def stop(self, force=False):
+ def stop(self, force=False, dry_run=False):
"""
Stop the instance
@@ -446,34 +446,38 @@ class Instance(TaggedEC2Object):
:rtype: list
:return: A list of the instances stopped
"""
- rs = self.connection.stop_instances([self.id], force)
+ rs = self.connection.stop_instances([self.id], force, dry_run=dry_run)
if len(rs) > 0:
self._update(rs[0])
- def start(self):
+ def start(self, dry_run=False):
"""
Start the instance.
"""
- rs = self.connection.start_instances([self.id])
+ rs = self.connection.start_instances([self.id], dry_run=dry_run)
if len(rs) > 0:
self._update(rs[0])
- def reboot(self):
- return self.connection.reboot_instances([self.id])
+ def reboot(self, dry_run=False):
+ return self.connection.reboot_instances([self.id], dry_run=dry_run)
- def get_console_output(self):
+ def get_console_output(self, dry_run=False):
"""
Retrieves the console output for the instance.
:rtype: :class:`boto.ec2.instance.ConsoleOutput`
:return: The console output as a ConsoleOutput object
"""
- return self.connection.get_console_output(self.id)
+ return self.connection.get_console_output(self.id, dry_run=dry_run)
- def confirm_product(self, product_code):
- return self.connection.confirm_product_instance(self.id, product_code)
+ def confirm_product(self, product_code, dry_run=False):
+ return self.connection.confirm_product_instance(
+ self.id,
+ product_code,
+ dry_run=dry_run
+ )
- def use_ip(self, ip_address):
+ def use_ip(self, ip_address, dry_run=False):
"""
Associates an Elastic IP to the instance.
@@ -488,15 +492,19 @@ class Instance(TaggedEC2Object):
if isinstance(ip_address, Address):
ip_address = ip_address.public_ip
- return self.connection.associate_address(self.id, ip_address)
+ return self.connection.associate_address(
+ self.id,
+ ip_address,
+ dry_run=dry_run
+ )
- def monitor(self):
- return self.connection.monitor_instance(self.id)
+ def monitor(self, dry_run=False):
+ return self.connection.monitor_instance(self.id, dry_run=dry_run)
- def unmonitor(self):
- return self.connection.unmonitor_instance(self.id)
+ def unmonitor(self, dry_run=False):
+ return self.connection.unmonitor_instance(self.id, dry_run=dry_run)
- def get_attribute(self, attribute):
+ def get_attribute(self, attribute, dry_run=False):
"""
Gets an attribute from this instance.
@@ -521,9 +529,13 @@ class Instance(TaggedEC2Object):
:return: An InstanceAttribute object representing the value of the
attribute requested
"""
- return self.connection.get_instance_attribute(self.id, attribute)
+ return self.connection.get_instance_attribute(
+ self.id,
+ attribute,
+ dry_run=dry_run
+ )
- def modify_attribute(self, attribute, value):
+ def modify_attribute(self, attribute, value, dry_run=False):
"""
Changes an attribute of this instance
@@ -546,10 +558,14 @@ class Instance(TaggedEC2Object):
:rtype: bool
:return: Whether the operation succeeded or not
"""
- return self.connection.modify_instance_attribute(self.id, attribute,
- value)
-
- def reset_attribute(self, attribute):
+ return self.connection.modify_instance_attribute(
+ self.id,
+ attribute,
+ value,
+ dry_run=dry_run
+ )
+
+ def reset_attribute(self, attribute, dry_run=False):
"""
Resets an attribute of this instance to its default value.
@@ -560,12 +576,14 @@ class Instance(TaggedEC2Object):
:rtype: bool
:return: Whether the operation succeeded or not
"""
- return self.connection.reset_instance_attribute(self.id, attribute)
-
- def create_image(
- self, name,
- description=None, no_reboot=False
- ):
+ return self.connection.reset_instance_attribute(
+ self.id,
+ attribute,
+ dry_run=dry_run
+ )
+
+ def create_image(self, name, description=None, no_reboot=False,
+ dry_run=False):
"""
Will create an AMI from the instance in the running or stopped
state.
@@ -587,7 +605,13 @@ class Instance(TaggedEC2Object):
:rtype: string
:return: The new image id
"""
- return self.connection.create_image(self.id, name, description, no_reboot)
+ return self.connection.create_image(
+ self.id,
+ name,
+ description,
+ no_reboot,
+ dry_run=dry_run
+ )
class ConsoleOutput: