diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-03-30 13:34:40 +0000 |
---|---|---|
committer | Baserock Gerrit <gerrit@baserock.org> | 2015-04-01 10:55:17 +0000 |
commit | d28595c19a5b9ee5bcacc6de4319de625024cb87 (patch) | |
tree | a5aaa752a8204bdadfc8fa3871b083d5dac02a79 /morphlib/exts | |
parent | 10ce3a9b63fdea3d36b8b646d70d9473c1d816cb (diff) | |
download | morph-d28595c19a5b9ee5bcacc6de4319de625024cb87.tar.gz |
Fix: strip 'network=' from NIC_CONFIG
Also ensure NIC_CONFIG begins with 'network=', 'bridge=' or is 'user'
Change-Id: I3bcbd25eb2c9a05b7fa276697f97a1080cb0316e
Diffstat (limited to 'morphlib/exts')
-rwxr-xr-x | morphlib/exts/kvm.check | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/morphlib/exts/kvm.check b/morphlib/exts/kvm.check index 62d76453..83562e44 100755 --- a/morphlib/exts/kvm.check +++ b/morphlib/exts/kvm.check @@ -129,14 +129,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) |