add upgrade command
This commit is contained in:
parent
b28dcc27bb
commit
1acc5ad73f
45
alakazam.py
45
alakazam.py
|
@ -482,7 +482,7 @@ def secrets(apps):
|
|||
|
||||
|
||||
def get_deployed_apps(apps):
|
||||
deployed_apps = []
|
||||
deployed_apps = {}
|
||||
processed_server = []
|
||||
for _, instance_config in CONFIGS.items():
|
||||
if apps:
|
||||
|
@ -495,8 +495,8 @@ def get_deployed_apps(apps):
|
|||
continue
|
||||
processed_server.append(server)
|
||||
deployed = abra("app", "ls", "-S", "-s", server, "-m", machine_output=True)
|
||||
deployed_domains = [app["appName"] for app in deployed[server]["apps"] if app["status"] == "deployed"]
|
||||
deployed_apps.extend(deployed_domains)
|
||||
deployed_app_versions = {app["appName"]: app["version"] for app in deployed[server]["apps"] if app["status"] == "deployed"}
|
||||
deployed_apps.update(deployed_app_versions)
|
||||
return deployed_apps
|
||||
|
||||
|
||||
|
@ -538,6 +538,45 @@ def deploy(apps, run_cmds, force):
|
|||
execute_cmds(app_config)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('-a', '--apps', multiple=True)
|
||||
@click.option('-r', '--run-cmds', is_flag=True)
|
||||
def upgrade(apps, run_cmds):
|
||||
""" Deploy all the apps """
|
||||
deployed_domains = get_deployed_apps(apps)
|
||||
for _, instance_config in CONFIGS.items():
|
||||
if apps:
|
||||
selected_apps = [app for app in apps if app in instance_config.keys()]
|
||||
else:
|
||||
selected_apps = instance_config.keys()
|
||||
for app in selected_apps:
|
||||
app_config = instance_config[app]
|
||||
domain = app_config['app_domain']
|
||||
if domain not in deployed_domains:
|
||||
print(f"{domain} is not deployed")
|
||||
continue
|
||||
version = app_config.get('version')
|
||||
if not version:
|
||||
version = 'latest'
|
||||
cmd = ["upgrade", "-n"]
|
||||
if version == 'chaos':
|
||||
cmd.append("--chaos")
|
||||
if not run_cmds:
|
||||
cmd.append("--no-converge-checks")
|
||||
cmd.append(domain)
|
||||
if version not in ['latest', 'chaos']:
|
||||
cmd.append(version)
|
||||
deployed_version = deployed_domains[domain]
|
||||
if version == deployed_version:
|
||||
print(f"{domain} is already at version {version}")
|
||||
continue
|
||||
print(f'upgrade {domain} from version {deployed_version} to version "{version}"')
|
||||
#print(abra("app", *cmd))
|
||||
if run_cmds:
|
||||
logging.info(f'execute commands for {domain}')
|
||||
execute_cmds(app_config)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('-a', '--apps', multiple=True)
|
||||
def undeploy(apps):
|
||||
|
|
Loading…
Reference in New Issue