Commit fc95f88f authored by Iustin Pop's avatar Iustin Pop
Browse files

Add rename instance support to ConfigWriter

This patch adds support for renaming instances to the ConfigWriter
class. It's needed in here in order to guarantee that we don't lose the
instance during the rename (the instance will be there, either with the
old name or with the new name).

Reviewed-by: imsnah
parent 116b0c88
......@@ -329,6 +329,23 @@ class ConfigWriter:
del self._config_data.instances[instance_name]
def RenameInstance(self, old_name, new_name):
"""Rename an instance.
This needs to be done in ConfigWriter and not by RemoveInstance
combined with AddInstance as only we can guarantee an atomic
if old_name not in self._config_data.instances:
raise errors.ConfigurationError("Unknown instance '%s'" % old_name)
inst = self._config_data.instances[old_name]
del self._config_data.instances[old_name] = new_name
self._config_data.instances[] = inst
def MarkInstanceDown(self, instance_name):
"""Mark the status of an instance to down in the configuration.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment