in netinfo output (ci-info:), fill in empty fields with a "."
If you were trying to parse this output with something, an empty field would be difficult to handle, as you'd have to know the expected lengths of each field. The '.' means empty, but then all fields are non-whitespace delimited by one or more whitespace.
This commit is contained in:
parent
ccdf959986
commit
46131d2db2
@ -20,6 +20,7 @@
|
||||
- add test case framework [Mike Milner] (LP: #890851)
|
||||
- fix pylint warnings [Juerg Haefliger] (LP: #914739)
|
||||
- add support for adding and deleting CA Certificates [Mike Milner] (LP: #915232)
|
||||
- in ci-info lines, use '.' to indicate empty field for easier machine reading
|
||||
0.6.2:
|
||||
- fix bug where update was not done unless update was explicitly set.
|
||||
It would not be run if 'upgrade' or packages were set to be installed
|
||||
|
@ -22,7 +22,7 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
def netdev_info():
|
||||
def netdev_info(empty=""):
|
||||
fields = ("hwaddr", "addr", "bcast", "mask")
|
||||
ifcfg_out = str(subprocess.check_output(["ifconfig", "-a"]))
|
||||
devs = {}
|
||||
@ -59,6 +59,13 @@ def netdev_info():
|
||||
pass
|
||||
elif toks[i].startswith("%s:" % field):
|
||||
devs[curdev][target] = toks[i][len(field) + 1:]
|
||||
|
||||
if empty != "":
|
||||
for (devname, dev) in devs.iteritems():
|
||||
for field in dev:
|
||||
if dev[field] == "":
|
||||
dev[field] = empty
|
||||
|
||||
return(devs)
|
||||
|
||||
|
||||
@ -85,7 +92,7 @@ def getgateway():
|
||||
def debug_info(pre="ci-info: "):
|
||||
lines = []
|
||||
try:
|
||||
netdev = netdev_info()
|
||||
netdev = netdev_info(empty=".")
|
||||
except Exception:
|
||||
lines.append("netdev_info failed!")
|
||||
netdev = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user