Bug 1155238: pass --authentication-file to tooltool
authorDustin J. Mitchell <dustin@mozilla.com>
Wed, 29 Apr 2015 11:15:59 -0400 (2015-04-29)
changeset 3929 81550ea89c735cb0af446a398eab5ca93e6d32cd
parent 3928 73c63ba904fad16e630ebbd681ad529912050784
child 3930 fbe718fe444062cc439d8ccd8736cbb77bdd6be3
push id3112
push userdmitchell@mozilla.com
push dateThu, 30 Apr 2015 14:08:17 +0000 (2015-04-30)
bugs1155238
Bug 1155238: pass --authentication-file to tooltool
mozharness/mozilla/tooltool.py
--- a/mozharness/mozilla/tooltool.py
+++ b/mozharness/mozilla/tooltool.py
@@ -1,10 +1,11 @@
 """module for tooltool operations"""
 import os
+import sys
 
 from mozharness.base.errors import PythonErrorList
 from mozharness.base.log import ERROR, FATAL
 from mozharness.mozilla.proxxy import Proxxy
 
 from mozharness.lib.python.authentication import get_credentials_path
 
 TooltoolErrorList = PythonErrorList + [{
@@ -18,18 +19,32 @@ TOOLTOOL_PY_URL = \
 TOOLTOOL_SERVERS = [
     'https://api.pub.build.mozilla.org/tooltool/',
 ]
 
 
 class TooltoolMixin(object):
     """Mixin class for handling tooltool manifests.
     To use a tooltool server other than the Mozilla server, override
-    config['tooltool_servers'].
+    config['tooltool_servers'].  To specify a different authentication
+    file than that used in releng automation,override
+    config['tooltool_authentication_file']; set it to None to not pass
+    any authentication information (OK for public files)
     """
+    def _get_auth_file(self):
+        # set the default authentication file based on platform; this
+        # corresponds to where puppet puts the token
+        if 'tooltool_authentication_file' in self.config:
+            return self.config['tooltool_authentication_file']
+
+        if self._is_windows():
+            return r'c:\builds\relengapi.tok'
+        else:
+            return '/builds/relengapi.tok'
+
     def tooltool_fetch(self, manifest, bootstrap_cmd=None,
                        output_dir=None, privileged=False, cache=None):
         """docstring for tooltool_fetch"""
         tooltool = self.query_exe('tooltool.py', return_type='list')
 
         if self.config.get("developer_mode"):
             if not os.path.exists(str(tooltool)):
                 tooltool = self._fetch_tooltool_py()
@@ -49,16 +64,21 @@ class TooltoolMixin(object):
 
         # proxxy-ify
         proxxy = Proxxy(self.config, self.log_obj)
         proxxy_urls = proxxy.get_proxies_and_urls(default_urls)
 
         for proxyied_url in proxxy_urls:
             cmd.extend(['--url', proxyied_url])
 
+        # handle authentication file, if given
+        auth_file = self._get_auth_file()
+        if auth_file:
+            cmd.extend(['--authentication-file', auth_file])
+
         cmd.extend(['fetch', '-m', manifest, '-o'])
 
         if cache:
             cmd.extend(['-c', cache])
 
         self.retry(
             self.run_command,
             args=(cmd, ),