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

Side by Side Diff: third_party/gsutil/boto/ec2/spotinstancerequest.py

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Removed gsutil/tests and gsutil/docs Created 7 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
2 # Copyright (c) 2010, Eucalyptus Systems, Inc.
3 #
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-
10 # lowing conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
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
21 # IN THE SOFTWARE.
22
23 """
24 Represents an EC2 Spot Instance Request
25 """
26
27 from boto.ec2.ec2object import TaggedEC2Object
28 from boto.ec2.launchspecification import LaunchSpecification
29
30
31 class SpotInstanceStateFault(object):
32 """
33 The fault codes for the Spot Instance request, if any.
34
35 :ivar code: The reason code for the Spot Instance state change.
36 :ivar message: The message for the Spot Instance state change.
37 """
38
39 def __init__(self, code=None, message=None):
40 self.code = code
41 self.message = message
42
43 def __repr__(self):
44 return '(%s, %s)' % (self.code, self.message)
45
46 def startElement(self, name, attrs, connection):
47 return None
48
49 def endElement(self, name, value, connection):
50 if name == 'code':
51 self.code = value
52 elif name == 'message':
53 self.message = value
54 setattr(self, name, value)
55
56
57 class SpotInstanceStatus(object):
58 """
59 Contains the status of a Spot Instance Request.
60
61 :ivar code: Status code of the request.
62 :ivar message: The description for the status code for the Spot request.
63 :ivar update_time: Time the status was stated.
64 """
65
66 def __init__(self, code=None, update_time=None, message=None):
67 self.code = code
68 self.update_time = update_time
69 self.message = message
70
71 def __repr__(self):
72 return '<Status: %s>' % self.code
73
74 def startElement(self, name, attrs, connection):
75 return None
76
77 def endElement(self, name, value, connection):
78 if name == 'code':
79 self.code = value
80 elif name == 'message':
81 self.message = value
82 elif name == 'updateTime':
83 self.update_time = value
84
85
86 class SpotInstanceRequest(TaggedEC2Object):
87
88 def __init__(self, connection=None):
89 TaggedEC2Object.__init__(self, connection)
90 self.id = None
91 self.price = None
92 self.type = None
93 self.state = None
94 self.fault = None
95 self.valid_from = None
96 self.valid_until = None
97 self.launch_group = None
98 self.launched_availability_zone = None
99 self.product_description = None
100 self.availability_zone_group = None
101 self.create_time = None
102 self.launch_specification = None
103 self.instance_id = None
104 self.status = None
105
106 def __repr__(self):
107 return 'SpotInstanceRequest:%s' % self.id
108
109 def startElement(self, name, attrs, connection):
110 retval = TaggedEC2Object.startElement(self, name, attrs, connection)
111 if retval is not None:
112 return retval
113 if name == 'launchSpecification':
114 self.launch_specification = LaunchSpecification(connection)
115 return self.launch_specification
116 elif name == 'fault':
117 self.fault = SpotInstanceStateFault()
118 return self.fault
119 elif name == 'status':
120 self.status = SpotInstanceStatus()
121 return self.status
122 else:
123 return None
124
125 def endElement(self, name, value, connection):
126 if name == 'spotInstanceRequestId':
127 self.id = value
128 elif name == 'spotPrice':
129 self.price = float(value)
130 elif name == 'type':
131 self.type = value
132 elif name == 'state':
133 self.state = value
134 elif name == 'validFrom':
135 self.valid_from = value
136 elif name == 'validUntil':
137 self.valid_until = value
138 elif name == 'launchGroup':
139 self.launch_group = value
140 elif name == 'availabilityZoneGroup':
141 self.availability_zone_group = value
142 elif name == 'launchedAvailabilityZone':
143 self.launched_availability_zone = value
144 elif name == 'instanceId':
145 self.instance_id = value
146 elif name == 'createTime':
147 self.create_time = value
148 elif name == 'productDescription':
149 self.product_description = value
150 else:
151 setattr(self, name, value)
152
153 def cancel(self):
154 self.connection.cancel_spot_instance_requests([self.id])
155
156
157 class SpotInstanceStatus(object):
158 def __init__(self, code=None, update_time=None, message=None):
159 self.code = code
160 self.update_time = update_time
161 self.message = message
162
163 def startElement(self, name, attrs, connection):
164 return None
165
166 def endElement(self, name, value, connection):
167 if name == 'code':
168 self.code = value
169 elif name == 'update_time':
170 self.update_time = value
171 elif name == 'message':
172 self.message = value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698