コード例 #1
0
def upload(
    dir: TFilename,
    target_name: str,
    skills: List[str],
    flip: bool = DEFAULT_FLIP,
):
    target = targets.get(target_name)

    url = target["thingpedia.url"]
    token = target["thingpedia.access-token"]

    if len(skills) == 1 and skills[0] == "demo":
        return upload_demo(dir, url, token)

    LOG.info("Uploading skills...", url=url, skills=skills)

    upload_run(
        dir,
        url,
        token,
        "./scripts/upload-all.sh",
        *skills,
    )

    if flip:
        flip_cmd(["skills"], target_name)
コード例 #2
0
def tail(pod_names: List[str], target_name: str, tail_lines: int):
    target = targets.get(target_name)
    namespace = target["k8s.namespace"]
    context = target.get("k8s.context")

    LOG.info(
        "Tailing pods...",
        context=context,
        namespace=namespace,
    )

    config.load_kube_config(context=context)
    api_v1 = client.CoreV1Api()
    all_pods = api_v1.list_namespaced_pod(namespace).items
    pods = [pod for pod in all_pods if match_pod_name(pod_names, pod)]

    if len(pods) == 0:
        LOG.error(
            "No pods found.",
            pod_names=pod_names,
            available_pods=sorted([pod.metadata.name for pod in all_pods]),
        )
        raise err.UserError("No pods found.")

    if len(pods) == 1:
        tail_one(api_v1, pods[0].metadata.name, namespace, tail_lines)

    tail_many(api_v1, [pod.metadata.name for pod in pods], namespace)
コード例 #3
0
ファイル: create.py プロジェクト: stanford-oval/almond-cloud
def create(debug: bool = DEFAULT_DEBUG):
    target = targets.get("local")

    if debug:
        src = CONFIG.kust.kustomizations_dir / "debug" / "nlp"
    else:
        src = CONFIG.kust.kustomizations_dir / "dev" / "nlp"

    kustard.apply(src, kubectl_context=target.get("k8s.context"))
コード例 #4
0
def flip(pod_names: List[str], target_name: str):
    target = targets.get(target_name)
    namespace = target["k8s.namespace"]
    context = target.get("k8s.context")
    expanded_names = expand_names(pod_names)

    LOG.debug(
        "Flipping...",
        arg_names=pod_names,
        expanded_names=expanded_names,
        context=context,
        namespace=namespace,
    )

    config.load_kube_config(context=context)
    api_v1 = client.CoreV1Api()
    all_pods = api_v1.list_namespaced_pod(namespace).items
    pods = [pod for pod in all_pods if match_pod_name(expanded_names, pod)]

    for pod in pods:
        LOG.info("Deleting pod...", name=pod.metadata.name)
        api_v1.delete_namespaced_pod(pod.metadata.name, namespace)
コード例 #5
0
ファイル: get.py プロジェクト: stanford-oval/almond-cloud
def get(target_name: str):
    return targets.get(target_name)