[PATCH 1/1] UBUNTU: SAUCE: move proxy setup to a Canonical specific catch-all

Paolo Pisati paolo.pisati at canonical.com
Tue Mar 3 11:19:16 UTC 2020


Signed-off-by: Paolo Pisati <paolo.pisati at canonical.com>
---
 client/canonical.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 client/canonical.py

diff --git a/client/canonical.py b/client/canonical.py
new file mode 100644
index 00000000..41810be6
--- /dev/null
+++ b/client/canonical.py
@@ -0,0 +1,23 @@
+"""
+Canonical specific code catch-all
+"""
+
+import os, utils
+
+def setup_proxy():
+    # Hacky way to use proxy settings, ideally this should be done on deployment stage
+    #
+    print "Setup the http/https proxy"
+    proxysets = [{'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
+              {'addr': '91.189.89.216', 'desc': 'Running in the Canonical enablement environment'},
+              {'addr': '10.245.64.1', 'desc': 'Running in the Canonical enablement environment'}]
+    for proxy in proxysets:
+        cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
+        try:
+            utils.system_output(cmd, retain_output=False)
+            print proxy['desc']
+            os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
+            os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
+            break
+        except:
+            pass
-- 
2.25.1




More information about the kernel-team mailing list