Revision c41eea6e daemons/ganeti-watcher
b/daemons/ganeti-watcher | ||
---|---|---|
62 | 62 |
def Indent(s, prefix='| '): |
63 | 63 |
"""Indent a piece of text with a given prefix before each line. |
64 | 64 |
|
65 |
Args: |
|
66 |
s: The string to indent |
|
67 |
prefix: The string to prepend each line. |
|
65 |
@param s: the string to indent |
|
66 |
@param prefix: the string to prepend each line |
|
68 | 67 |
|
69 | 68 |
""" |
70 | 69 |
return "%s%s\n" % (prefix, ('\n' + prefix).join(s.splitlines())) |
... | ... | |
158 | 157 |
def NumberOfRestartAttempts(self, instance): |
159 | 158 |
"""Returns number of previous restart attempts. |
160 | 159 |
|
161 |
Args:
|
|
162 |
instance - the instance to look up.
|
|
160 |
@type instance: L{Instance}
|
|
161 |
@param instance: the instance to look up
|
|
163 | 162 |
|
164 | 163 |
""" |
165 | 164 |
idata = self._data["instance"] |
... | ... | |
172 | 171 |
def RecordRestartAttempt(self, instance): |
173 | 172 |
"""Record a restart attempt. |
174 | 173 |
|
175 |
Args:
|
|
176 |
instance - the instance being restarted
|
|
174 |
@type instance: L{Instance}
|
|
175 |
@param instance: the instance being restarted
|
|
177 | 176 |
|
178 | 177 |
""" |
179 | 178 |
idata = self._data["instance"] |
... | ... | |
187 | 186 |
inst[KEY_RESTART_COUNT] = inst.get(KEY_RESTART_COUNT, 0) + 1 |
188 | 187 |
|
189 | 188 |
def RemoveInstance(self, instance): |
190 |
"""Update state to reflect that a machine is running, i.e. remove record.
|
|
189 |
"""Update state to reflect that a machine is running. |
|
191 | 190 |
|
192 |
Args:
|
|
193 |
instance - the instance to remove from books
|
|
191 |
This method removes the record for a named instance (as we only
|
|
192 |
track down instances).
|
|
194 | 193 |
|
195 |
This method removes the record for a named instance. |
|
194 |
@type instance: L{Instance} |
|
195 |
@param instance: the instance to remove from books |
|
196 | 196 |
|
197 | 197 |
""" |
198 | 198 |
idata = self._data["instance"] |
... | ... | |
204 | 204 |
class Instance(object): |
205 | 205 |
"""Abstraction for a Virtual Machine instance. |
206 | 206 |
|
207 |
Methods: |
|
208 |
Restart(): issue a command to restart the represented machine. |
|
209 |
|
|
210 | 207 |
""" |
211 | 208 |
def __init__(self, name, state, autostart): |
212 | 209 |
self.name = name |
... | ... | |
399 | 396 |
def ParseOptions(): |
400 | 397 |
"""Parse the command line options. |
401 | 398 |
|
402 |
Returns: |
|
403 |
(options, args) as from OptionParser.parse_args() |
|
399 |
@return: (options, args) as from OptionParser.parse_args() |
|
404 | 400 |
|
405 | 401 |
""" |
406 | 402 |
parser = OptionParser(description="Ganeti cluster watcher", |
Also available in: Unified diff