summaryrefslogtreecommitdiff
path: root/morphlib/exts/kvm.check
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/exts/kvm.check')
-rwxr-xr-xmorphlib/exts/kvm.check23
1 files changed, 20 insertions, 3 deletions
diff --git a/morphlib/exts/kvm.check b/morphlib/exts/kvm.check
index 62d76453..67cb3d38 100755
--- a/morphlib/exts/kvm.check
+++ b/morphlib/exts/kvm.check
@@ -47,6 +47,7 @@ class KvmPlusSshCheckExtension(morphlib.writeexts.WriteExtension):
self.check_no_existing_libvirt_vm(ssh_host, vm_name)
self.check_extra_disks_exist(ssh_host, self.parse_attach_disks())
self.check_virtual_networks_are_started(ssh_host)
+ self.check_host_has_virtinstall(ssh_host)
def check_and_parse_location(self, location):
'''Check and parse the location argument to get relevant data.'''
@@ -129,14 +130,22 @@ class KvmPlusSshCheckExtension(morphlib.writeexts.WriteExtension):
def name(nic_entry):
if ',' in nic_entry:
- # NETWORK_NAME,mac=12:34,model=e1000...
- return nic_entry[:nic_entry.find(',')]
+ # network=NETWORK_NAME,mac=12:34,model=e1000...
+ return nic_entry[:nic_entry.find(',')].lstrip('network=')
else:
- return nic_entry # NETWORK_NAME
+ return nic_entry.lstrip('network=') # NETWORK_NAME
if 'NIC_CONFIG' in os.environ:
nics = os.environ['NIC_CONFIG'].split()
+ for n in nics:
+ if not (n.startswith('network=')
+ or n.startswith('bridge=')
+ or n == 'user'):
+ raise cliapp.AppException('malformed NIC_CONFIG: %s\n'
+ " (expected 'bridge=BRIDGE' 'network=NAME'"
+ " or 'user')" % n)
+
# --network bridge= is used to specify a bridge
# --network user is used to specify a form of NAT
# (see the virt-install(1) man page)
@@ -148,5 +157,13 @@ class KvmPlusSshCheckExtension(morphlib.writeexts.WriteExtension):
for network in networks:
check_virtual_network_is_started(network)
+ def check_host_has_virtinstall(self, ssh_host):
+ try:
+ cliapp.ssh_runcmd(ssh_host, ['which', 'virt-install'])
+ except cliapp.AppException:
+ raise cliapp.AppException(
+ 'virt-install does not seem to be installed on host %s'
+ % ssh_host)
+
KvmPlusSshCheckExtension().run()