b
This commit is contained in:
parent
ed1c2cebe0
commit
0a521eac33
7 changed files with 151 additions and 17 deletions
10
app/api.py
10
app/api.py
|
|
@ -24,11 +24,11 @@ def setup(path, auth_name, auth_seed, auth_realm,
|
||||||
|
|
||||||
op_result = GitOperation.clone("https://code.ungleich.ch/ungleich-public/ucloud-api.git")
|
op_result = GitOperation.clone("https://code.ungleich.ch/ungleich-public/ucloud-api.git")
|
||||||
|
|
||||||
content = f"AUTH_NAME={auth_name}" \
|
content = f"AUTH_NAME={auth_name}\n" \
|
||||||
f"AUTH_SEED={auth_seed}" \
|
f"AUTH_SEED={auth_seed}\n" \
|
||||||
f"AUTH_REALM={auth_seed}" \
|
f"AUTH_REALM={auth_seed}\n" \
|
||||||
f"REALM_ALLOWED={list(realm_allowed)}" \
|
f"REALM_ALLOWED={list(realm_allowed)}\n" \
|
||||||
f"OTP_SERVER={otp_server}"
|
f"OTP_SERVER={otp_server}\n"
|
||||||
|
|
||||||
op_result.add(FileOperation.write,
|
op_result.add(FileOperation.write,
|
||||||
path=os.path.join("ucloud-api", ".env"),
|
path=os.path.join("ucloud-api", ".env"),
|
||||||
|
|
|
||||||
35
app/file.py
Normal file
35
app/file.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import click
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
from app.helper import clone, clone_common,\
|
||||||
|
clone_etcd_wrapper, GitOperation, PipenvOperation, FileOperation
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def file_scan():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@file_scan.command("setup")
|
||||||
|
@file_scan.option("--path", required=True)
|
||||||
|
@file_scan.option("--base_dir", required=True)
|
||||||
|
@file_scan.option("--file_prefix", required=True)
|
||||||
|
def setup(path, base_dir, file_prefix):
|
||||||
|
os.chdir(path)
|
||||||
|
|
||||||
|
repo_name = "ucloud-file-scan"
|
||||||
|
|
||||||
|
op_result = GitOperation.clone(f"https://code.ungleich.ch/ungleich-public/{repo_name}.git")
|
||||||
|
|
||||||
|
content = f"BASE_DIR={base_dir}\n" \
|
||||||
|
f"FILE_PREFIX={file_prefix}\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/ahmedbilal/etcd3_wrapper")
|
||||||
|
|
||||||
|
op_result.add(PipenvOperation.install, path=repo_name)
|
||||||
|
|
||||||
|
# Write Crontab entry
|
||||||
44
app/host.py
Normal file
44
app/host.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
import click
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
from app.helper import clone, clone_common,\
|
||||||
|
clone_etcd_wrapper, GitOperation, PipenvOperation, FileOperation
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def host():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@host.command("setup")
|
||||||
|
@click.option("--path", required=True)
|
||||||
|
@click.option("--ssh_username", required=True)
|
||||||
|
@click.option("--ssh_key_path", required=True, help="For Example, ~/.ssh/id_rsa")
|
||||||
|
@click.option("--ssh_key_pass", required=True)
|
||||||
|
@click.option("--etcd_host", required=True)
|
||||||
|
@click.option("--etcd_port", required=True)
|
||||||
|
def setup(path, ssh_username, ssh_key_path, ssh_key_pass, etcd_host, etcd_port):
|
||||||
|
os.chdir(path)
|
||||||
|
|
||||||
|
repo_name = "ucloud-vm"
|
||||||
|
|
||||||
|
op_result = GitOperation.clone(f"https://code.ungleich.ch/ungleich-public/{repo_name}.git")
|
||||||
|
|
||||||
|
|
||||||
|
content = f"ssh_username={ssh_username}\n" \
|
||||||
|
f"ssh_pkey={ssh_key_path}\n" \
|
||||||
|
f"ssh_private_key_password={ssh_key_pass}\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)
|
||||||
27
app/image.py
Normal file
27
app/image.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import click
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
from app.helper import clone, clone_common,\
|
||||||
|
clone_etcd_wrapper, GitOperation, PipenvOperation, FileOperation
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def image():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@image.command("setup")
|
||||||
|
@image.option("--path", required=True)
|
||||||
|
def setup(path):
|
||||||
|
os.chdir(path)
|
||||||
|
|
||||||
|
repo_name = "ucloud-image-scanner"
|
||||||
|
|
||||||
|
op_result = GitOperation.clone(f"https://code.ungleich.ch/ungleich-public/{repo_name}.git")
|
||||||
|
|
||||||
|
|
||||||
|
op_result.add(GitOperation.clone, path=repo_name,
|
||||||
|
url="https://code.ungleich.ch/ahmedbilal/etcd3_wrapper")
|
||||||
|
|
||||||
|
op_result.add(PipenvOperation.install, path=repo_name)
|
||||||
|
|
||||||
|
# Write Crontab entry
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
import click
|
import click
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
from app.helper import clone, clone_common,\
|
||||||
|
clone_etcd_wrapper, GitOperation, PipenvOperation, FileOperation
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def scheduler():
|
def scheduler():
|
||||||
|
|
@ -8,9 +11,34 @@ def scheduler():
|
||||||
|
|
||||||
|
|
||||||
@scheduler.command("setup")
|
@scheduler.command("setup")
|
||||||
def setup():
|
@click.option("--path", required=True)
|
||||||
command = "git clone https://code.ungleich.ch/ungleich-public/ucloud-scheduler.git"
|
@click.option("--vm_prefix", required=True)
|
||||||
try:
|
@click.option("--host_prefix", required=True)
|
||||||
subprocess.check_output(command.split())
|
@click.option("--request_prefix", required=True)
|
||||||
except subprocess.CalledProcessError as e:
|
@click.option("--etcd_host", required=True)
|
||||||
print("Some Error Occurrred", e)
|
@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)
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 9aeb05987bd1b84e7ac851ce8b84f31647e436bd
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
import click
|
import click
|
||||||
from app.api import api
|
from app.api import api
|
||||||
from app.scheduler import scheduler
|
from app.scheduler import scheduler
|
||||||
|
from app.host import host
|
||||||
|
from app.image import image
|
||||||
|
from app.file import file_scan
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def entry_point():
|
def entry_point():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
entry_point.add_command(api)
|
entry_point.add_command(api)
|
||||||
entry_point.add_command(scheduler)
|
entry_point.add_command(scheduler)
|
||||||
|
entry_point.add_command(host)
|
||||||
|
entry_point.add_command(image)
|
||||||
|
entry_point.add_command(file_scan)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
entry_point()
|
entry_point()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue