Permalink
Browse files

Bug 702595 - write initial balrog admin client to support nightly bui…

…ld submissions. r=bhearsum
  • Loading branch information...
1 parent 8971952 commit d3004c243cc96fc24b9ed0ec8f88c893f101178f @rail rail committed Mar 27, 2012
Showing with 7,356 additions and 1 deletion.
  1. 0 lib/python/balrog/__init__.py
  2. 0 lib/python/balrog/client/__init__.py
  3. +60 −0 lib/python/balrog/client/api.py
  4. +80 −0 lib/python/balrog/client/cli.py
  5. +1 −1 lib/python/release/platforms.py
  6. +417 −0 lib/python/vendor/requests-0.10.8/HISTORY.rst
  7. +13 −0 lib/python/vendor/requests-0.10.8/LICENSE
  8. +1 −0 lib/python/vendor/requests-0.10.8/MANIFEST.in
  9. +25 −0 lib/python/vendor/requests-0.10.8/NOTICE
  10. +515 −0 lib/python/vendor/requests-0.10.8/PKG-INFO
  11. +76 −0 lib/python/vendor/requests-0.10.8/README.rst
  12. +515 −0 lib/python/vendor/requests-0.10.8/requests.egg-info/PKG-INFO
  13. +41 −0 lib/python/vendor/requests-0.10.8/requests.egg-info/SOURCES.txt
  14. +1 −0 lib/python/vendor/requests-0.10.8/requests.egg-info/dependency_links.txt
  15. +2 −0 lib/python/vendor/requests-0.10.8/requests.egg-info/requires.txt
  16. +1 −0 lib/python/vendor/requests-0.10.8/requests.egg-info/top_level.txt
  17. +33 −0 lib/python/vendor/requests-0.10.8/requests/__init__.py
  18. +116 −0 lib/python/vendor/requests-0.10.8/requests/api.py
  19. +106 −0 lib/python/vendor/requests-0.10.8/requests/async.py
  20. +148 −0 lib/python/vendor/requests-0.10.8/requests/auth.py
  21. +105 −0 lib/python/vendor/requests-0.10.8/requests/compat.py
  22. +48 −0 lib/python/vendor/requests-0.10.8/requests/defaults.py
  23. +32 −0 lib/python/vendor/requests-0.10.8/requests/exceptions.py
  24. +48 −0 lib/python/vendor/requests-0.10.8/requests/hooks.py
  25. +816 −0 lib/python/vendor/requests-0.10.8/requests/models.py
  26. +3 −0 lib/python/vendor/requests-0.10.8/requests/packages/__init__.py
  27. +3 −0 lib/python/vendor/requests-0.10.8/requests/packages/oreos/__init__.py
  28. +24 −0 lib/python/vendor/requests-0.10.8/requests/packages/oreos/core.py
  29. +773 −0 lib/python/vendor/requests-0.10.8/requests/packages/oreos/monkeys.py
  30. +399 −0 lib/python/vendor/requests-0.10.8/requests/packages/oreos/structures.py
  31. +48 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/__init__.py
  32. +131 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/_collections.py
  33. +629 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/connectionpool.py
  34. +67 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/exceptions.py
  35. +74 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/filepost.py
  36. +4 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/packages/__init__.py
  37. +47 −0 ...n/vendor/requests-0.10.8/requests/packages/urllib3/packages/mimetools_choose_boundary/__init__.py
  38. +372 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/packages/six.py
  39. +61 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
  40. +138 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/poolmanager.py
  41. +147 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/request.py
  42. +191 −0 lib/python/vendor/requests-0.10.8/requests/packages/urllib3/response.py
  43. +300 −0 lib/python/vendor/requests-0.10.8/requests/sessions.py
  44. +86 −0 lib/python/vendor/requests-0.10.8/requests/status_codes.py
  45. +66 −0 lib/python/vendor/requests-0.10.8/requests/structures.py
  46. +463 −0 lib/python/vendor/requests-0.10.8/requests/utils.py
  47. +5 −0 lib/python/vendor/requests-0.10.8/setup.cfg
  48. +67 −0 lib/python/vendor/requests-0.10.8/setup.py
  49. +1 −0 lib/python/vendorlibs.pth
  50. +21 −0 misc/mozilla-root.crt
  51. +36 −0 scripts/updates/balrog-client.py
