From 8eb3f6fc6f55c5fe46ffb679b3116e69d59e4c98 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Thu, 16 Mar 2017 13:26:54 -0400 Subject: [PATCH] Add an "activate" script for PDC. --- bootstrap/activate-in-pdc.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bootstrap/activate-in-pdc.py diff --git a/bootstrap/activate-in-pdc.py b/bootstrap/activate-in-pdc.py new file mode 100644 index 00000000..d3aed879 --- /dev/null +++ b/bootstrap/activate-in-pdc.py @@ -0,0 +1,22 @@ +import json +import requests +import os +import sys + +import pdc_client + +servername, token, variant_uid = sys.argv[-3], sys.argv[-2], sys.argv[-1] + +if os.path.basename(__file__) in (servername, token,): + raise ValueError("Provide a PDC server name defined in /etc/pdc.d/ and a token") + +print("Connecting to PDC server %r with token %r" % (servername, token)) +pdc = pdc_client.PDCClient(servername, token=token) + +print("Querying for %r to see if it is inactive" % variant_uid) +obj = pdc['unreleasedvariants'][variant_uid]() +assert obj['active'] == False, obj['active'] + +print("Submitting PATCH to activate.") +pdc['unreleasedvariants'][variant_uid] += {'variant_uid': variant_uid, 'active': True} +print("Done.")