44 lines
No EOL
1.4 KiB
Python
44 lines
No EOL
1.4 KiB
Python
import click
|
|
import subprocess
|
|
import os
|
|
|
|
from app.helper import clone, clone_common,\
|
|
clone_etcd_wrapper, GitOperation, PipenvOperation, FileOperation
|
|
|
|
@click.group()
|
|
def scheduler():
|
|
pass
|
|
|
|
|
|
@scheduler.command("setup")
|
|
@click.option("--path", required=True)
|
|
@click.option("--vm_prefix", required=True)
|
|
@click.option("--host_prefix", required=True)
|
|
@click.option("--request_prefix", required=True)
|
|
@click.option("--etcd_host", required=True)
|
|
@click.option("--etcd_port", required=True)
|
|
|
|
def setup(path, vm_prefix, host_prefix, request_prefix, etcd_host, etcd_port):
|
|
os.chdir(path)
|
|
|
|
repo_name = "ucloud-scheduler"
|
|
|
|
op_result = GitOperation.clone(f"https://code.ungleich.ch/ungleich-public/{repo_name}.git")
|
|
|
|
content = f"VM_PREFIX={vm_prefix}\n" \
|
|
f"HOST_PREFIX={host_prefix}\n" \
|
|
f"REQUEST_PREFIX={request_prefix}\n" \
|
|
f"ETCD_HOST={etcd_host}\n" \
|
|
f"ETCD_PORT={etcd_port}\n"
|
|
|
|
op_result.add(FileOperation.write,
|
|
path=os.path.join(repo_name, ".env"),
|
|
content=content)
|
|
|
|
op_result.add(GitOperation.clone, path=repo_name,
|
|
url="https://code.ungleich.ch/ungleich-public/ucloud_common")
|
|
|
|
op_result.add(GitOperation.clone, path=repo_name,
|
|
url="https://code.ungleich.ch/ahmedbilal/etcd3_wrapper")
|
|
|
|
op_result.add(PipenvOperation.install, path=repo_name) |