No changes.
No changes.
@@ -0,0 +1,60 @@
+# TODO: extend API to handle release blobs
+
+import logging
+import requests
+import os
+
+CA_BUNDLE = os.path.join(os.path.dirname(__file__),
+ '../../../../misc/mozilla-root.crt')
+
+
+class API(object):
+
+ url_template = \
+ '%(api_root)s/releases/%(name)s/builds/%(build_target)s/%(locale)s'
+
+ verify = False
+ auth = None
+
+ def __init__(self, api_root='https://balrog.build.mozilla.org',
+ auth=None, ca_certs=CA_BUNDLE, timeout=60, raise_exceptions=True):
+ """ Creates an API object which wraps REST API of Balrog server.
+
+ api_root: API root URL of balrog server
+ auth : a tuple of (username, password) or None
+ ca_certs: CA bundle. It follows python-requests `verify' usage.
+ If set to False, no SSL verification is done.
+ If set to True, it tries to load a CA bundle from certifi
+ module.
+ If set to string, puthon-requests uses it as a pth to path to
+ CA bundle.
+ timeout : request timeout
+ raise_exceptions: Sets danger_mode parameter of python-requests config
+ which controls excpetion raising.
+ """
+ self.api_root = api_root.rstrip('/')
+ self.verify = ca_certs
+ assert isinstance(auth, tuple) or auth == None, \
+ "auth should be set to tuple or None"
+ self.auth = auth
+ self.timeout = timeout
+ self.config = dict(danger_mode=raise_exceptions)
+
+ def request(self, url, data=None, method='GET'):
+ logging.debug('Balrog request to %s' % url)
+ logging.debug('Data sent: %s' % data)
+ return requests.request(method=method, url=url, data=data,
+ config=self.config, timeout=self.timeout,
+ verify=self.verify, auth=self.auth)
+
+ def update_build(self, name, product, version, build_target, locale,
+ details, copy_to=None):
+ url_template_vars = dict(api_root=self.api_root, name=name,
+ locale=locale, build_target=build_target)
+ url = self.url_template % url_template_vars
+ data = dict(product=product, version=version,
+ details=details)
+ if copy_to:
+ data['copy_to'] = copy_to
+
+ return self.request(method='PUT', url=url, data=data)
@@ -0,0 +1,80 @@
+try:
+ import simplejson as json
+except ImportError:
+ import json
+
+from release.platforms import buildbot2updatePlatforms
+from balrog.client.api import API
+
+
+def get_nightly_blob_name(appName, branch, build_type, suffix, dummy=False):
+ if dummy:
+ branch = '%s-dummy' % branch
+ return '%s-%s-%s-%s' % (appName, branch, build_type, suffix)
+
+
+class NightlyRunner(object):
+
+ build_type = 'nightly'
+ appName = None
+ branch = None
+ build_target = None
+ appVersion = None
+ name = None
+ locale = None
+
+ def __init__(self, buildprops_file, api_root, auth, dummy=False):
+ self.buildbprops_file = buildprops_file
+ self.api_root = api_root
+ self.auth = auth
+ self.dummy = dummy
+
+ def generate_blob(self):
+ fp = open(self.buildbprops_file)
+ bp = json.load(fp)
+ fp.close()
+
+ props = bp['properties']
+ self.build_target = buildbot2updatePlatforms(props['platform'])[0]
+ buildID = props['buildid']
+
+ self.appName = props['appName']
+ self.branch = props['branch']
+ self.appVersion = props['appVersion']
+ self.name = get_nightly_blob_name(self.appName, self.branch,
+ self.build_type, buildID, self.dummy)
+ self.locale = props.get('locale', 'en-US')
+ blob = {
+ 'appv': self.appVersion,
+ 'extv': props.get('extVersion', self.appVersion),
+ 'buildID': props['buildid'],
+ }
+ blob['complete'] = {
+ 'from': '*',
+ 'filesize': props['completeMarSize'],
+ 'hashValue': props['completeMarHash'],
+ 'fileUrl': props['completeMarUrl']
+ }
+ if props.get('partialMarFilename'):
+ blob['partial'] = {
+ 'from': get_nightly_blob_name(self.appName, self.branch,
+ self.build_type,
+ props['previous_buildid'],
+ self.dummy),
+ 'filesize': props['partialMarSize'],
+ 'hashValue': props['partialMarHash'],
+ 'fileUrl': props['partialMarUrl']
+ }
+ return blob
+
+ def run(self):
+ blob = self.generate_blob()
+ blob = json.dumps(blob)
+ api = API(auth=self.auth, api_root=self.api_root)
+ copy_to = [get_nightly_blob_name(
+ self.appName, self.branch, self.build_type, 'latest', self.dummy)]
+ copy_to = repr(copy_to)
+ api.update_build(name=self.name, product=self.appName,
+ build_target=self.build_target,
+ version=self.appVersion, locale=self.locale,
+ details=blob, copy_to=copy_to)
@@ -49,7 +49,7 @@ def shippedlocales2buildbot(platform):
return [platform]
def buildbot2updatePlatforms(platform):
- return update_platform_map.get(platform, platform)
+ return update_platform_map.get(platform, [platform])
def getPlatformLocales(shipped_locales, platforms):
platform_locales = {}
Oops, something went wrong.

0 comments on commit d3004c2

Please sign in to comment.