From abbf68d5f15a30ce4bfe3760c44ea849f0f688a6 Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Tue, 17 Sep 2019 17:43:30 +0500 Subject: [PATCH] a --- app/api.py | 19 +++---------------- app/cli.py | 17 +++-------------- app/file.py | 13 +++++-------- app/host.py | 20 ++++---------------- app/image.py | 14 +++++--------- app/scheduler.py | 16 +++------------- 6 files changed, 23 insertions(+), 76 deletions(-) diff --git a/app/api.py b/app/api.py index dd08528..cf37e80 100644 --- a/app/api.py +++ b/app/api.py @@ -1,10 +1,8 @@ import click import subprocess as sp import os -import shutil from app.helper import install_available -from decouple import config @click.group() def api(): @@ -20,15 +18,16 @@ def api(): @click.option("--etcd_url", required=True) @click.option("--otp_server", default="https://otp.ungleich.ch/ungleichotp/", help="URL of ungleich OTP server") +@click.option("--branch", default="master") def setup(path, auth_name, auth_seed, auth_realm, - realm_allowed, otp_server, etcd_url): + realm_allowed, otp_server, etcd_url, branch): os.chdir(path) repo_name = "ucloud-api" # Clone main repo - sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip', + sp.check_output(['git', 'clone', '--single-branch', '--branch', branch, f'https://code.ungleich.ch/ungleich-public/{repo_name}.git']) # Create .env file @@ -49,21 +48,9 @@ def setup(path, auth_name, auth_seed, auth_realm, ) f.writelines(content) - # Clone Common and Etcd Wrapper - # clone_common(path=repo_name) - # clone_etcd_wrapper(path=repo_name) - - # Copy Etcd Wrapper inside ucloud_common as ucloud_common - # also needs etcd wrapper - # shutil.copytree( - # src=os.path.join(repo_name, "etcd3_wrapper"), - # dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), - # ) - install_available(repo_name) # Create virtualenv with site-packages enabled and install all dependencies - # sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name) sp.check_output(['pipenv', 'install'], cwd=repo_name) sp.check_output(['pipenv', 'run', 'python', 'create_image_store.py'], cwd=repo_name) \ No newline at end of file diff --git a/app/cli.py b/app/cli.py index e14983a..78195eb 100644 --- a/app/cli.py +++ b/app/cli.py @@ -16,13 +16,14 @@ def cli(): @click.option("--name", required=True) @click.option("--realm", required=True) @click.option("--seed", required=True) -def setup(path, api_server, name, realm, seed): +@click.option("--branch", default="master") +def setup(path, api_server, name, realm, seed, branch): os.chdir(path) repo_name = "ucloud-cli" # Clone main repo - sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip', + sp.check_output(['git', 'clone', '--single-branch', '--branch', branch, f'https://code.ungleich.ch/ucloud/{repo_name}.git']) # Create .env file @@ -35,19 +36,7 @@ def setup(path, api_server, name, realm, seed): ) f.writelines(content) - # Clone Common and Etcd Wrapper - # clone_common(path=repo_name) - # clone_etcd_wrapper(path=repo_name) - - # Copy Etcd Wrapper inside ucloud_common as ucloud_common - # also needs etcd wrapper - # shutil.copytree( - # src=os.path.join(repo_name, "etcd3_wrapper"), - # dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), - # ) - install_available(repo_name) # Create virtualenv with site-packages enabled and install all dependencies - # sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name) sp.check_output(['pipenv', 'install'], cwd=repo_name) \ No newline at end of file diff --git a/app/file.py b/app/file.py index c2c2950..655f342 100644 --- a/app/file.py +++ b/app/file.py @@ -2,7 +2,7 @@ import click import subprocess as sp import os -from app.helper import clone_etcd_wrapper, install_available +from app.helper import install_available @click.group() def file_scan(): @@ -14,13 +14,14 @@ def file_scan(): @click.option("--base_dir", required=True) @click.option("--file_prefix", required=True) @click.option("--etcd_url", required=True) -def setup(path, base_dir, file_prefix, etcd_url): +@click.option("--branch", default="master") +def setup(path, base_dir, file_prefix, etcd_url, branch): os.chdir(path) repo_name = "ucloud-file-scan" # Clone main repository - sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip', + sp.check_output(['git', 'clone', '--single-branch', '--branch', branch, f'https://code.ungleich.ch/ungleich-public/{repo_name}.git']) # Create .env file @@ -37,14 +38,10 @@ def setup(path, base_dir, file_prefix, etcd_url): f"FILE_PREFIX=/v1/file/\n" ) f.writelines(content) - - # Clone etcd wrapper - # clone_etcd_wrapper(path=repo_name) - + install_available(repo_name) # Create virtualenv with site-packages enabled and install all dependencies - # sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name) sp.check_output(['pipenv', 'install'], cwd=repo_name) # TODO: Devuan/Debian have crontab under /etc/crontab diff --git a/app/host.py b/app/host.py index 5c35a6c..b645f51 100644 --- a/app/host.py +++ b/app/host.py @@ -1,9 +1,8 @@ import click import subprocess as sp import os -import shutil -from app.helper import clone_common, clone_etcd_wrapper, install_available +from app.helper import install_available @click.group() @@ -18,13 +17,14 @@ def host(): @click.option("--ssh_key_pass", required=True) @click.option("--etcd_url", required=True) @click.option("--without_ceph", default=False, type=bool) -def setup(path, ssh_username, ssh_key_path, ssh_key_pass, etcd_url, without_ceph): +@click.option("--branch", default="master") +def setup(path, ssh_username, ssh_key_path, ssh_key_pass, etcd_url, without_ceph, branch): os.chdir(path) repo_name = "ucloud-vm" # Clone main repo - sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip', + sp.check_output(['git', 'clone', '--single-branch', '--branch', branch, f'https://code.ungleich.ch/ungleich-public/{repo_name}.git']) # Create .env file @@ -44,19 +44,7 @@ def setup(path, ssh_username, ssh_key_path, ssh_key_pass, etcd_url, without_ceph ) f.writelines(content) - # Clone Common and Etcd Wrapper - # clone_common(path=repo_name) - # clone_etcd_wrapper(path=repo_name) - - # Copy Etcd Wrapper inside ucloud_common as ucloud_common - # also needs etcd wrapper - # shutil.copytree( - # src=os.path.join(repo_name, "etcd3_wrapper"), - # dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), - # ) - install_available(repo_name) # Create virtualenv with site-packages enabled and install all dependencies - # sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name) sp.check_output(['pipenv', 'install'], cwd=repo_name) \ No newline at end of file diff --git a/app/image.py b/app/image.py index 1263927..dfcf005 100644 --- a/app/image.py +++ b/app/image.py @@ -2,7 +2,7 @@ import click import subprocess as sp import os -from app.helper import clone_etcd_wrapper, install_available +from app.helper import install_available @click.group() def image(): @@ -14,13 +14,14 @@ def image(): @click.option("--base_dir", required=True) @click.option("--etcd_url", required=True) @click.option("--without_ceph", default=False, type=bool) -def setup(path, base_dir, etcd_url, without_ceph): +@click.option("--branch", default="master") +def setup(path, base_dir, etcd_url, without_ceph, branch): os.chdir(path) repo_name = "ucloud-image-scanner" # Clone main repo - sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip', + sp.check_output(['git', 'clone', '--single-branch', '--branch', branch, f'https://code.ungleich.ch/ungleich-public/{repo_name}.git']) # Create .env file @@ -37,14 +38,9 @@ def setup(path, base_dir, etcd_url, without_ceph): f"FILE_PREFIX=/v1/file/\n" ) f.writelines(content) - - - # clone_etcd_wrapper(path=repo_name) - + install_available(repo_name) - # Create virtualenv with site-packages enabled and install all dependencies - # sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name) sp.check_output(['pipenv', 'install'], cwd=repo_name) # TODO: Devuan/Debian have crontab under /etc/crontab diff --git a/app/scheduler.py b/app/scheduler.py index f81ccb1..f506a85 100644 --- a/app/scheduler.py +++ b/app/scheduler.py @@ -17,13 +17,14 @@ def scheduler(): @click.option("--host_prefix", required=True) @click.option("--request_prefix", required=True) @click.option("--etcd_url", required=True) -def setup(path, vm_prefix, host_prefix, request_prefix, etcd_url): +@click.option("--branch", default="master") +def setup(path, vm_prefix, host_prefix, request_prefix, etcd_url, branch): os.chdir(path) repo_name = "ucloud-scheduler" # Clone main repo - sp.check_output(['git', 'clone', '--single-branch', '--branch', 'wip', + sp.check_output(['git', 'clone', '--single-branch', '--branch', branch, f'https://code.ungleich.ch/ungleich-public/{repo_name}.git']) # Create .env file @@ -42,19 +43,8 @@ def setup(path, vm_prefix, host_prefix, request_prefix, etcd_url): ) f.writelines(content) - # Clone Common and Etcd Wrapper - # clone_common(path=repo_name) - # clone_etcd_wrapper(path=repo_name) - - # Copy Etcd Wrapper inside ucloud_common as ucloud_common - # also needs etcd wrapper - # shutil.copytree( - # src=os.path.join(repo_name, "etcd3_wrapper"), - # dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), - # ) install_available(repo_name) # Create virtualenv with site-packages enabled and install all dependencies - # sp.check_output(['pipenv','--site-packages', '--three'], cwd=repo_name) sp.check_output(['pipenv', 'install'], cwd=repo_name) \ No newline at end of file