# HG changeset patch # User Tero Marttila # Date 1396276056 -10800 # Node ID b557b472ffa11239bd25d2ceb92306489620d33a # Parent 9ac5dae42adb2fb603b44c5e041117836eec37a6 pvl.hosts: normalize host ethernet syntax diff -r 9ac5dae42adb -r b557b472ffa1 pvl/hosts.py --- a/pvl/hosts.py Mon Mar 31 17:14:51 2014 +0300 +++ b/pvl/hosts.py Mon Mar 31 17:27:36 2014 +0300 @@ -32,6 +32,13 @@ class HostConfigError (HostError) : pass +def parse_ethernet (value) : + """ + Normalize ethernet str. + """ + + return ':'.join('%02x' % int(x, 16) for x in value.split(':')) + class Host (object) : # the label used for alias4/6 hosts ALIAS4_FMT = '{host}-ipv4' @@ -143,10 +150,10 @@ if field == 'ethernet' : if instance : - ethernet[instance] = value + ethernet[instance] = parse_ethernet(value) else : for eth in value.split() : - ethernet[len(ethernet)] = eth + ethernet[len(ethernet)] = parse_ethernet(eth) else : raise ValueError("%s: Unknown host field: %s=%s" % (host, field, value))