Revision 6a408fb2 lib/config.py
b/lib/config.py | ||
---|---|---|
305 | 305 |
self._config_data.instances[instance.name] = instance |
306 | 306 |
self._WriteConfig() |
307 | 307 |
|
308 |
def MarkInstanceUp(self, instance_name):
|
|
309 |
"""Mark the instance status to up in the config.
|
|
308 |
def _SetInstanceStatus(self, instance_name, status):
|
|
309 |
"""Set the instance's status to a given value.
|
|
310 | 310 |
|
311 | 311 |
""" |
312 |
if status not in ("up", "down"): |
|
313 |
raise errors.ProgrammerError("Invalid status '%s' passed to" |
|
314 |
" ConfigWriter._SetInstanceStatus()" % |
|
315 |
status) |
|
312 | 316 |
self._OpenConfig() |
313 | 317 |
|
314 | 318 |
if instance_name not in self._config_data.instances: |
315 | 319 |
raise errors.ConfigurationError("Unknown instance '%s'" % |
316 | 320 |
instance_name) |
317 | 321 |
instance = self._config_data.instances[instance_name] |
318 |
instance.status = "up"
|
|
322 |
instance.status = status
|
|
319 | 323 |
self._WriteConfig() |
320 | 324 |
|
325 |
def MarkInstanceUp(self, instance_name): |
|
326 |
"""Mark the instance status to up in the config. |
|
327 |
|
|
328 |
""" |
|
329 |
self._SetInstanceStatus(instance_name, "up") |
|
330 |
|
|
321 | 331 |
def RemoveInstance(self, instance_name): |
322 | 332 |
"""Remove the instance from the configuration. |
323 | 333 |
|
... | ... | |
360 | 370 |
"""Mark the status of an instance to down in the configuration. |
361 | 371 |
|
362 | 372 |
""" |
363 |
self._OpenConfig() |
|
364 |
|
|
365 |
if instance_name not in self._config_data.instances: |
|
366 |
raise errors.ConfigurationError("Unknown instance '%s'" % instance_name) |
|
367 |
instance = self._config_data.instances[instance_name] |
|
368 |
instance.status = "down" |
|
369 |
self._WriteConfig() |
|
373 |
self._SetInstanceStatus(instance_name, "down") |
|
370 | 374 |
|
371 | 375 |
def GetInstanceList(self): |
372 | 376 |
"""Get the list of instances. |
Also available in: Unified diff