cli: add ioc *-all commands
This commit is contained in:
+52
-7
@@ -1,9 +1,7 @@
|
||||
import sys
|
||||
|
||||
import ansible_runner
|
||||
import typer
|
||||
|
||||
from core.ansible import run_playbook
|
||||
from core.models import ServiceRegistry
|
||||
from core.utils import get_git_root
|
||||
|
||||
ioc = typer.Typer(no_args_is_help=True)
|
||||
@@ -15,6 +13,8 @@ IOC_PLAYBOOK_INSTALL = ANSIBLE_PLAYBOOKS_DIR / "ioc-install.yml"
|
||||
IOC_PLAYBOOK_RESTART = ANSIBLE_PLAYBOOKS_DIR / "ioc-restart.yml"
|
||||
IOC_PLAYBOOK_START = ANSIBLE_PLAYBOOKS_DIR / "ioc-start.yml"
|
||||
|
||||
# TODO: make sure dev/prod works correctly for all commands
|
||||
|
||||
|
||||
@ioc.command(no_args_is_help=True)
|
||||
def install(
|
||||
@@ -31,6 +31,43 @@ def install(
|
||||
run_playbook(playbook=str(IOC_PLAYBOOK_INSTALL), vars=[env_var, branch_var, service_name_var])
|
||||
|
||||
|
||||
@ioc.command(no_args_is_help=True)
|
||||
def install_all(
|
||||
env: str = typer.Option(..., "--env"),
|
||||
):
|
||||
env_var = f"agebd_env={env}"
|
||||
registry = ServiceRegistry.read_from_config()
|
||||
services = registry.get_services()
|
||||
|
||||
branch_var = f"branch_name=main"
|
||||
for service in services:
|
||||
service_name_var = f"service_name_lower={service.name_lower}"
|
||||
|
||||
run_playbook(
|
||||
playbook=str(IOC_PLAYBOOK_INSTALL), vars=[env_var, branch_var, service_name_var]
|
||||
)
|
||||
|
||||
|
||||
@ioc.command(no_args_is_help=True)
|
||||
def start(
|
||||
ioc_port: int = typer.Option(..., "--port", "-p"),
|
||||
):
|
||||
ioc_port_var = f"ioc_port={ioc_port}"
|
||||
|
||||
run_playbook(playbook=str(IOC_PLAYBOOK_START), vars=[ioc_port_var])
|
||||
|
||||
|
||||
@ioc.command()
|
||||
def start_all():
|
||||
registry = ServiceRegistry.read_from_config()
|
||||
services = registry.get_services()
|
||||
|
||||
for service in services:
|
||||
ioc_port_var = f"ioc_port={service.ioc_port}"
|
||||
|
||||
run_playbook(playbook=str(IOC_PLAYBOOK_START), vars=[ioc_port_var])
|
||||
|
||||
|
||||
@ioc.command(no_args_is_help=True)
|
||||
def restart(
|
||||
env: str = typer.Option(..., "--env"),
|
||||
@@ -47,9 +84,17 @@ def restart(
|
||||
|
||||
|
||||
@ioc.command(no_args_is_help=True)
|
||||
def start(
|
||||
ioc_port: int = typer.Option(..., "--port", "-p"),
|
||||
def restart_all(
|
||||
env: str = typer.Option(..., "--env"),
|
||||
):
|
||||
ioc_port_var = f"ioc_port={ioc_port}"
|
||||
env_var = f"agebd_env={env}"
|
||||
registry = ServiceRegistry.read_from_config()
|
||||
services = registry.get_services()
|
||||
|
||||
run_playbook(playbook=str(IOC_PLAYBOOK_START), vars=[ioc_port_var])
|
||||
branch_var = f"branch_name=main"
|
||||
for service in services:
|
||||
service_name_var = f"service_name_lower={service.name_lower}"
|
||||
|
||||
run_playbook(
|
||||
playbook=str(IOC_PLAYBOOK_RESTART), vars=[env_var, branch_var, service_name_var]
|
||||
)
|
||||
|
||||
@@ -36,54 +36,54 @@ services:
|
||||
- name: plots
|
||||
ioc_port: 50011
|
||||
status: active
|
||||
- name: orbitbump
|
||||
ioc_port: 50012
|
||||
status: active
|
||||
# - name: orbitbump
|
||||
# ioc_port: 50012
|
||||
# status: active
|
||||
- name: topuptool
|
||||
ioc_port: 50013
|
||||
status: active
|
||||
- name: shifttool
|
||||
ioc_port: 50014
|
||||
status: active
|
||||
- name: beamtransferchecks
|
||||
ioc_port: 50015
|
||||
status: active
|
||||
# - name: beamtransferchecks
|
||||
# ioc_port: 50015
|
||||
# status: active
|
||||
- name: tunefbx
|
||||
ioc_port: 50016
|
||||
status: active
|
||||
- name: tunefby
|
||||
ioc_port: 50017
|
||||
status: active
|
||||
- name: opticsff-x02s
|
||||
ioc_port: 50018
|
||||
status: active
|
||||
- name: opticsff-x03m
|
||||
ioc_port: 50019
|
||||
status: active
|
||||
- name: opticsff-x04s
|
||||
ioc_port: 50020
|
||||
status: active
|
||||
- name: opticsff-x05l
|
||||
ioc_port: 50021
|
||||
status: active
|
||||
- name: opticsff-x06s
|
||||
ioc_port: 50022
|
||||
status: active
|
||||
- name: opticsff-x07m
|
||||
ioc_port: 50023
|
||||
status: active
|
||||
- name: opticsff-x08s
|
||||
ioc_port: 50024
|
||||
status: active
|
||||
- name: opticsff-x09l
|
||||
ioc_port: 50025
|
||||
status: active
|
||||
- name: opticsff-x10s
|
||||
ioc_port: 50026
|
||||
status: active
|
||||
- name: opticsff-x11m
|
||||
ioc_port: 50027
|
||||
status: active
|
||||
- name: opticsff-x12s
|
||||
ioc_port: 50028
|
||||
status: active
|
||||
# - name: opticsff-x02s
|
||||
# ioc_port: 50018
|
||||
# status: active
|
||||
# - name: opticsff-x03m
|
||||
# ioc_port: 50019
|
||||
# status: active
|
||||
# - name: opticsff-x04s
|
||||
# ioc_port: 50020
|
||||
# status: active
|
||||
# - name: opticsff-x05l
|
||||
# ioc_port: 50021
|
||||
# status: active
|
||||
# - name: opticsff-x06s
|
||||
# ioc_port: 50022
|
||||
# status: active
|
||||
# - name: opticsff-x07m
|
||||
# ioc_port: 50023
|
||||
# status: active
|
||||
# - name: opticsff-x08s
|
||||
# ioc_port: 50024
|
||||
# status: active
|
||||
# - name: opticsff-x09l
|
||||
# ioc_port: 50025
|
||||
# status: active
|
||||
# - name: opticsff-x10s
|
||||
# ioc_port: 50026
|
||||
# status: active
|
||||
# - name: opticsff-x11m
|
||||
# ioc_port: 50027
|
||||
# status: active
|
||||
# - name: opticsff-x12s
|
||||
# ioc_port: 50028
|
||||
# status: active
|
||||
|
||||
Reference in New Issue
Block a user