summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-05-08 17:04:45 +0100
committerTiago Gomes <tiago.gomes@codethink.co.uk>2013-05-08 16:54:17 +0000
commit2287b2a81ca8a19e41cc9edf3cb8c2c361bfa4e4 (patch)
tree2001333a311c86c8ccd18926967d0f2c0a72ed35
parent4cd3a4060146a37cdef216ee4dc346c0f7229f8c (diff)
downloaddefinitions-2287b2a81ca8a19e41cc9edf3cb8c2c361bfa4e4.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.
-rwxr-xr-xwriteexts.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/writeexts.py b/writeexts.py
index 2cdba86f..9caab839 100755
--- a/writeexts.py
+++ b/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)