Merge lp:~heber013/utah/fix-provisioning-function into lp:utah

Proposed by Heber Parrucci
Status: Merged
Merged at revision: 1130
Proposed branch: lp:~heber013/utah/fix-provisioning-function
Merge into: lp:utah
Diff against target: 277 lines (+78/-41)
3 files modified
conf/utah/default-vm.xml (+5/-2)
utah/provisioning/provisioning.py (+56/-37)
utah/provisioning/vm.py (+17/-2)
To merge this branch: bzr merge lp:~heber013/utah/fix-provisioning-function
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Paul Larson Pending
Review via email: mp+352837@code.launchpad.net

This proposal supersedes a proposal from 2018-07-10.

Commit message

Fixing broken provisioning function due to initrd file extension change

Description of the change

Fixing broken provisioning function due to initrd file extension change

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote : Posted in a previous version of this proposal

Looks sane, +1 assuming it works for you

review: Approve
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote : Posted in a previous version of this proposal

I think the fix is incomplete. casper/initrd and the target directory initrd have the same name and utah fails with ENOTDIR

cat: write error: Broken pipe
Unhandled error in UTAH:
Traceback (most recent call last):
  File "/usr/bin/run_utah_tests.py", line 132, in <module>
    exitstatus = timeout(config.jobtimeout, run_utah_tests)
  File "/usr/lib/python2.7/dist-packages/utah/timeout.py", line 65, in timeout
    return command(*args, **kw)
  File "/usr/bin/run_utah_tests.py", line 121, in run_utah_tests
    exitstatus, locallogs = run_tests(args, _get_machine(args))
  File "/usr/lib/python2.7/dist-packages/utah/run.py", line 344, in run_tests
    exitstatus, remote_path = _run(machine, args.runlist, extraopts)
  File "/usr/lib/python2.7/dist-packages/utah/run.py", line 256, in _run
    return _install_and_run(machine, runlist_url, extraopts)
  File "/usr/lib/python2.7/dist-packages/utah/run.py", line 174, in _install_and_run
    machine.installclient()
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py", line 315, in installclient
    self.uploadfiles([deb], tmppath)
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/ssh.py", line 202, in uploadfiles
    self.activecheck()
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/ssh.py", line 364, in activecheck
    self.provisioncheck()
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py", line 247, in provisioncheck
    config.installtimeout, self._provision, provision_data)
  File "/usr/lib/python2.7/dist-packages/utah/timeout.py", line 75, in timeout
    retval = command(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py", line 364, in _provision
    self._create(provision_data)
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/vm.py", line 522, in _create
    self._copy_qemu_scripts(tmpdir=tmpdir)
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py", line 717, in _copy_qemu_scripts
    self.copy_qemu_scripts_to_path(initrd_work_dir)
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py", line 1010, in copy_qemu_scripts_to_path
    shutil.copy2(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 20] Not a directory: '/var/lib/utah/vm/utah_vm_V0OnwPlGppPWxuFE/tmpcIvRKW/initrd/qemu-setup.py'

review: Needs Fixing
Revision history for this message
Heber Parrucci (heber013) wrote : Posted in a previous version of this proposal

I tried fixing _copy_qemu_scripts and some more errors. Now I am getting an error in the function _preseedcasper:

2018-08-06 17:17:13,086 root WARNING: Command (sed -i 1i/scripts/casper-bottom/utah\n[ -e /conf/param.conf ] && . /conf/param.conf /var/lib/utah/vm/utah-21-cosmic-amd64/tmp7jWHqv/initrd.d/scripts/casper-bottom/ORDER) failed with return code: 2

1130. By Heber Parrucci

Fixing issue when repacking initrd

1131. By Heber Parrucci

Fixing utah tests:
* Adding more memory to created VMs
* Adding video type qxl
* Adding retries when starting the VM with vm.create()

1132. By Heber Parrucci

Increasing wait period default value when starting the virtual machine

1133. By Heber Parrucci

Updating logic on first VM boot

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for this patch.

It fixes the problem with desktop images but breaks server tests.

The error is:

INFO: logpath was already set by /etc/utah/config
2018-09-10 03:00:05,890 cleanup WARNING: OSError when changing directory permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865-cosmic-server-amd64/disk0.qcow2'
2018-09-10 03:00:05,890 cleanup WARNING: OSError when changing directory permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865-cosmic-server-amd64/tmpBBkVPS/initrd.gz'
2018-09-10 03:00:05,891 cleanup WARNING: OSError when changing directory permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865-cosmic-server-amd64/tmpBBkVPS/kernel'
2018-09-10 03:00:05,891 cleanup WARNING: OSError when changing directory permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865-cosmic-server-amd64/tmpBBkVPS/cosmic-server-amd64.iso'
Unhandled error in UTAH:
Traceback (most recent call last):
  File "/usr/bin/run_utah_tests.py", line 132, in <module>
    exitstatus = timeout(config.jobtimeout, run_utah_tests)
  File "/usr/lib/python2.7/dist-packages/utah/timeout.py", line 65, in timeout
    return command(*args, **kw)
  File "/usr/bin/run_utah_tests.py", line 121, in run_utah_tests
    exitstatus, locallogs = run_tests(args, _get_machine(args))
  File "/usr/lib/python2.7/dist-packages/utah/run.py", line 344, in run_tests
    exitstatus, remote_path = _run(machine, args.runlist, extraopts)
  File "/usr/lib/python2.7/dist-packages/utah/run.py", line 256, in _run
    return _install_and_run(machine, runlist_url, extraopts)
  File "/usr/lib/python2.7/dist-packages/utah/run.py", line 174, in _install_and_run
    machine.installclient()
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py", line 316, in installclient
    self.uploadfiles([deb], tmppath)
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/ssh.py", line 202, in uploadfiles
    self.activecheck()
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/ssh.py", line 366, in activecheck
    self._start()
  File "/usr/lib/python2.7/dist-packages/utah/provisioning/vm.py", line 570, in _start
    self.vm.create()
  File "/usr/lib/python2.7/dist-packages/libvirt.py", line 1035, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: Requested operation is not valid: domain is already running

+ RETCODE=4

review: Needs Fixing
1134. By Heber Parrucci

Fixing start vm function

Revision history for this message
Heber Parrucci (heber013) wrote :

> Thanks for this patch.
>
> It fixes the problem with desktop images but breaks server tests.
>
> The error is:
>
> INFO: logpath was already set by /etc/utah/config
> 2018-09-10 03:00:05,890 cleanup WARNING: OSError when changing directory
> permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865
> -cosmic-server-amd64/disk0.qcow2'
> 2018-09-10 03:00:05,890 cleanup WARNING: OSError when changing directory
> permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865
> -cosmic-server-amd64/tmpBBkVPS/initrd.gz'
> 2018-09-10 03:00:05,891 cleanup WARNING: OSError when changing directory
> permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865
> -cosmic-server-amd64/tmpBBkVPS/kernel'
> 2018-09-10 03:00:05,891 cleanup WARNING: OSError when changing directory
> permissions: [Errno 1] Operation not permitted: '/var/lib/utah/vm/utah-74865
> -cosmic-server-amd64/tmpBBkVPS/cosmic-server-amd64.iso'
> Unhandled error in UTAH:
> Traceback (most recent call last):
> File "/usr/bin/run_utah_tests.py", line 132, in <module>
> exitstatus = timeout(config.jobtimeout, run_utah_tests)
> File "/usr/lib/python2.7/dist-packages/utah/timeout.py", line 65, in timeout
> return command(*args, **kw)
> File "/usr/bin/run_utah_tests.py", line 121, in run_utah_tests
> exitstatus, locallogs = run_tests(args, _get_machine(args))
> File "/usr/lib/python2.7/dist-packages/utah/run.py", line 344, in run_tests
> exitstatus, remote_path = _run(machine, args.runlist, extraopts)
> File "/usr/lib/python2.7/dist-packages/utah/run.py", line 256, in _run
> return _install_and_run(machine, runlist_url, extraopts)
> File "/usr/lib/python2.7/dist-packages/utah/run.py", line 174, in
> _install_and_run
> machine.installclient()
> File "/usr/lib/python2.7/dist-packages/utah/provisioning/provisioning.py",
> line 316, in installclient
> self.uploadfiles([deb], tmppath)
> File "/usr/lib/python2.7/dist-packages/utah/provisioning/ssh.py", line 202,
> in uploadfiles
> self.activecheck()
> File "/usr/lib/python2.7/dist-packages/utah/provisioning/ssh.py", line 366,
> in activecheck
> self._start()
> File "/usr/lib/python2.7/dist-packages/utah/provisioning/vm.py", line 570,
> in _start
> self.vm.create()
> File "/usr/lib/python2.7/dist-packages/libvirt.py", line 1035, in create
> if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
> libvirtError: Requested operation is not valid: domain is already running
>
> + RETCODE=4

It should be fixed now. Thanks!

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks. Tested on Xenial with cosmic and bionic images of Desktop and server.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'conf/utah/default-vm.xml'
--- conf/utah/default-vm.xml 2016-02-04 16:28:14 +0000
+++ conf/utah/default-vm.xml 2018-09-10 14:38:14 +0000
@@ -20,8 +20,8 @@
20<domain type='qemu'>20<domain type='qemu'>
21 <name>Utah Example</name>21 <name>Utah Example</name>
22 <uuid>00000000-0000-0000-0000-000000000000</uuid>22 <uuid>00000000-0000-0000-0000-000000000000</uuid>
23 <memory>524288</memory>23 <memory>1048576</memory>
24 <currentMemory>524288</currentMemory>24 <currentMemory>1048576</currentMemory>
25 <vcpu>1</vcpu>25 <vcpu>1</vcpu>
26 <os>26 <os>
27 <type arch='i686' machine='pc'>hvm</type>27 <type arch='i686' machine='pc'>hvm</type>
@@ -49,6 +49,9 @@
49 <model type='virtio'/>49 <model type='virtio'/>
50 </interface>50 </interface>
51 <graphics type='vnc' autoport='yes'/>51 <graphics type='vnc' autoport='yes'/>
52 <video>
53 <model type='qxl' vram='16384' heads='1'/>
54 </video>
52 </devices>55 </devices>
53</domain>56</domain>
5457
5558
=== modified file 'utah/provisioning/provisioning.py'
--- utah/provisioning/provisioning.py 2018-07-07 16:12:04 +0000
+++ utah/provisioning/provisioning.py 2018-09-10 14:38:14 +0000
@@ -25,6 +25,7 @@
25import re25import re
26import shutil26import shutil
27import stat27import stat
28import subprocess
28import sys29import sys
29import urllib30import urllib
30import uuid31import uuid
@@ -321,7 +322,7 @@
321 'File not found: {filename}; '322 'File not found: {filename}; '
322 'UTAH was probably updated during the run. '323 'UTAH was probably updated during the run. '
323 'Please try again.'324 'Please try again.'
324 .format(filename=deb),325 .format(filename=deb),
325 retry=True)326 retry=True)
326 raise err327 raise err
327 except AttributeError:328 except AttributeError:
@@ -508,8 +509,8 @@
508 raise UTAHProvisioningException(509 raise UTAHProvisioningException(
509 '{cls} attempted to call the {method} method '510 '{cls} attempted to call the {method} method '
510 'of the base Machine class, which is not implemented'511 'of the base Machine class, which is not implemented'
511 .format(cls=self.__class__.__name__,512 .format(cls=self.__class__.__name__,
512 method=method))513 method=method))
513514
514 def cleanfile(self, path):515 def cleanfile(self, path):
515 """Register a path to be cleaned later.516 """Register a path to be cleaned later.
@@ -558,7 +559,6 @@
558559
559560
560class CustomInstallMixin(object):561class CustomInstallMixin(object):
561
562 """Provide routines for automating an install from an image."""562 """Provide routines for automating an install from an image."""
563563
564 def _preparekernel(self, kernel=None, tmpdir=None):564 def _preparekernel(self, kernel=None, tmpdir=None):
@@ -661,15 +661,24 @@
661 if os.path.splitext(initrd)[1] == '.gz':661 if os.path.splitext(initrd)[1] == '.gz':
662 self.logger.debug('Using gzip based on file extension')662 self.logger.debug('Using gzip based on file extension')
663 pipe.prepend('zcat $IN', 'f-')663 pipe.prepend('zcat $IN', 'f-')
664 pipe.append('cpio -ivd 2>/dev/null', '-.')
665 exitstatus = pipe.copy(initrd, '/dev/null')
666 self.initrd_uncompressed_path = os.path.join(tmpdir, 'initrd.d')
667 self.initrd_no_extension = False
664 elif os.path.splitext(initrd)[1] == '.lz':668 elif os.path.splitext(initrd)[1] == '.lz':
665 self.logger.debug('Using lzma based on file extension')669 self.logger.debug('Using lzma based on file extension')
666 pipe.prepend('lzcat -S .lz $IN', 'f-')670 pipe.prepend('lzcat -S .lz $IN', 'f-')
671 pipe.append('cpio -ivd 2>/dev/null', '-.')
672 exitstatus = pipe.copy(initrd, '/dev/null')
673 self.initrd_uncompressed_path = os.path.join(tmpdir, 'initrd.d')
674 self.initrd_no_extension = False
675 elif not os.path.splitext(initrd)[1]:
676 exitstatus = subprocess.check_call(['unmkinitramfs', initrd, os.getcwd()])
677 self.initrd_uncompressed_path = os.path.join(tmpdir, 'initrd.d', 'main')
678 self.initrd_no_extension = True
667 else:679 else:
668 raise UTAHProvisioningException(680 raise UTAHProvisioningException(
669 'initrd file does have have gz or lz extension: {}'681 'initrd file does have have gz or lz extension or no extension: {}'.format(initrd))
670 .format(initrd))
671 pipe.append('cpio -ivd 2>/dev/null', '-.')
672 exitstatus = pipe.copy(initrd, '/dev/null')
673 if exitstatus != 0:682 if exitstatus != 0:
674 # Currently this comes up as 512 when things seem fine683 # Currently this comes up as 512 when things seem fine
675 # TODO: refactor this and check for codes at all stages684 # TODO: refactor this and check for codes at all stages
@@ -683,10 +692,10 @@
683 if tmpdir is None:692 if tmpdir is None:
684 tmpdir = self.tmpdir693 tmpdir = self.tmpdir
685 shutil.copyfile(config.sshpublickey,694 shutil.copyfile(config.sshpublickey,
686 os.path.join(tmpdir, 'initrd.d', 'utah-ssh-key'))695 os.path.join(self.initrd_uncompressed_path, 'utah-ssh-key'))
687696
688 self.logger.info('Creating latecommand scripts')697 self.logger.info('Creating latecommand scripts')
689 filename = os.path.join(tmpdir, 'initrd.d', 'utah-latecommand')698 filename = os.path.join(self.initrd_uncompressed_path, 'utah-latecommand')
690 template.write('utah-latecommand.jinja2',699 template.write('utah-latecommand.jinja2',
691 filename,700 filename,
692 user=config.user,701 user=config.user,
@@ -696,19 +705,22 @@
696 install_type=self.image.installtype,705 install_type=self.image.installtype,
697 md5=self.image.getmd5())706 md5=self.image.getmd5())
698707
699 filename = os.path.join(tmpdir, 'initrd.d', 'utah-setup')708 filename = os.path.join(self.initrd_uncompressed_path, 'utah-setup')
700 template.write('utah-setup.jinja2',709 template.write('utah-setup.jinja2',
701 filename,710 filename,
702 packages=config.installpackages,711 packages=config.installpackages,
703 log_file='/var/log/utah-install')712 log_file='/var/log/utah-install')
704713
705 filename = os.path.join(tmpdir, 'initrd.d', 'utah-autorun.sh')714 filename = os.path.join(self.initrd_uncompressed_path, 'utah-autorun.sh')
706 template.write('utah-autorun.sh.jinja2',715 template.write('utah-autorun.sh.jinja2',
707 filename,716 filename,
708 log_file='/var/log/utah-install')717 log_file='/var/log/utah-install')
709718
710 def _copy_qemu_scripts(self, tmpdir=None):719 def _copy_qemu_scripts(self, tmpdir=None):
711 initrd_work_dir = os.path.join(tmpdir, 'initrd')720 if self.initrd_no_extension:
721 initrd_work_dir = self.initrd_uncompressed_path
722 else:
723 initrd_work_dir = os.path.join(tmpdir, 'initrd')
712 if not os.path.exists(initrd_work_dir):724 if not os.path.exists(initrd_work_dir):
713 os.makedirs(initrd_work_dir)725 os.makedirs(initrd_work_dir)
714 # copy the qemu scripts into initrd726 # copy the qemu scripts into initrd
@@ -736,8 +748,8 @@
736 if self.image.installtype == 'desktop':748 if self.image.installtype == 'desktop':
737 self._rewrite_failure_command(preseed)749 self._rewrite_failure_command(preseed)
738750
739 output_preseed_filename = os.path.join(tmpdir,751 output_preseed_filename = os.path.join(self.initrd_uncompressed_path,
740 'initrd.d', 'preseed.cfg')752 'preseed.cfg')
741 with open(output_preseed_filename, 'w') as f:753 with open(output_preseed_filename, 'w') as f:
742 f.write(preseed.dump())754 f.write(preseed.dump())
743 self.finalpreseed = output_preseed_filename755 self.finalpreseed = output_preseed_filename
@@ -766,7 +778,7 @@
766 question.prepend('ubiquity ubiquity/summary note')778 question.prepend('ubiquity ubiquity/summary note')
767 question.prepend('ubiquity ubiquity/reboot boolean true')779 question.prepend('ubiquity ubiquity/reboot boolean true')
768780
769 filename = os.path.join(tmpdir, 'initrd.d', 'latecommand-wrapper')781 filename = os.path.join(self.initrd_uncompressed_path, 'latecommand-wrapper')
770 target_log_file = '/target{}'.format(log_file)782 target_log_file = '/target{}'.format(log_file)
771 template.write('latecommand-wrapper.jinja2',783 template.write('latecommand-wrapper.jinja2',
772 filename,784 filename,
@@ -838,10 +850,8 @@
838 self.logger.info('Inserting preseed into casper')850 self.logger.info('Inserting preseed into casper')
839 if tmpdir is None:851 if tmpdir is None:
840 tmpdir = self.tmpdir852 tmpdir = self.tmpdir
841853 casper_dir = os.path.join(os.path.join(self.initrd_uncompressed_path, 'scripts',
842 casper_dir = os.path.join(tmpdir, 'initrd.d', 'scripts',854 'casper-bottom'))
843 'casper-bottom')
844
845 filename = os.path.join(casper_dir, 'utah')855 filename = os.path.join(casper_dir, 'utah')
846 template.write('casper-preseed-script.jinja2', filename)856 template.write('casper-preseed-script.jinja2', filename)
847 os.chmod(filename, 0755)857 os.chmod(filename, 0755)
@@ -856,7 +866,7 @@
856 if exitstatus != 0:866 if exitstatus != 0:
857 raise UTAHProvisioningException('Failed to setup casper script')867 raise UTAHProvisioningException('Failed to setup casper script')
858868
859 casper_file = os.path.join(tmpdir, 'initrd.d', 'etc', 'casper.conf')869 casper_file = os.path.join(self.initrd_uncompressed_path, 'etc', 'casper.conf')
860 tmpfilename = '{}.tmp'.format(casper_file)870 tmpfilename = '{}.tmp'.format(casper_file)
861 with open(casper_file, 'r') as i:871 with open(casper_file, 'r') as i:
862 with open(tmpfilename, 'w') as o:872 with open(tmpfilename, 'w') as o:
@@ -879,7 +889,7 @@
879 """889 """
880 if tmpdir is None:890 if tmpdir is None:
881 tmpdir = self.tmpdir891 tmpdir = self.tmpdir
882 inittab = os.path.join(tmpdir, 'initrd.d', 'etc', 'inittab')892 inittab = os.path.join(self.initrd_uncompressed_path, 'etc', 'inittab')
883 if os.path.isfile(inittab):893 if os.path.isfile(inittab):
884 self.logger.info('Updating inittab')894 self.logger.info('Updating inittab')
885 with open(inittab, 'a') as myfile:895 with open(inittab, 'a') as myfile:
@@ -889,7 +899,7 @@
889 "-f /var/log/syslog \n")899 "-f /var/log/syslog \n")
890900
891 self.logger.info('Creating rsyslog config file')901 self.logger.info('Creating rsyslog config file')
892 conffilename = os.path.join(tmpdir, 'initrd.d', '50-utahdefault.conf')902 conffilename = os.path.join(self.initrd_uncompressed_path, '50-utahdefault.conf')
893 with open(conffilename, 'w') as f:903 with open(conffilename, 'w') as f:
894 if self.rsyslog.port:904 if self.rsyslog.port:
895 ip = self._ipaddr(config.bridge)905 ip = self._ipaddr(config.bridge)
@@ -909,21 +919,30 @@
909 self.logger.info('Repacking initrd')919 self.logger.info('Repacking initrd')
910 if tmpdir is None:920 if tmpdir is None:
911 tmpdir = self.tmpdir921 tmpdir = self.tmpdir
912 pipe = pipes.Template()922 if self.initrd_no_extension:
913 pipe.prepend('find .', '.-')923 os.chdir(self.initrd_uncompressed_path)
914 pipe.append('cpio --quiet -o -H newc', '--')924 pipe = pipes.Template()
915 # Desktop image loads initrd.gz,925 pipe.prepend('find .', '.-')
916 # but for physical machines we should stick with lz926 pipe.append('cpio --quiet -o -H newc', '--')
917 if self.image.installtype == 'desktop':927 initrd = os.path.join(tmpdir, 'initrd')
918 self.logger.debug('Using lzma because installtype is desktop')928 if pipe.copy('/dev/null', initrd) != 0:
919 pipe.append('lzma -9fc ', '--')929 raise UTAHProvisioningException('Failed to repack initrd')
920 initrd = os.path.join(tmpdir, 'initrd.lz')
921 else:930 else:
922 self.logger.debug('Using gzip because installtype is not desktop')931 pipe = pipes.Template()
923 pipe.append('gzip -9fc ', '--')932 pipe.prepend('find .', '.-')
924 initrd = os.path.join(tmpdir, 'initrd.gz')933 pipe.append('cpio --quiet -o -H newc', '--')
925 if pipe.copy('/dev/null', initrd) != 0:934 # Desktop image loads initrd.gz,
926 raise UTAHProvisioningException('Failed to repack initrd')935 # but for physical machines we should stick with lz
936 if self.image.installtype == 'desktop':
937 self.logger.debug('Using lzma because installtype is desktop')
938 pipe.append('lzma -9fc ', '--')
939 initrd = os.path.join(tmpdir, 'initrd.lz')
940 else:
941 self.logger.debug('Using gzip because installtype is not desktop')
942 pipe.append('gzip -9fc ', '--')
943 initrd = os.path.join(tmpdir, 'initrd.gz')
944 if pipe.copy('/dev/null', initrd) != 0:
945 raise UTAHProvisioningException('Failed to repack initrd')
927 return initrd946 return initrd
928947
929 def _cmdlinesetup(self):948 def _cmdlinesetup(self):
930949
=== modified file 'utah/provisioning/vm.py'
--- utah/provisioning/vm.py 2017-07-06 18:03:17 +0000
+++ utah/provisioning/vm.py 2018-09-10 14:38:14 +0000
@@ -220,6 +220,7 @@
220 os.makedirs(self.directory)220 os.makedirs(self.directory)
221 except OSError as err:221 except OSError as err:
222 raise UTAHVMProvisioningException(err)222 raise UTAHVMProvisioningException(err)
223 self.first_boot = True
223 self.logger.debug('CustomVM init finished')224 self.logger.debug('CustomVM init finished')
224225
225 def _createdisks(self, disksizes=None):226 def _createdisks(self, disksizes=None):
@@ -552,12 +553,26 @@
552 if self.poweroff:553 if self.poweroff:
553 self.cleanfunction(self.vm.shutdown, force=True)554 self.cleanfunction(self.vm.shutdown, force=True)
554555
555 def _start(self):556 def _start(self, retries=6, wait=10):
556 """Start the VM."""557 """Start the VM."""
557 self.logger.info('Starting CustomVM')558 self.logger.info('Starting CustomVM')
559 attempt = 1
558 if self.vm is not None:560 if self.vm is not None:
559 if self.vm.isActive() == 0:561 # For desktop tests the first boot configures the qemu script to run system tests and
562 # shuts down the machine, so we start the machine and wait until it shuts down,
563 # then we start it again and continue
564 if self.image.installtype == 'desktop' and self.first_boot:
560 self.vm.create()565 self.vm.create()
566 while self.vm.isActive() == 1 and attempt <= retries:
567 self.logger.info('Waiting for the VM to shut down, attempt number: %s', attempt)
568 time.sleep(wait)
569 attempt += 1
570 if self.vm.isActive() == 0:
571 self.vm.create()
572 self.first_boot = False
573 else:
574 if self.vm.isActive() == 0:
575 self.vm.create()
561 else:576 else:
562 raise UTAHVMProvisioningException('Failed to provision VM')577 raise UTAHVMProvisioningException('Failed to provision VM')
563578

Subscribers

People subscribed via source and target branches