[node-patches] Change in ovirt-node[master]: defaults: Fix Name-/Timeservers with empty lists
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Tue Dec 11 20:09:42 UTC 2012
Fabian Deutsch has uploaded a new change for review.
Change subject: defaults: Fix Name-/Timeservers with empty lists
......................................................................
defaults: Fix Name-/Timeservers with empty lists
Change-Id: I86b52436924507d8e43df68fcc0a5be985b9443b
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/setup/network_page.py
2 files changed, 16 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/62/9962/1
diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 6031634..148fce5 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -329,6 +329,9 @@
>>> data = n.retrieve()
>>> all([servers[idx] == s for idx, s in enumerate(data["servers"])])
True
+ >>> n.update([])
+ >>> n.retrieve()
+ {'servers': None}
"""
keys = ("OVIRT_DNS",)
@@ -338,7 +341,7 @@
servers = filter(lambda i: i.strip() not in ["", None], servers)
map(valid.IPv4Address(), servers)
return {
- "OVIRT_DNS": ",".join(servers)
+ "OVIRT_DNS": ",".join(servers) or None
}
def retrieve(self):
@@ -346,7 +349,7 @@
"""
cfg = dict(NodeConfigFileSection.retrieve(self))
cfg.update({
- "servers": cfg["servers"].split(",")
+ "servers": cfg["servers"].split(",") if cfg["servers"] else None
})
return cfg
@@ -419,6 +422,9 @@
>>> data = n.retrieve()
>>> all([servers[idx] == s for idx, s in enumerate(data["servers"])])
True
+ >>> n.update([])
+ >>> n.retrieve()
+ {'servers': None}
"""
keys = ("OVIRT_NTP",)
@@ -428,13 +434,13 @@
servers = filter(lambda i: i.strip() not in ["", None], servers)
map(valid.IPv4Address(), servers)
return {
- "OVIRT_NTP": ",".join(servers)
+ "OVIRT_NTP": ",".join(servers) or None
}
def retrieve(self):
cfg = dict(NodeConfigFileSection.retrieve(self))
cfg.update({
- "servers": cfg["servers"].split(",")
+ "servers": cfg["servers"].split(",") if cfg["servers"] else None
})
return cfg
diff --git a/scripts/tui/src/ovirt/node/setup/network_page.py b/scripts/tui/src/ovirt/node/setup/network_page.py
index bd65bb2..8330191 100644
--- a/scripts/tui/src/ovirt/node/setup/network_page.py
+++ b/scripts/tui/src/ovirt/node/setup/network_page.py
@@ -62,12 +62,14 @@
def model(self):
# Pull name-/timeservers from config files (not defaults)
nameservers = defaults.Nameservers().retrieve()["servers"]
- for idx, nameserver in enumerate(nameservers):
- self._model["dns[%d]" % idx] = nameserver
+ if nameservers:
+ for idx, nameserver in enumerate(nameservers):
+ self._model["dns[%d]" % idx] = nameserver
timeservers = defaults.Timeservers().retrieve()["servers"]
- for idx, timeserver in enumerate(timeservers):
- self._model["ntp[%d]" % idx] = timeserver
+ if timeservers:
+ for idx, timeserver in enumerate(timeservers):
+ self._model["ntp[%d]" % idx] = timeserver
return self._model
--
To view, visit http://gerrit.ovirt.org/9962
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I86b52436924507d8e43df68fcc0a5be985b9443b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list