hobo: compute api secret by service (#7192)

This commit is contained in:
Serghei Mihai 2015-05-11 17:27:17 +02:00
parent 9e94dbe7ac
commit 3493e2fbe2
1 changed files with 10 additions and 0 deletions

View File

@ -21,6 +21,8 @@ import subprocess
import sys
import tempfile
import urllib2
import urlparse
import hashlib
from qommon.ctl import Command, make_option
from qommon.storage import atomic_write
@ -234,8 +236,11 @@ class CmdCheckHobos(Command):
config.set('hobo', 'timestamp', self.all_services.get('timestamp'))
variables = {}
api_secrets = {}
for service in self.all_services.get('services', []):
variables['%s_url' % service.get('slug')] = service.get('base_url')
domain = urlparse.urlparse(service.get('base_url')).netloc.split(':')[0]
api_secrets[domain] = hashlib.sha1(domain + service.get('secret_key')).hexdigest()
if self.all_services.get('variables'):
for key, value in self.all_services.get('variables').items():
variables[key] = value
@ -250,6 +255,11 @@ class CmdCheckHobos(Command):
value = unicode(value).encode('utf-8')
config.set('variables', key, value)
if not 'api-secrets' in config.sections():
config.add_section('api-secrets')
for key, value in api_secrets.items():
config.set('api-secrets', key, value)
if 'options' not in config.sections():
config.add_section('options')
for service in self.all_services.get('services', []):