commit b0e03a8119d6d5c0974b182cb5ed3c52e8787337 Author: Ondrej Lichtner olichtne@redhat.com Date: Mon Oct 27 17:11:43 2014 +0100
SlavePool: small object construction fixes
This patch fixes some small problems in the SlavePool methods responsible for Machine object construction.
When the machine isn't virtual it doesn't need the libvirt_domain parameter. This can could cause exceptions when the match wasn't virtual but the machine had the parameter defined and lnst-ctl wasn't running with root privileges.
Proper initialization of the network parameter for interfaces. This is purely so that it doesn't cause confusion in the future. Unused interfaces don't have any network.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com Signed-off-by: Jiri Pirko jiri@resnulli.us
lnst/Controller/SlavePool.py | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) --- diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py index 53f402f..cbe177d 100644 --- a/lnst/Controller/SlavePool.py +++ b/lnst/Controller/SlavePool.py @@ -271,15 +271,11 @@ class SlavePool:
hostname = pm["params"]["hostname"]
- libvirt_domain = None - if "libvirt_domain" in pm["params"]: - libvirt_domain = pm["params"]["libvirt_domain"] - rpcport = None if "rpc_port" in pm["params"]: rpcport = pm["params"]["rpc_port"]
- machine = Machine(tm_id, hostname, libvirt_domain, rpcport) + machine = Machine(tm_id, hostname, None, rpcport)
used = [] if_map = self._map["machines"][tm_id]["interfaces"] @@ -287,19 +283,19 @@ class SlavePool: used.append(p_if) if_data = pm["interfaces"][p_if]
+ iface = machine.new_static_interface(t_if, "eth") + iface.set_hwaddr(if_data["params"]["hwaddr"]) + for t_net, p_net in self._map["networks"].iteritems(): if pm["interfaces"][p_if]["network"] == p_net: + iface.set_network(t_net) break
- iface = machine.new_static_interface(t_if, "eth") - iface.set_hwaddr(if_data["params"]["hwaddr"]) - iface.set_network(t_net) - for if_id, if_data in pm["interfaces"].iteritems(): if if_id not in used: iface = machine.new_unused_interface("eth") iface.set_hwaddr(if_data["params"]["hwaddr"]) - iface.set_network(t_net) + iface.set_network(None)
return machine
@@ -320,7 +316,7 @@ class SlavePool: for if_id, if_data in pm["interfaces"].iteritems(): iface = machine.new_unused_interface("eth") iface.set_hwaddr(if_data["params"]["hwaddr"]) - iface.set_network(if_data["network"]) + iface.set_network(None)
# add all the other devices for if_id, if_data in tm["interfaces"].iteritems():
lnst-developers@lists.fedorahosted.org