>From b2ddf7e9d434ea33619ced976f61e59d2d20ab71 Mon Sep 17 00:00:00 2001
From: yogananth subramanian <[email protected]>
Date: Wed, 10 Feb 2010 06:15:29 -0500
Subject: [PATCH 1/5] kvm test: unattended install: change host role from
server to client

By changing the role of the host from server to client, we can do
unattended install in parallel. Similar change has to be made in the
unattended installfile(kickstart, xml) to make them behave as server
rather as client.

Signed-off-by: yogananth subramanian <[email protected]>
---
 client/tests/kvm/tests/unattended_install.py |   38
++++++++++++-------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/client/tests/kvm/tests/unattended_install.py
b/client/tests/kvm/tests/unattended_install.py
index e3df72a..3978e26 100644
--- a/client/tests/kvm/tests/unattended_install.py
+++ b/client/tests/kvm/tests/unattended_install.py
@@ -13,11 +13,11 @@ def run_unattended_install(test, params, env):
     @param params: Dictionary with the test parameters.
     @param env: Dictionary with test environment.
     """
+    buf = 1024
     vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
 
-    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    server.bind(('', 12323))
-    server.listen(1)
+    port = vm.get_port(int(params.get("guest_port_unattend_shell")))
+    addr = ('localhost', port)
 
     install_timeout = float(params.get("timeout", 3000))
     logging.info("Starting unattended install watch process. "
@@ -26,21 +26,19 @@ def run_unattended_install(test, params, env):
     start_time = time.time()
 
     while True:
-        server.settimeout(install_timeout)
+        client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         try:
-            (client, addr) = server.accept()
-        except socket.timeout:
-            server.close()
-            raise error.TestFail('Timeout elapsed while waiting for
install to '
-                                 'finish.')
-        msg = client.recv(1024)
-        logging.debug("Received '%s' from %s", msg, addr)
-        if msg == 'done':
-            end_time = time.time()
-            time_elapsed = int(end_time - start_time)
-            logging.info('Guest reported successful installation after
%ds '
-                         '(%d min)', time_elapsed, time_elapsed/60)
-            server.close()
-            break
-        else:
-            logging.error('Got invalid string from client: %s.' % msg)
+            client.connect(addr)
+            msg = client.recv(1024)
+            if msg == 'thank u for connecting':
+                break
+            else:
+                raise Exception
+        except:
+            time.sleep(1)
+            client.close()
+
+    end_time = time.time()
+    time_elapsed = int(end_time - start_time)
+    logging.info('Guest reported successful installation after %ds '
+                 '(%d min)', time_elapsed, time_elapsed/60)
-- 
1.6.2.5



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to