diff --git a/software/kvm/buildout.hash.cfg b/software/kvm/buildout.hash.cfg index fdc775ffcb1d5be306c0c918aaeae2501ecf6e92..e290b6c2a25164ec1332ea0eb7266de98e9dd157 100644 --- a/software/kvm/buildout.hash.cfg +++ b/software/kvm/buildout.hash.cfg @@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257 [template-kvm-run] filename = template/template-kvm-run.in -md5sum = da4947e6d67849f14b7b1ece2b945f04 +md5sum = 536c3b208fec9fa29ba6223432cd3509 [template-kvm-controller] filename = template/kvm-controller-run.in diff --git a/software/kvm/template/template-kvm-run.in b/software/kvm/template/template-kvm-run.in index 1d52330633c428d1af92811aece6847acc6ae701..f30b311e463756102f5e594a381da43d35aefc8b 100644 --- a/software/kvm/template/template-kvm-run.in +++ b/software/kvm/template/template-kvm-run.in @@ -370,7 +370,6 @@ for nbd_ip, nbd_port in nbd_list: '-drive', 'file=nbd:[%s]:%s,media=cdrom' % (nbd_ip, nbd_port)]) else: - boot_image_url_list_used = False if boot_image_url_list_json_config: # Support boot-image-url-list with open(boot_image_url_list_json_config) as fh: @@ -379,16 +378,14 @@ else: for image in sorted(image_config['image-list'], key=lambda k: k['link']): link = os.path.join(image_config['destination-directory'], image['link']) if os.path.exists(link) and os.path.islink(link): - boot_image_url_list_used = True kvm_argument_list.extend([ '-drive', 'file=%s,media=cdrom' % (link,) ]) - if not boot_image_url_list_used: - # If no NBD is specified/available not downloadable image: use internal disk image - kvm_argument_list.extend([ - '-drive', 'file=%s,media=cdrom' % default_cdrom_iso - ]) + # Always add by default the default image + kvm_argument_list.extend([ + '-drive', 'file=%s,media=cdrom' % default_cdrom_iso + ]) print('Starting KVM: \n %s' % ' '.join(kvm_argument_list)) diff --git a/software/kvm/test/test.py b/software/kvm/test/test.py index 255fdb6b093f9db40b7f7be8e04cfe3939eec50b..b24a87c40158a18cd31e79ab57194f21555f5ea5 100644 --- a/software/kvm/test/test.py +++ b/software/kvm/test/test.py @@ -563,20 +563,29 @@ class TestBootImageUrlList(InstanceTestCase): self.assertTrue(os.path.islink(image2_link)) self.assertEqual(os.readlink(image2_link), image2) + def getRunningImageList(): + running_image_list = [] + with self.slap.instance_supervisor_rpc as instance_supervisor: + kvm_pid = [q for q in instance_supervisor.getAllProcessInfo() + if 'kvm-' in q['name']][0]['pid'] + kvm_process = psutil.Process(kvm_pid) + software_root = '/'.join([ + self.slap.software_directory, + hashlib.md5(self.getSoftwareURL()).hexdigest()]) + for entry in kvm_process.cmdline(): + if entry.startswith('file') and 'media=cdrom' in entry: + # do cleanups + entry = entry.replace(software_root, '') + entry = entry.replace(self.computer_partition_root_path, '') + running_image_list.append(entry) + return running_image_list + # check that the image is NOT YET available in kvm - with self.slap.instance_supervisor_rpc as instance_supervisor: - kvm_pid = [q for q in instance_supervisor.getAllProcessInfo() - if 'kvm-' in q['name']][0]['pid'] - kvm_process = psutil.Process(kvm_pid) - cmd_line = ''.join(kvm_process.cmdline()) - self.assertNotIn( - 'srv/boot-image-url-list-repository/image_001,media=cdrom', - cmd_line - ) - self.assertNotIn( - 'srv/boot-image-url-list-repository/image_002,media=cdrom', - cmd_line - ) + self.assertEqual( + ['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' + 'media=cdrom'], + getRunningImageList() + ) # mimic the requirement: restart the instance by requesting it stopped and # then started started, like user have to do it @@ -585,20 +594,16 @@ class TestBootImageUrlList(InstanceTestCase): self.rerequestInstance(partition_parameter_kw, state='started') self.slap.waitForInstance(max_retry=1) - # now the image is available in the kvm - with self.slap.instance_supervisor_rpc as instance_supervisor: - kvm_pid = [q for q in instance_supervisor.getAllProcessInfo() - if 'kvm-' in q['name']][0]['pid'] - kvm_process = psutil.Process(kvm_pid) - cmd_line = ''.join(kvm_process.cmdline()) - self.assertIn( - 'srv/boot-image-url-list-repository/image_001,media=cdrom', - cmd_line - ) - self.assertIn( - 'srv/boot-image-url-list-repository/image_002,media=cdrom', - cmd_line - ) + # now the image is available in the kvm, and its above default image + self.assertEqual( + [ + 'file=/srv/boot-image-url-list-repository/image_001,media=cdrom', + 'file=/srv/boot-image-url-list-repository/image_002,media=cdrom', + 'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' + 'media=cdrom' + ], + getRunningImageList() + ) # cleanup of images works, also asserts that configuration changes are # reflected @@ -609,6 +614,20 @@ class TestBootImageUrlList(InstanceTestCase): [] ) + # mimic the requirement: restart the instance by requesting it stopped and + # then started started, like user have to do it + self.rerequestInstance(partition_parameter_kw, state='stopped') + self.slap.waitForInstance(max_retry=1) + self.rerequestInstance(partition_parameter_kw, state='started') + self.slap.waitForInstance(max_retry=1) + + # again only default image is available in the running process + self.assertEqual( + ['file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,' + 'media=cdrom'], + getRunningImageList() + ) + def assertPromiseFails(self, promise): monitor_run_promise = os.path.join( self.computer_partition_root_path, 'software_release', 'bin',