From: Ondrej Lichtner <olichtne(a)redhat.com>
The init_connection method is now public and the Machine object doesn't
initialize it's own connection.
Instead the connection is explicitly initialized by the SlavePoolManager
after the creation of the Machine object. This will later be used to
expose an API to the tester that will enable him to connect to slave
machines during test execution.
The method also gained a timeout parameter to limit the socket creation
duration when relevant.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 7 +++----
lnst/Controller/SlavePoolManager.py | 1 +
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 32d933f..bdfbc1e 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -87,8 +87,6 @@ class Machine(object):
self._initns = None
- self._init_connection()
-
def set_id(self, new_id):
self._id = new_id
@@ -201,7 +199,7 @@ class Machine(object):
return self._msg_dispatcher.send_message(self, msg)
- def _init_connection(self):
+ def init_connection(self, timeout=None):
""" Initialize the slave connection
This will connect to the Slave, get it's description (should be
@@ -212,7 +210,8 @@ class Machine(object):
m_id = self._id
logging.info("Connecting to RPC on machine %s (%s)", m_id, hostname)
- connection = CtlSecSocket(socket.create_connection((hostname, port)))
+ connection = CtlSecSocket(socket.create_connection((hostname, port),
+ timeout))
connection.handshake(self._security)
self._msg_dispatcher.add_slave(self, connection)
diff --git a/lnst/Controller/SlavePoolManager.py b/lnst/Controller/SlavePoolManager.py
index ea1ade9..eb6ae52 100644
--- a/lnst/Controller/SlavePoolManager.py
+++ b/lnst/Controller/SlavePoolManager.py
@@ -74,6 +74,7 @@ class SlavePoolManager(object):
pool[m_id] = Machine(m_id, hostname, self._msg_dispatcher,
ctl_config, libvirt_domain, rpc_port,
m_spec["security"])
+ pool[m_id].init_connection()
#TODO check if all described devices are available
logging.info("Finished loading pools.")
--
2.17.0