ubuntu-bugcontrol team mailing list archive
-
ubuntu-bugcontrol team
-
Mailing list archive
-
Message #04828
[Merge] ~wqian/ubuntu-qa-tools:postcmd_feat into ubuntu-qa-tools:master
Alan Moore has proposed merging ~wqian/ubuntu-qa-tools:postcmd_feat into ubuntu-qa-tools:master.
Commit message:
- Adds a new feature which allows vm to execute "post install" command before creating the pristine image so that one can add some permanent change/effect to the pristine status, e.g. run pro attach to transfer a normal image into a pro enabled one.
- (Pro)Detach the machine before removing it and ignore the result to avoid running out of quota.
- Fix indent of message
Requested reviews:
Ubuntu Bug Control (ubuntu-bugcontrol)
For more details, see:
https://code.launchpad.net/~wqian/ubuntu-qa-tools/+git/ubuntu-qa-tools/+merge/490758
--
Your team Ubuntu Bug Control is requested to review the proposed merge of ~wqian/ubuntu-qa-tools:postcmd_feat into ubuntu-qa-tools:master.
diff --git a/vm-tools/uvt b/vm-tools/uvt
index 683ce0a..66efd8b 100755
--- a/vm-tools/uvt
+++ b/vm-tools/uvt
@@ -232,6 +232,10 @@ def cmd_new():
print("Verifying lsb_release and waiting 30 minutes for post-installation to finish...")
print("(in case of problems, see /var/log/vm-new.log in the guest)")
+ if uvt_conf['vm_postcmd']:
+ vm_run_command(vm_name, uvt_conf['vm_postcmd'], root = True, start = True,
+ force_keys = True, quiet = not opt.verbose)
+
command = "lsb_release -c | grep -q " + release + " || " + \
"echo '*** WARNING *** LSB release is not " + release + "' ;" + \
"while [ -r /etc/network/if-up.d/postinstall ]; do sleep 5; done"
@@ -784,6 +788,23 @@ def cmd_remove():
if not confirm("Do you want to continue?"):
continue
+ if vm_running(machine) == False:
+ vm_start(machine)
+ if vm_start_wait(machine, quiet=True) == False:
+ print("Could not start VM: %s" % machine)
+ return False
+
+ # Wait a couple of seconds for the DHCP to settle down
+ time.sleep(2)
+
+ command = ("pro detach --assume-yes")
+ vm_run_command(machine, command, root=True, force_keys=True)
+
+ vm_stop(machine)
+ if not vm_stop_wait(machine, quiet=True):
+ print("Error: VM '%s' could not be stopped." % machine, file=sys.stderr)
+ return False
+
if vm_running(machine) == True:
print("Destroying '%s'" % machine)
vm_destroy(machine)
@@ -3424,6 +3445,11 @@ def create_uvt_config():
#vm_latecmd=""
#
+# vm_postcmd: This allows specifying an additional postcommand that is
+# executed by the installed os before creating pristine snapshot.
+#vm_postcmd=""
+
+#
# vm_extra_packages: A list of extra packages can be specified here to be
# installed in the VM, for example, "screen". Empty by
# default. It is also possible to create ISO-type
@@ -3645,6 +3671,8 @@ def load_uvt_config():
config['vm_aptproxy'] = ""
if not 'vm_latecmd' in config:
config['vm_latecmd'] = ""
+ if not 'vm_postcmd' in config:
+ config['vm_postcmd'] = ""
if config.get('vm_connect', "") == "":
config['vm_connect'] = "qemu:///system"
if not 'vm_extra_packages' in config:
@@ -3703,7 +3731,7 @@ def load_uvt_config():
(re.search("mask::..x", out) is None)):
print("Missing permissions found while creating '%s' directory. libvirt-qemu user "
- "requires search permission all the way up the path, but it seems to be"
+ "requires search permission all the way up the path, but it seems to be "
"missing on directory '%s'" % (d, path))
print("If you wish to change the location where '%s' is "
"stored, you can launch 'uvt config', which will create "