On Tue, May 13, 2014 at 10:43 AM, 'Jose A. Lopes' via ganeti-devel <
[email protected]> wrote:

> This method temporarily changes the instance's disk to contain the
> helper VM's boot disk and the target disk for the OS installation.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  lib/cmdlib/instance.py | 52
> ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py
> index f2fb187..ee6a8eb 100644
> --- a/lib/cmdlib/instance.py
> +++ b/lib/cmdlib/instance.py
> @@ -1519,6 +1519,58 @@ class LUInstanceCreate(LogicalUnit):
>
>        feedback_fn("Created OS install package '%s'" % result.payload)
>
> +  def RunOsScriptsVirtualized(self, feedback_fn, instance):
>

Missing docstring. And here you actually do have something to write about ;)


> +    install_image = self.cfg.GetInstallImage()
> +
> +    if not install_image:
> +      raise errors.OpExecError("Cannot create install instance because an"
> +                               " install image has not been specified")
> +
> +    disk_size = DetermineImageSize(self, install_image,
> instance.primary_node)
> +
> +    # KVM does not support readonly disks
> +    if instance.hypervisor == constants.HT_KVM:
> +      disk_access = constants.DISK_RDWR
> +    else:
> +      disk_access = constants.DISK_RDONLY
> +
> +    with TemporaryDisk(self,
> +                       instance,
> +                       [(constants.DT_PLAIN, disk_access, disk_size)],
> +                       feedback_fn):
> +      feedback_fn("Activating instance disks")
> +      StartInstanceDisks(self, instance, False)
> +
> +      feedback_fn("Imaging disk with install image")
> +      ImageDisks(self, instance, install_image)
> +
> +      feedback_fn("Starting instance with install image")
> +      result = self.rpc.call_instance_start(instance.primary_node,
> +                                            (instance, [], []),
> +                                            False, self.op.reason)
> +      result.Raise("Could not start instance '%s' with the install image
> '%s'"
> +                   % (instance.name, install_image))
> +
> +      # First wait for the instance to start up
> +      running_check = lambda: IsInstanceRunning(self, instance,
> +                                                check_user_shutdown=True)
> +      instance_up = retry.SimpleRetry(True, running_check, 5.0,
> +                                      self.op.helper_startup_timeout)
> +      if not instance_up:
> +        raise errors.OpExecError("Could not boot instance using install
> image"
> +                                 " '%s'" % install_image)
> +
> +      feedback_fn("Instance is up, now awaiting shutdown")
> +
> +      # Then for it to be finished, detected by its shutdown
> +      instance_up = retry.SimpleRetry(False, running_check, 20.0,
> +                                      self.op.helper_shutdown_timeout)
> +      if instance_up:
> +        self.LogWarning("Installation not completed prior to timeout,
> shutting"
> +                        " down instance forcibly")
> +
> +    feedback_fn("Installation complete")
> +
>    def Exec(self, feedback_fn):
>      """Create and add the instance to the cluster.
>
> --
> 1.9.1.423.g4596e3a
>
>

Reply via email to