← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:fix/cii-kvmimage-preserve-original into cloud-init:master

 

the Image object has a destroy() method which is valid to call, and should be called whne you're "done" with the object.
  i = Image(foo)
  i.execute(['apt-get', 'dist-upgrade'])
  s = i.snapshot()
  i.destroy()
  s.launch()
  ...

the result of snapshot needs to be stand-alone, and before this change it was not.
As used above, s.launch() would have failed as it was qcow backed by i.


Diff comments:

> diff --git a/tests/cloud_tests/images/nocloudkvm.py b/tests/cloud_tests/images/nocloudkvm.py
> index 1e7962c..8678b07 100644
> --- a/tests/cloud_tests/images/nocloudkvm.py
> +++ b/tests/cloud_tests/images/nocloudkvm.py
> @@ -21,7 +25,13 @@ class NoCloudKVMImage(base.Image):
>          @param img_path: path to the image
>          """
>          self.modified = False
> -        self._img_path = img_path
> +        self._workd = tempfile.mkdtemp(prefix='NoCloudKVMImage')

When verifying results against an existing directory, Image(foo) will never be called.
if you create a Image() object, then it will download an image. of course we do not want to do that when just doing the verify stage.

> +        self._orig_img_path = orig_img_path
> +        self._img_path = os.path.join(self._workd,
> +                                      os.path.basename(self._orig_img_path))
> +
> +        c_util.subp(['qemu-img', 'create', '-f', 'qcow2',
> +                    '-b', orig_img_path, self._img_path])
>  
>          super(NoCloudKVMImage, self).__init__(platform, config)
>  
> diff --git a/tests/cloud_tests/platforms/nocloudkvm.py b/tests/cloud_tests/platforms/nocloudkvm.py
> index f1f8187..cf55561 100644
> --- a/tests/cloud_tests/platforms/nocloudkvm.py
> +++ b/tests/cloud_tests/platforms/nocloudkvm.py
> @@ -58,16 +58,14 @@ class NoCloudKVMPlatform(base.Platform):
>          if len(images) != 1:
>              raise Exception('No unique images found')
>  
> -        image = nocloud_kvm_image.NoCloudKVMImage(self, img_conf, images[0])
> -        if img_conf.get('override_templates', False):
> -            image.update_templates(self.config.get('template_overrides', {}),
> -                                   self.config.get('template_files', {}))
> +        image = nocloud_kvm_image.NoCloudKVMImage(self, img_conf,
> +                                                  sorted(images)[0])

fixed.

>          return image
>  
> -    def create_image(self, properties, config, features,
> -                     src_img_path, image_desc=None, use_desc=None,
> -                     user_data=None, meta_data=None):
> -        """Create an image
> +    def create_instance(self, properties, config, features,
> +                        src_img_path, image_desc=None, use_desc=None,
> +                        user_data=None, meta_data=None):
> +        """Create an instance
>  
>          @param src_img_path: image path to launch from
>          @param properties: image properties


-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/334147
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:fix/cii-kvmimage-preserve-original into cloud-init:master.


Follow ups

References