diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 361: Use apt-get -o to specify proxy instead of configuration file to reduce proxy setting issue

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

Commit Message

Spring Zhang Aug. 1, 2012, 4:37 p.m. UTC
Merge authors:
  Spring Zhang (qzhang)
Related merge proposals:
  https://code.launchpad.net/~qzhang/lava-dispatcher/fix-apt-proxy-failure/+merge/117304
  proposed by: Spring Zhang (qzhang)
  review: Approve - Andy Doan (doanac)
  review: Resubmit - Spring Zhang (qzhang)
------------------------------------------------------------
revno: 361 [merge]
committer: Spring Zhang <spring.zhang@linaro.org>
branch nick: lava-dispatcher
timestamp: Thu 2012-08-02 00:35:40 +0800
message:
  Use apt-get -o to specify proxy instead of configuration file to reduce proxy setting issue
modified:
  lava_dispatcher/actions/lava-test.py
  lava_dispatcher/client/base.py
  lava_dispatcher/context.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
diff mbox

Patch

=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py	2012-07-24 04:00:12 +0000
+++ lava_dispatcher/actions/lava-test.py	2012-08-01 15:41:23 +0000
@@ -29,12 +29,12 @@ 
 
 def _install_lava_test(client, session):
     #install bazaar in tester image
-    session.run('apt-get update')
+    session.run('%s update' % client.aptget_cmd)
     #Install necessary packages for build lava-test
-    cmd = ('apt-get -y --force-yes install '
+    cmd = ('%s -y --force-yes install '
            'bzr usbutils python-apt python-setuptools '
            'python-simplejson lsb-release python-keyring '
-           'python-pip')
+           'python-pip' % client.aptget_cmd)
     session.run(cmd, timeout=2400)
 
     dispatcher_config = client.context.config
@@ -42,7 +42,8 @@ 
     lava_test_deb = dispatcher_config.get("LAVA_TEST_DEB", "")
     if lava_test_deb != "":
         logging.debug("Installing %s with apt-get" % lava_test_deb)
-        session.run("apt-get -y --force-yes install " + lava_test_deb)
+        session.run("%s -y --force-yes install %s"
+            % (client.aptget_cmd, lava_test_deb))
     else:
         lava_test_url = dispatcher_config.get("LAVA_TEST_URL")
         logging.debug("Installing %s with pip" % lava_test_url)
@@ -144,11 +145,6 @@ 
             lava_proxy = self.client.context.lava_proxy
             if lava_proxy:
                 session.run("sh -c 'export http_proxy=%s'" % lava_proxy)
-                session.run("echo 'Acquire::http::proxy \"%s\";' > /etc/apt/apt.conf.d/30proxy" % lava_proxy)
-            else:
-                # If the rootfs is new generated, the cmd will fail,
-                # just ignore it
-                session.run("rm -f /etc/apt/apt.conf.d/30proxy")
 
             if install_lava_test:
                 _install_lava_test(self.client, session)
@@ -162,7 +158,8 @@ 
             if install_deb:
                 debs = " ".join(install_deb)
                 self.run_command_with_test_result(
-                    session, "apt-get -y --force-yes install " + debs,
+                    session, "%s -y --force-yes install %s"
+                    % (self.client.aptget_cmd, debs),
                     'lava_test_install deb (%s)' % debs, timeout=timeout)
 
             if register:
@@ -201,9 +198,10 @@ 
         with self.client.reliable_session() as session:
 
             #install add-apt-repository
-            session.run('apt-get -y install python-software-properties')
+            session.run('%s -y install python-software-properties'
+                % self.client.aptget_cmd)
 
             #add ppa
             for repository in arg:
                 session.run('add-apt-repository %s < /dev/null' % repository)
-            session.run('apt-get update')
+            session.run('%s update' % self.client.aptget_cmd)

=== modified file 'lava_dispatcher/client/base.py'
--- lava_dispatcher/client/base.py	2012-07-23 02:58:42 +0000
+++ lava_dispatcher/client/base.py	2012-08-01 15:41:23 +0000
@@ -274,6 +274,8 @@ 
         self.config = config
         self.sio = SerialIO(sys.stdout)
         self.proc = None
+        # used for apt-get in lava-test.py
+        self.aptget_cmd = "apt-get"
 
     def device_option(self, option_name, *extra):
         return self.config.get(option_name, *extra)
@@ -394,13 +396,8 @@ 
             # take around 15-20 seconds.
             self.proc.sendline("export http_proxy=%s" % lava_proxy)
             self.proc.expect(prompt_str, timeout=30)
-            self.proc.sendline("echo 'Acquire::http::proxy \"%s\";' > /etc/apt/apt.conf.d/30proxy" % lava_proxy)
-            self.proc.expect(prompt_str, timeout=30)
-        else:
-            # If the rootfs is new generated, the cmd will fail, just ignore it
-            self.proc.sendline("rm -f /etc/apt/apt.conf.d/30proxy")
-            self.proc.expect(prompt_str, timeout=30)
-
+            self.aptget_cmd = ' '.join([self.aptget_cmd,
+                "-o Acquire::http::proxy=%s" % lava_proxy])
 
     def boot_master_image(self):
         raise NotImplementedError(self.boot_master_image)

=== modified file 'lava_dispatcher/context.py'
--- lava_dispatcher/context.py	2012-06-15 20:37:40 +0000
+++ lava_dispatcher/context.py	2012-07-30 17:03:46 +0000
@@ -60,10 +60,7 @@ 
 
     @property
     def lava_proxy(self):
-        proxy = self.config.get("LAVA_PROXY", "")
-        if proxy == "":
-            proxy = None
-        return proxy
+        return self.config.get("LAVA_PROXY", None)
 
     @property
     def lava_cookies(self):