mirror of
https://github.com/servo/servo.git
synced 2025-07-10 17:03:40 +01:00
… in scripts for deploying new Macstadium or Packet.net workers. CC: https://bugzilla.mozilla.org/show_bug.cgi?id=1375182#c6
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
import base64
|
|
import subprocess
|
|
|
|
|
|
def check():
|
|
try:
|
|
subprocess.check_output(["taskcluster", "version"])
|
|
except FileNotFoundError: # noqa: F821
|
|
sys.exit("taskcluster CLI tool not available. Install it from "
|
|
"https://github.com/taskcluster/taskcluster-cli#installation")
|
|
|
|
if "TASKCLUSTER_CLIENT_ID" not in os.environ or "TASKCLUSTER_ACCESS_TOKEN" not in os.environ:
|
|
sys.exit("Taskcluster API credentials not available. Run this command and try again:\n\n"
|
|
"eval `taskcluster signin`\n")
|
|
|
|
|
|
def livelog():
|
|
win2016 = secret("worker-type:aws-provisioner-v1/servo-win2016")
|
|
files = win2016["files"]
|
|
assert all(f["encoding"] == "base64" for f in files)
|
|
files = {f.get("description"): f["content"] for f in files}
|
|
cert = files["SSL certificate for livelog"]
|
|
key = files["SSL key for livelog"]
|
|
return {
|
|
"livelog_cert_base64": cert,
|
|
"livelog_key_base64": key,
|
|
"livelog_cert": base64.b64decode(cert),
|
|
"livelog_key": base64.b64decode(key),
|
|
"livelog_secret": win2016["config"]["livelogSecret"],
|
|
}
|
|
|
|
|
|
def packet_auth_token():
|
|
return secret("project/servo/packet.net-api-key")["key"]
|
|
|
|
|
|
def secret(name):
|
|
return api("secrets", "get", name)["secret"]
|
|
|
|
|
|
def api(*args):
|
|
args = ["taskcluster", "api"] + list(args)
|
|
output = subprocess.check_output(args)
|
|
if output:
|
|
return json.loads(output)
|