[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 95: Wait for the network to come up before trying to get the ip from the

Message ID 20110829210912.26712.16729.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Aug. 29, 2011, 9:09 p.m.
------------------------------------------------------------
revno: 95
fixes bug(s): https://launchpad.net/bugs/836700
committer: Paul Larson <paul.larson@canonical.com>
branch nick: network-upload-fix-836700
timestamp: Mon 2011-08-29 08:57:19 -0500
message:
  Wait for the network to come up before trying to get the ip from the
  master image, and some other obvious fixes/cleanups
modified:
  lava_dispatcher/actions/launch_control.py
  lava_dispatcher/client.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription

Patch

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-08-17 10:36:29 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-08-29 13:57:19 +0000
@@ -20,18 +20,19 @@ 
 # along
 # with this program; if not, see <http://www.gnu.org/licenses>.
 
+import json
 import os
-import json
+import pexpect
 import shutil
 import tarfile
 from lava_dispatcher.actions import BaseAction
-from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, LAVA_SERVER_IP
+from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR
 from lava_dispatcher.config import LAVA_IMAGE_TMPDIR
 from lava_dispatcher.client import NetworkError
 from lava_dispatcher.utils import download
+from tempfile import mkdtemp
 import time
 import xmlrpclib
-from subprocess import call
 
 class cmd_submit_results_on_host(BaseAction):
     def run(self, server, stream):
@@ -43,7 +44,7 @@ 
         bundle_list = os.listdir("/tmp/%s" % LAVA_RESULT_DIR)
         for bundle_name in bundle_list:
             bundle = "/tmp/%s/%s" % (LAVA_RESULT_DIR, bundle_name)
-            f = open(bundle) 
+            f = open(bundle)
             content = f.read()
             f.close()
             try:
@@ -106,7 +107,7 @@ 
         os.chmod(tarball_dir, 0755)
         #FIXME: need to consider exception?
         result_path = download(result_tarball, tarball_dir)
-        id = client.proc.expect([MASTER_STR, pexpect.TIMEOUT, pexpect.EOF], 
+        id = client.proc.expect([MASTER_STR, pexpect.TIMEOUT, pexpect.EOF],
                 timeout=3)
         client.run_shell_command('kill %1', response=MASTER_STR)
 
@@ -119,7 +120,7 @@ 
                 self.all_bundles.append(json.loads(content))
         tar.close()
         shutil.rmtree(tarball_dir)
-        
+
         #flush the serial log
         client.run_shell_command("")
 

=== modified file 'lava_dispatcher/client.py'
--- lava_dispatcher/client.py	2011-08-16 00:15:08 +0000
+++ lava_dispatcher/client.py	2011-08-29 13:57:19 +0000
@@ -128,6 +128,7 @@ 
 
     def get_master_ip(self):
         #get master image ip address
+        self.wait_network_up()
         #tty device uses minimal match, see pexpect wiki
         #pattern1 = ".*\n(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
         pattern1 = "(\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?)"
@@ -136,7 +137,7 @@ 
         self.proc.sendline(cmd)
         #if running from ipython, it needs another Enter, don't know why
         #self.proc.sendline("")
-        id = self.proc.expect([pattern1, pexpect.EOF, 
+        id = self.proc.expect([pattern1, pexpect.EOF,
             pexpect.TIMEOUT], timeout=5)
         print "\nid=%s" %id
         if id == 0: