Commit 9cf44a8a by Feanil Patel

Change how abby gets notified.

We were previously using the jenkins api which was more complicated than the
buildByTokens plugin and its API.
parent ba0fd895
...@@ -42,7 +42,6 @@ deployments: ...@@ -42,7 +42,6 @@ deployments:
# A jenkins URL to post requests for building AMIs # A jenkins URL to post requests for building AMIs
abbey_url: "http://...." abbey_url: "http://...."
abbey_token: "API_TOKEN"
--- ---
""" """
import argparse import argparse
...@@ -154,7 +153,7 @@ def prepare_release(args): ...@@ -154,7 +153,7 @@ def prepare_release(args):
if not args.noop: if not args.noop:
release_coll.insert(release) release_coll.insert(release)
# All plays that need new AMIs have been updated. # All plays that need new AMIs have been updated.
notify_abbey(config['abbey_url'], config['abbey_token'], args.deployment, notify_abbey(config['abbey_url'], args.deployment,
all_plays, args.release_id, mongo_uri, config_repo_ver, all_plays, args.release_id, mongo_uri, config_repo_ver,
config_secure_ver, args.noop) config_secure_ver, args.noop)
...@@ -173,33 +172,31 @@ def ami_for(db, env, deployment, play, configuration, ...@@ -173,33 +172,31 @@ def ami_for(db, env, deployment, play, configuration,
return db.amis.find_one(ami_signature) return db.amis.find_one(ami_signature)
import requests import requests
def notify_abbey(abbey_url, abbey_token, deployment, all_plays, release_id, def notify_abbey(abbey_url, deployment, all_plays, release_id,
mongo_uri, configuration_ref, configuration_secure_ref, noop=False): mongo_uri, configuration_ref, configuration_secure_ref, noop=False):
for play_name, play in all_plays.items(): for play_name, play in all_plays.items():
for env, ami in play['amis'].items(): for env, ami in play['amis'].items():
if ami is None: if ami is None:
params = [] params = {}
params.append({ 'name': 'play', 'value': play_name}) params['play'] = play_name
params.append({ 'name': 'deployment', 'value': deployment}) params['deployment'] = deployment
params.append({ 'name': 'environment', 'value': env}) params['environment'] = env
params.append({ 'name': 'vars', 'value': yaml.safe_dump(play['vars'], default_flow_style=False)}) params['vars'] = yaml.safe_dump(play['vars'], default_flow_style=False)
params.append({ 'name': 'release_id', 'value': release_id}) params['release_id'] = release_id
params.append({ 'name': 'mongo_uri', 'value': mongo_uri}) params['mongo_uri'] = mongo_uri
params.append({ 'name': 'configuration', 'value': configuration_ref}) params['configuration'] = configuration_ref
params.append({ 'name': 'configuration_secure', 'value': configuration_secure_ref}) params['configuration_secure'] = configuration_secure_ref
build_params = {'parameter': params}
log.info("Need ami for {}".format(pformat(params)))
log.info("Need ami for {}".format(pformat(build_params)))
if not noop: if not noop:
r = requests.post(abbey_url, r = requests.post(abbey_url,
data={"token": abbey_token}, params=params)
params={"json": json.dumps(build_params)})
log.info("Sent request got {}".format(r)) log.info("Sent request got {}".format(r))
if r.status_code != 201: if r.status_code != 200:
# Something went wrong. # Something went wrong.
msg = "Failed to submit request with params: {}" msg = "Failed to submit request with params: {}"
raise Exception(msg.format(pformat(build_params))) raise Exception(msg.format(pformat(params)))
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Prepare a new release.") parser = argparse.ArgumentParser(description="Prepare a new release.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment