diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-05-08 17:04:45 +0100 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2013-05-08 16:54:17 +0000 |
commit | 1b2f2013bb85769352e82cfd55a3179fe16ccce2 (patch) | |
tree | d967860c2601d32c67f415fb8f8a310d18364306 /morphlib/writeexts.py | |
parent | be72eb1771b0d83bf3a48ac2e59255dc8644e665 (diff) | |
download | morph-1b2f2013bb85769352e82cfd55a3179fe16ccce2.tar.gz |
Add AUTOSTART to kvm and libvirt write extensions
If AUTOSTART is 'yes' then the VM will be started once it is
created. If it is 'no' or undefined, then it will need to be manually
started. If it is any other value, then an exception is raised.
Diffstat (limited to 'morphlib/writeexts.py')
-rwxr-xr-x | morphlib/writeexts.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index 2cdba86f..9caab839 100755 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -228,3 +228,15 @@ class WriteExtension(cliapp.Application): return s.split(':') else: return [] + + def parse_autostart(self): + '''Parse $AUTOSTART to determine if VMs should be started.''' + + autostart = os.environ.get('AUTOSTART', 'no') + if autostart == 'no': + return False + elif autostart == 'yes': + return True + else: + raise cliapp.AppException('Unexpected value for AUTOSTART: %s' % + autostart) |