forked from archiver_config/sf_databuffer
add imagebuffer restart script
This commit is contained in:
@@ -98,6 +98,10 @@ def remove_labeled_source(sources, label):
|
||||
return {"sources": [x for x in sources["sources"] if "labels" not in x or (label not in x['labels'])]}
|
||||
|
||||
|
||||
def remove_image_source(sources):
|
||||
return {"sources": [x for x in sources["sources"] if "backend" not in x or x['backend'] != "sf-imagebuffer"]}
|
||||
|
||||
|
||||
def get_labels(sources):
|
||||
"""
|
||||
Retrieve all used labels in the source configurations
|
||||
@@ -118,6 +122,15 @@ def get_labeled_sources(sources, label):
|
||||
return [x for x in sources["sources"] if "labels" in x and label in x['labels']]
|
||||
|
||||
|
||||
def get_image_sources(sources):
|
||||
"""
|
||||
Get image source(s)
|
||||
:param sources:
|
||||
:return: list of source config that are images
|
||||
"""
|
||||
return [x for x in sources["sources"] if "backend" in x and x['backend'] == "sf-imagebuffer"]
|
||||
|
||||
|
||||
def read_files(files_dir, file_type):
|
||||
"""
|
||||
Read sources or policies files
|
||||
@@ -198,6 +211,11 @@ def main():
|
||||
default=None,
|
||||
help="label that identifies the source(s) to stop")
|
||||
|
||||
parser_stop.add_argument('-t',
|
||||
'--type',
|
||||
default=None,
|
||||
help="type of to stop")
|
||||
|
||||
parser_list = subparsers.add_parser('list',
|
||||
help="list",
|
||||
formatter_class=argparse.RawTextHelpFormatter)
|
||||
@@ -267,12 +285,33 @@ def main():
|
||||
# Only for debugging purposes
|
||||
labeled_sources = get_labeled_sources(sources, label)
|
||||
for s in labeled_sources:
|
||||
logging.info(f"Restarting {s['stream']}")
|
||||
logging.info(f"Stop {s['stream']}")
|
||||
|
||||
sources_new = remove_labeled_source(sources, label)
|
||||
|
||||
# Stopping the removed source(s)
|
||||
upload_sources_and_policies(sources_new, policies)
|
||||
elif arguments.type:
|
||||
type = arguments.type
|
||||
if type != "image":
|
||||
logging.warning(f"Type {type} currently not supported")
|
||||
return
|
||||
logging.info(f"Stop: {type}")
|
||||
|
||||
policies = read_files(base_directory / Path("policies"), "policies")
|
||||
sources = read_files(base_directory / Path("sources"), "sources")
|
||||
|
||||
# Only for debugging purposes
|
||||
image_sources = get_image_sources(sources)
|
||||
for s in image_sources:
|
||||
logging.info(f"Stop {s['stream']}")
|
||||
|
||||
sources_new = remove_image_source(sources)
|
||||
|
||||
# Stopping the removed source(s)
|
||||
upload_sources_and_policies(sources_new, policies)
|
||||
|
||||
|
||||
else:
|
||||
logging.warning("Not yet implemented")
|
||||
parser_stop.print_usage()
|
||||
|
||||
106
operation-tools/restart_imagebuffer.yml
Normal file
106
operation-tools/restart_imagebuffer.yml
Normal file
@@ -0,0 +1,106 @@
|
||||
#- name: stop data api
|
||||
# hosts: data_api
|
||||
# become: true
|
||||
# tasks:
|
||||
# - name: stop data-api
|
||||
# systemd:
|
||||
# state: stopped
|
||||
# name: data-api
|
||||
# - name: stop nginx
|
||||
# systemd:
|
||||
# state: stopped
|
||||
# name: nginx
|
||||
#
|
||||
#
|
||||
#- name: stop dispatcher api
|
||||
# hosts: dispatcher_api
|
||||
# become: true
|
||||
# tasks:
|
||||
# - name: stop dispatcher-api
|
||||
# systemd:
|
||||
# state: stopped
|
||||
# name: dispatcher-api
|
||||
# - name: stop nginx
|
||||
# systemd:
|
||||
# state: stopped
|
||||
# name: nginx
|
||||
|
||||
|
||||
- name: stop nodes
|
||||
hosts: imagebuffer
|
||||
become: true
|
||||
tasks:
|
||||
- name: stop daq-dispatcher-node
|
||||
systemd:
|
||||
state: stopped
|
||||
name: daq-dispatcher-node
|
||||
- name: stop daq-query-node
|
||||
systemd:
|
||||
state: stopped
|
||||
name: daq-query-node
|
||||
- name: Remove sources
|
||||
file:
|
||||
path: /home/daqusr/.config/daq/stores/sources
|
||||
state: absent
|
||||
- name: Remove streamers
|
||||
file:
|
||||
path: /home/daqusr/.config/daq/stores/streamers
|
||||
state: absent
|
||||
|
||||
|
||||
- name: start dispatcher nodes
|
||||
hosts: imagebuffer
|
||||
become: true
|
||||
# serial: 1
|
||||
tasks:
|
||||
- name: start daq-dispatcher-node
|
||||
systemd:
|
||||
state: started
|
||||
name: daq-dispatcher-node
|
||||
|
||||
|
||||
- name: wait for dispatcher nodes to come up
|
||||
hosts: imagebuffer
|
||||
tasks:
|
||||
- name: sleep for 30 seconds and continue with play
|
||||
wait_for:
|
||||
timeout: 30
|
||||
|
||||
|
||||
- name: start query nodes
|
||||
hosts: imagebuffer
|
||||
become: true
|
||||
# serial: 1
|
||||
tasks:
|
||||
- name: start daq-query-node
|
||||
systemd:
|
||||
state: started
|
||||
name: daq-query-node
|
||||
|
||||
#
|
||||
#- name: start data api
|
||||
# hosts: data_api
|
||||
# become: true
|
||||
# tasks:
|
||||
# - name: start data-api
|
||||
# systemd:
|
||||
# state: started
|
||||
# name: data-api
|
||||
# - name: start nginx
|
||||
# systemd:
|
||||
# state: started
|
||||
# name: nginx
|
||||
#
|
||||
#
|
||||
#- name: start dispatcher api
|
||||
# hosts: dispatcher_api
|
||||
# become: true
|
||||
# tasks:
|
||||
# - name: start dispatcher-api
|
||||
# systemd:
|
||||
# state: started
|
||||
# name: dispatcher-api
|
||||
# - name: start nginx
|
||||
# systemd:
|
||||
# state: started
|
||||
# name: nginx
|
||||
Reference in New Issue
Block a user