Пример #1
0
def main(*args):
    tc.check()
    ssh_key = tc.secret("project/servo/ssh-keys/docker-worker-kvm")
    tc_creds = tc.secret("project/servo/tc-client/worker/docker-worker-kvm/1")
    win2016 = tc.api("awsProvisioner", "workerType", "servo-win2016")
    files_by_desc = {
        f.get("description"): f
        for f in win2016["secrets"]["files"]
    }

    def decode(description):
        f = files_by_desc[description]
        assert f["encoding"] == "base64"
        return base64.b64decode(f["content"])

    terraform_vars = dict(
        ssh_pub_key=ssh_key["public"],
        ssh_priv_key=ssh_key["private"],
        taskcluster_client_id=tc_creds["client_id"],
        taskcluster_access_token=tc_creds["access_token"],
        packet_api_key=tc.packet_auth_token(),
        ssl_certificate=decode("SSL certificate for livelog"),
        cert_key=decode("SSL key for livelog"),
    )
    env = dict(os.environ)
    env["PACKET_AUTH_TOKEN"] = terraform_vars["packet_api_key"]
    env.update({"TF_VAR_" + k: v for k, v in terraform_vars.items()})
    sys.exit(subprocess.call(["terraform"] + list(args), env=env))
Пример #2
0
def main():
    tc.check()
    global PACKET_AUTH_TOKEN
    PACKET_AUTH_TOKEN = tc.packet_auth_token()
    response = api_request("/projects/%s/devices?per_page=1000" %
                           SERVO_PROJECT_ID)
    for device in response["devices"]:
        print(device["id"])
        print("    Hostname:\t" + device["hostname"])
        print("    Plan:\t" + device["plan"]["name"])
        print("    OS: \t" + device["operating_system"]["name"])
        for address in device["ip_addresses"]:
            if address["public"]:
                print("    IPv%s:\t%s" %
                      (address["address_family"], address["address"]))
        print("    Created:\t" + device["created_at"].replace("T", " "))
        print("    Updated:\t" + device["updated_at"].replace("T", " "))
    assert response["meta"]["next"] is None
Пример #3
0
def main(*args):
    tc.check()
    ssh_key = tc.secret("project/servo/ssh-keys/docker-worker-kvm")
    tc_creds = tc.secret("project/servo/tc-client/worker/docker-worker-kvm/1")
    livelog = tc.livelog()

    terraform_vars = dict(
        ssh_pub_key=ssh_key["public"],
        ssh_priv_key=ssh_key["private"],
        taskcluster_client_id=tc_creds["client_id"],
        taskcluster_access_token=tc_creds["access_token"],
        packet_api_key=tc.packet_auth_token(),
        ssl_certificate=livelog["livelog_cert_base64"],
        cert_key=livelog["livelog_key_base64"],
    )
    env = dict(os.environ)
    env["PACKET_AUTH_TOKEN"] = terraform_vars["packet_api_key"]
    env.update({"TF_VAR_" + k: v for k, v in terraform_vars.items()})
    sys.exit(subprocess.call(["terraform"] + list(args), env=env))
Пример #4
0
def main(*args):
    tc.check()
    ssh_key = tc.secret("project/servo/ssh-keys/docker-worker-kvm")
    tc_creds = tc.secret("project/servo/tc-client/worker/docker-worker-kvm/1")
    livelog = tc.livelog()

    terraform_vars = dict(
        ssh_pub_key=ssh_key["public"],
        ssh_priv_key=ssh_key["private"],
        taskcluster_client_id=tc_creds["client_id"],
        taskcluster_access_token=tc_creds["access_token"],
        packet_api_key=tc.packet_auth_token(),
        ssl_certificate=livelog["livelog_cert_base64"],
        cert_key=livelog["livelog_key_base64"],
    )
    env = dict(os.environ)
    env["PACKET_AUTH_TOKEN"] = terraform_vars["packet_api_key"]
    env.update({"TF_VAR_" + k: v for k, v in terraform_vars.items()})
    cwd = os.path.abspath(os.path.dirname(__file__))
    sys.exit(subprocess.call(["terraform"] + list(args), env=env, cwd=cwd))
Пример #5
0
    def failing_value(args, kwargs):
        full_kwargs = {
            **default_args,
            **{name: arg
               for name, arg in zip(arg_names, args)},
            **kwargs
        }

        if len(full_kwargs) != len(spec.args):
            return ("Incorrect number of arguments", (args, kwargs))

        for name, arg in full_kwargs.items():
            template = templates[name]
            if not check(template, arg):
                return (template, arg)
        return None
Пример #6
0
def ext_pillar(_minion_id, _pillar, *_args):
    tc.check()
    data = {}
    data.update(tc.secret("project/servo/tc-client/worker/macos/1"))
    data.update(tc.livelog())
    return data
Пример #7
0
def ext_pillar(_minion_id, _pillar, *_args):
    tc.check()
    data = {}
    data.update(tc.secret("project/servo/tc-client/worker/macos/1"))
    data.update(tc.livelog())
    return data
Пример #8
0
def ext_pillar(_minion_id, _pillar, *_args):
    tc.check()
    return tc.secret("project/servo/tc-client/worker/macos/1")
Пример #9
0
"""This module demonstrates what templates there are in tc"""

import tc

if "Python types":
    assert tc.check(int, 1)
    assert tc.check(tuple, ())

if "None":
    assert tc.check(None, None)
    """
    None ≡ {None}
    """

if "tuple":
    assert tc.check((int, str), (4, "string"))
    assert tc.check((), ())
    """
    (T1, T2, ...) ≡ {(x1, x2, ...) | x(i) ∈ T(i)}
    """

if "list":
    assert tc.check([int], [1, 2, 3, 4])
    assert tc.check([int, float], [1, 2.5, 3.14, 4])
    assert tc.check([(int, float)], [(1, 2.5), (3, 4.14), (5, 0.5)])
    assert tc.check([], [])
    """
    [T1, T2, ...] ≡ {[x1, x2...] | x(i) ∈ either(T(j))}
    """

if "dict":