comparison env/lib/python3.9/site-packages/boto/ec2/volumestatus.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates.
3 # All Rights Reserved
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish, dis-
9 # tribute, sublicense, and/or sell copies of the Software, and to permit
10 # persons to whom the Software is furnished to do so, subject to the fol-
11 # lowing conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
18 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 # IN THE SOFTWARE.
23
24 from boto.ec2.instancestatus import Status, Details
25
26
27 class Event(object):
28 """
29 A status event for an instance.
30
31 :ivar type: The type of the event.
32 :ivar id: The ID of the event.
33 :ivar description: A string describing the reason for the event.
34 :ivar not_before: A datestring describing the earliest time for
35 the event.
36 :ivar not_after: A datestring describing the latest time for
37 the event.
38 """
39
40 def __init__(self, type=None, id=None, description=None,
41 not_before=None, not_after=None):
42 self.type = type
43 self.id = id
44 self.description = description
45 self.not_before = not_before
46 self.not_after = not_after
47
48 def __repr__(self):
49 return 'Event:%s' % self.type
50
51 def startElement(self, name, attrs, connection):
52 return None
53
54 def endElement(self, name, value, connection):
55 if name == 'eventType':
56 self.type = value
57 elif name == 'eventId':
58 self.id = value
59 elif name == 'description':
60 self.description = value
61 elif name == 'notBefore':
62 self.not_before = value
63 elif name == 'notAfter':
64 self.not_after = value
65 else:
66 setattr(self, name, value)
67
68
69 class EventSet(list):
70
71 def startElement(self, name, attrs, connection):
72 if name == 'item':
73 event = Event()
74 self.append(event)
75 return event
76 else:
77 return None
78
79 def endElement(self, name, value, connection):
80 setattr(self, name, value)
81
82
83 class Action(object):
84 """
85 An action for an instance.
86
87 :ivar code: The code for the type of the action.
88 :ivar id: The ID of the event.
89 :ivar type: The type of the event.
90 :ivar description: A description of the action.
91 """
92
93 def __init__(self, code=None, id=None, description=None, type=None):
94 self.code = code
95 self.id = id
96 self.type = type
97 self.description = description
98
99 def __repr__(self):
100 return 'Action:%s' % self.code
101
102 def startElement(self, name, attrs, connection):
103 return None
104
105 def endElement(self, name, value, connection):
106 if name == 'eventType':
107 self.type = value
108 elif name == 'eventId':
109 self.id = value
110 elif name == 'description':
111 self.description = value
112 elif name == 'code':
113 self.code = value
114 else:
115 setattr(self, name, value)
116
117
118 class ActionSet(list):
119
120 def startElement(self, name, attrs, connection):
121 if name == 'item':
122 action = Action()
123 self.append(action)
124 return action
125 else:
126 return None
127
128 def endElement(self, name, value, connection):
129 setattr(self, name, value)
130
131
132 class VolumeStatus(object):
133 """
134 Represents an EC2 Volume status as reported by
135 DescribeVolumeStatus request.
136
137 :ivar id: The volume identifier.
138 :ivar zone: The availability zone of the volume
139 :ivar volume_status: A Status object that reports impaired
140 functionality that arises from problems internal to the instance.
141 :ivar events: A list of events relevant to the instance.
142 :ivar actions: A list of events relevant to the instance.
143 """
144
145 def __init__(self, id=None, zone=None):
146 self.id = id
147 self.zone = zone
148 self.volume_status = Status()
149 self.events = None
150 self.actions = None
151
152 def __repr__(self):
153 return 'VolumeStatus:%s' % self.id
154
155 def startElement(self, name, attrs, connection):
156 if name == 'eventsSet':
157 self.events = EventSet()
158 return self.events
159 elif name == 'actionsSet':
160 self.actions = ActionSet()
161 return self.actions
162 elif name == 'volumeStatus':
163 return self.volume_status
164 else:
165 return None
166
167 def endElement(self, name, value, connection):
168 if name == 'volumeId':
169 self.id = value
170 elif name == 'availabilityZone':
171 self.zone = value
172 else:
173 setattr(self, name, value)
174
175
176 class VolumeStatusSet(list):
177 """
178 A list object that contains the results of a call to
179 DescribeVolumeStatus request. Each element of the
180 list will be an VolumeStatus object.
181
182 :ivar next_token: If the response was truncated by
183 the EC2 service, the next_token attribute of the
184 object will contain the string that needs to be
185 passed in to the next request to retrieve the next
186 set of results.
187 """
188
189 def __init__(self, connection=None):
190 list.__init__(self)
191 self.connection = connection
192 self.next_token = None
193
194 def startElement(self, name, attrs, connection):
195 if name == 'item':
196 status = VolumeStatus()
197 self.append(status)
198 return status
199 else:
200 return None
201
202 def endElement(self, name, value, connection):
203 if name == 'NextToken':
204 self.next_token = value
205 setattr(self, name, value)