Sometimes reinstalls are slightly different than new installs. For example certain partitions may need to be preserved accross reinstalls. In order to do that on a per-os basis we pass in the INSTANCE_REINSTALL variable to inform the create script about when a reinstall is happening.
Signed-off-by: Guido Trotter <[email protected]> --- daemons/ganeti-noded | 3 ++- lib/backend.py | 6 +++++- lib/cmdlib.py | 3 ++- lib/rpc.py | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 3a2b4a0..ac90090 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -365,7 +365,8 @@ class NodeHttpServer(http.server.HttpServer): """ inst_s = params[0] inst = objects.Instance.FromDict(inst_s) - return backend.InstanceOsAdd(inst) + reinstall = params[1] + return backend.InstanceOsAdd(inst, reinstall) @staticmethod def perspective_instance_run_rename(params): diff --git a/lib/backend.py b/lib/backend.py index 18d439e..183286b 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -673,11 +673,13 @@ def GetAllInstancesInfo(hypervisor_list): return output -def InstanceOsAdd(instance): +def InstanceOsAdd(instance, reinstall): """Add an OS to an instance. @type instance: L{objects.Instance} @param instance: Instance whose OS is to be installed + @type reinstall: boolean + @param reinstall: whether this is an instance reinstall @rtype: boolean @return: the success of the operation @@ -693,6 +695,8 @@ def InstanceOsAdd(instance): (os_name, os_dir, os_err)) create_env = OSEnvironment(instance) + if reinstall: + create_env['INSTANCE_REINSTALL'] = "1" logfile = "%s/add-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, instance.name, int(time.time())) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 516483e..cc8ecdd 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2995,7 +2995,8 @@ class LUReinstallInstance(LogicalUnit): _StartInstanceDisks(self, inst, None) try: feedback_fn("Running the instance OS create scripts...") - result = self.rpc.call_instance_os_add(inst.primary_node, inst) + result = self.rpc.call_instance_os_add(inst.primary_node, inst, + reinstall=True) msg = result.RemoteFailMsg() if msg: raise errors.OpExecError("Could not install OS for instance %s" diff --git a/lib/rpc.py b/lib/rpc.py index 70dd312..0f1d44d 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -524,14 +524,14 @@ class RpcRunner(object): return self._SingleNodeCall(node, "instance_reboot", [self._InstDict(instance), reboot_type]) - def call_instance_os_add(self, node, inst): + def call_instance_os_add(self, node, inst, reinstall=False): """Installs an OS on the given instance. This is a single-node call. """ return self._SingleNodeCall(node, "instance_os_add", - [self._InstDict(inst)]) + [self._InstDict(inst), reinstall]) def call_instance_run_rename(self, node, inst, old_name): """Run the OS rename script for an instance. -- 1.5.6.5
