Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: third_party/gsutil/boto/boto/ec2/instance.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/gsutil/boto/boto/ec2/image.py ('k') | third_party/gsutil/boto/boto/ec2/instanceinfo.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gsutil/boto/boto/ec2/instance.py
diff --git a/third_party/gsutil/20110627/boto/boto/ec2/instance.py b/third_party/gsutil/boto/boto/ec2/instance.py
similarity index 72%
rename from third_party/gsutil/20110627/boto/boto/ec2/instance.py
rename to third_party/gsutil/boto/boto/ec2/instance.py
index 8c21bad0f650f1abf6ebd59d4dfc76134faf4b9a..fc90680a70a7f3b63cba374c1071406d6b664e2b 100644
--- a/third_party/gsutil/20110627/boto/boto/ec2/instance.py
+++ b/third_party/gsutil/boto/boto/ec2/instance.py
@@ -29,9 +29,21 @@ from boto.resultset import ResultSet
from boto.ec2.address import Address
from boto.ec2.blockdevicemapping import BlockDeviceMapping
from boto.ec2.image import ProductCodes
+from boto.ec2.networkinterface import NetworkInterface
+from boto.ec2.group import Group
import base64
class Reservation(EC2Object):
+ """
+ Represents a Reservation response object.
+
+ :ivar id: The unique ID of the Reservation.
+ :ivar owner_id: The unique ID of the owner of the Reservation.
+ :ivar groups: A list of Group objects representing the security
+ groups associated with launched instances.
+ :ivar instances: A list of Instance objects launched in this
+ Reservation.
+ """
def __init__(self, connection=None):
EC2Object.__init__(self, connection)
@@ -66,6 +78,44 @@ class Reservation(EC2Object):
instance.stop()
class Instance(TaggedEC2Object):
+ """
+ Represents an instance.
+
+ :ivar id: The unique ID of the Instance.
+ :ivar groups: A list of Group objects representing the security
+ groups associated with the instance.
+ :ivar public_dns_name: The public dns name of the instance.
+ :ivar private_dns_name: The private dns name of the instance.
+ :ivar state: The string representation of the instances current state.
+ :ivar state_code: An integer representation of the instances current state.
+ :ivar key_name: The name of the SSH key associated with the instance.
+ :ivar instance_type: The type of instance (e.g. m1.small).
+ :ivar launch_time: The time the instance was launched.
+ :ivar image_id: The ID of the AMI used to launch this instance.
+ :ivar placement: The availability zone in which the instance is running.
+ :ivar kernel: The kernel associated with the instance.
+ :ivar ramdisk: The ramdisk associated with the instance.
+ :ivar architecture: The architecture of the image (i386|x86_64).
+ :ivar hypervisor: The hypervisor used.
+ :ivar virtualization_type: The type of virtualization used.
+ :ivar product_codes: A list of product codes associated with this instance.
+ :ivar ami_launch_index: This instances position within it's launch group.
+ :ivar monitored: A boolean indicating whether monitoring is enabled or not.
+ :ivar spot_instance_request_id: The ID of the spot instance request
+ if this is a spot instance.
+ :ivar subnet_id: The VPC Subnet ID, if running in VPC.
+ :ivar vpc_id: The VPC ID, if running in VPC.
+ :ivar private_ip_address: The private IP address of the instance.
+ :ivar ip_address: The public IP address of the instance.
+ :ivar platform: Platform of the instance (e.g. Windows)
+ :ivar root_device_name: The name of the root device.
+ :ivar root_device_type: The root device type (ebs|instance-store).
+ :ivar block_device_mapping: The Block Device Mapping for the instance.
+ :ivar state_reason: The reason for the most recent state transition.
+ :ivar groups: List of security Groups associated with the instance.
+ :ivar interfaces: List of Elastic Network Interfaces associated with
+ this instance.
+ """
def __init__(self, connection=None):
TaggedEC2Object.__init__(self, connection)
@@ -79,7 +129,6 @@ class Instance(TaggedEC2Object):
self.shutdown_state = None
self.previous_state = None
self.instance_type = None
- self.instance_class = None
self.launch_time = None
self.image_id = None
self.placement = None
@@ -88,7 +137,6 @@ class Instance(TaggedEC2Object):
self.product_codes = ProductCodes()
self.ami_launch_index = None
self.monitored = False
- self.instance_class = None
self.spot_instance_request_id = None
self.subnet_id = None
self.vpc_id = None
@@ -103,7 +151,13 @@ class Instance(TaggedEC2Object):
self.state_reason = None
self.group_name = None
self.client_token = None
+ self.eventsSet = None
self.groups = []
+ self.platform = None
+ self.interfaces = []
+ self.hypervisor = None
+ self.virtualization_type = None
+ self.architecture = None
def __repr__(self):
return 'Instance:%s' % self.id
@@ -120,11 +174,16 @@ class Instance(TaggedEC2Object):
elif name == 'productCodes':
return self.product_codes
elif name == 'stateReason':
- self.state_reason = StateReason()
+ self.state_reason = SubParse('stateReason')
return self.state_reason
elif name == 'groupSet':
self.groups = ResultSet([('item', Group)])
return self.groups
+ elif name == "eventsSet":
+ self.eventsSet = SubParse('eventsSet')
+ return self.eventsSet
+ elif name == 'networkInterfaceSet':
+ self.interfaces = ResultSet([('item', NetworkInterface)])
return None
def endElement(self, name, value, connection):
@@ -155,8 +214,6 @@ class Instance(TaggedEC2Object):
self.state_code = value
elif name == 'instanceType':
self.instance_type = value
- elif name == 'instanceClass':
- self.instance_class = value
elif name == 'rootDeviceName':
self.root_device_name = value
elif name == 'rootDeviceType':
@@ -165,6 +222,8 @@ class Instance(TaggedEC2Object):
self.launch_time = value
elif name == 'availabilityZone':
self.placement = value
+ elif name == 'platform':
+ self.platform = value
elif name == 'placement':
pass
elif name == 'kernelId':
@@ -176,8 +235,6 @@ class Instance(TaggedEC2Object):
if value == 'enabled':
self.monitored = True
self._in_monitoring_element = False
- elif name == 'instanceClass':
- self.instance_class = value
elif name == 'spotInstanceRequestId':
self.spot_instance_request_id = value
elif name == 'subnetId':
@@ -200,6 +257,14 @@ class Instance(TaggedEC2Object):
self.group_name = value
elif name == 'clientToken':
self.client_token = value
+ elif name == "eventsSet":
+ self.events = value
+ elif name == 'hypervisor':
+ self.hypervisor = value
+ elif name == 'virtualizationType':
+ self.virtualization_type = value
+ elif name == 'architecture':
+ self.architecture = value
else:
setattr(self, name, value)
@@ -233,7 +298,8 @@ class Instance(TaggedEC2Object):
Terminate the instance
"""
rs = self.connection.terminate_instances([self.id])
- self._update(rs[0])
+ if len(rs) > 0:
+ self._update(rs[0])
def stop(self, force=False):
"""
@@ -245,15 +311,17 @@ class Instance(TaggedEC2Object):
:rtype: list
:return: A list of the instances stopped
"""
- rs = self.connection.stop_instances([self.id])
- self._update(rs[0])
+ rs = self.connection.stop_instances([self.id], force)
+ if len(rs) > 0:
+ self._update(rs[0])
def start(self):
"""
Start the instance.
"""
rs = self.connection.start_instances([self.id])
- self._update(rs[0])
+ if len(rs) > 0:
+ self._update(rs[0])
def reboot(self):
return self.connection.reboot_instances([self.id])
@@ -336,23 +404,6 @@ class Instance(TaggedEC2Object):
"""
return self.connection.reset_instance_attribute(self.id, attribute)
-class Group:
-
- def __init__(self, parent=None):
- self.id = None
- self.name = None
-
- def startElement(self, name, attrs, connection):
- return None
-
- def endElement(self, name, value, connection):
- if name == 'groupId':
- self.id = value
- elif name == 'groupName':
- self.name = value
- else:
- setattr(self, name, value)
-
class ConsoleOutput:
def __init__(self, parent=None):
@@ -376,28 +427,47 @@ class ConsoleOutput:
class InstanceAttribute(dict):
+ ValidValues = ['instanceType', 'kernel', 'ramdisk', 'userData',
+ 'disableApiTermination', 'instanceInitiatedShutdownBehavior',
+ 'rootDeviceName', 'blockDeviceMapping', 'sourceDestCheck',
+ 'groupSet']
+
def __init__(self, parent=None):
dict.__init__(self)
+ self.instance_id = None
+ self.request_id = None
self._current_value = None
def startElement(self, name, attrs, connection):
- return None
+ if name == 'blockDeviceMapping':
+ self[name] = BlockDeviceMapping()
+ return self[name]
+ elif name == 'groupSet':
+ self[name] = ResultSet([('item', Group)])
+ return self[name]
+ else:
+ return None
def endElement(self, name, value, connection):
- if name == 'value':
+ if name == 'instanceId':
+ self.instance_id = value
+ elif name == 'requestId':
+ self.request_id = value
+ elif name == 'value':
self._current_value = value
- else:
+ elif name in self.ValidValues:
self[name] = self._current_value
-class StateReason(dict):
+class SubParse(dict):
- def __init__(self, parent=None):
+ def __init__(self, section, parent=None):
dict.__init__(self)
+ self.section = section
def startElement(self, name, attrs, connection):
return None
def endElement(self, name, value, connection):
- if name != 'stateReason':
+ if name != self.section:
self[name] = value
« no previous file with comments | « third_party/gsutil/boto/boto/ec2/image.py ('k') | third_party/gsutil/boto/boto/ec2/instanceinfo.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698