diff --git a/docker-compose/archiver.yml b/docker-compose/archiver.yml deleted file mode 100644 index 12ec2d88959fca75b047cff6004dd6e2b22c294a..0000000000000000000000000000000000000000 --- a/docker-compose/archiver.yml +++ /dev/null @@ -1,120 +0,0 @@ -version: '2' - -services: - archiver-maria-db: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/mariadb_hdbpp:2021-05-28 - container_name: ${CONTAINER_NAME_PREFIX}archiver-maria-db - networks: - - control - ports: - - "3307:3306/tcp" - depends_on: - - databaseds - environment: - - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - - MYSQL_DATABASE=hdbpp - - MYSQL_HOST=archiver-maria-db:3306 - - MYSQL_USER=tango - - MYSQL_PASSWORD=${MYSQL_PASSWORD} - - TANGO_HOST=${TANGO_HOST} - logging: - driver: syslog - options: - syslog-address: udp://${LOG_HOSTNAME}:1514 - syslog-format: rfc3164 - tag: "{{.Name}}" - restart: unless-stopped - - hdbpp-es: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-archiver:2021-05-28 - networks: - - control - container_name: ${CONTAINER_NAME_PREFIX}hdbpp-es - depends_on: - - databaseds - - dsconfig - - archiver-maria-db - environment: - - TANGO_HOST=${TANGO_HOST} - - HdbManager=archiving/hdbpp/confmanager01 - command: > - /bin/bash -c " - wait-for-it.sh archiver-maria-db:3306 --timeout=30 --strict -- - wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - hdbppes-srv 01" - logging: - driver: syslog - options: - syslog-address: udp://${LOG_HOSTNAME}:1514 - syslog-format: rfc3164 - tag: "{{.Name}}" - restart: unless-stopped - - hdbpp-es2: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-archiver:2021-05-28 - networks: - - control - container_name: hdbpp-es2 - depends_on: - - databaseds - - dsconfig - - archiver-maria-db - environment: - - TANGO_HOST=${TANGO_HOST} - - HdbManager=archiving/hdbpp/confmanager01 - command: > - /bin/bash -c " - wait-for-it.sh archiver-maria-db:3306 --timeout=30 --strict -- - wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - hdbppes-srv 03" - restart: unless-stopped - - hdbpp-cm: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-archiver:${TANGO_ARCHIVER_VERSION} - networks: - - control - container_name: ${CONTAINER_NAME_PREFIX}hdbpp-cm - depends_on: - - databaseds - - dsconfig - - archiver-maria-db - environment: - - TANGO_HOST=${TANGO_HOST} - - HdbManager=archiving/hdbpp/confmanager01 - command: > - /bin/bash -c " - wait-for-it.sh archiver-maria-db:3306 --timeout=30 --strict -- - wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - hdbppcm-srv 01" - logging: - driver: syslog - options: - syslog-address: udp://${LOG_HOSTNAME}:1514 - syslog-format: rfc3164 - tag: "{{.Name}}" - - dsconfig: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-dsconfig:${TANGO_DSCONFIG_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}dsconfig - networks: - - control - depends_on: - - databaseds - environment: - - TANGO_HOST=${TANGO_HOST} - command: > - sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - json2tango -w -a -u /tango-archiver/data/archiver-devices.json && - sleep infinity" - volumes: - - ..:/opt/lofar/tango:rw - - ${HOME}:/hosthome - - ../docker/tango/tango-archiver:/tango-archiver - logging: - driver: syslog - options: - syslog-address: udp://${LOG_HOSTNAME}:1514 - syslog-format: rfc3164 - tag: "{{.Name}}" - restart: unless-stopped - diff --git a/docker-compose/astor.yml b/docker-compose/astor.yml deleted file mode 100644 index 502472fc4eedd022388cd13d76e74135e00ff3db..0000000000000000000000000000000000000000 --- a/docker-compose/astor.yml +++ /dev/null @@ -1,52 +0,0 @@ -# -# Docker compose file that launches Astor, sending the display to a remote X11 -# display. -# -# Defines: -# - astor: service that runs Astor in a container -# - container1: example container running Starter device -# -# Requires: -# - tango.yml -# -version: '2' - -services: - astor: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-java:${TANGO_JAVA_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}astor - networks: - - control - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/astor - - starter-example: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-starter:${TANGO_STARTER_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}starter-example - networks: - - control - # set the hostname, otherwise duplicate device registrations result every - # time the hostname changes as the container is restarted. - hostname: starter-example - environment: - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/bin/supervisord - - --configuration - - /etc/supervisor/supervisord.conf diff --git a/docker-compose/hdbpp_viewer.yml b/docker-compose/hdbpp_viewer.yml deleted file mode 100644 index 9a1f9da06a3db1398e3f4060fd32de9850e6532e..0000000000000000000000000000000000000000 --- a/docker-compose/hdbpp_viewer.yml +++ /dev/null @@ -1,40 +0,0 @@ -# -# Docker compose file that launches HdbViewer, sending the display to a remote X11 -# display. -# -# -# Requires: -# - tango.yml -# -version: '2' - -services: - hdbpp-viewer: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/hdbpp_viewer:${TANGO_HDBPP_VIEWER_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}hdbpp-viewer - network_mode: host - depends_on: - - databaseds - - dsconfig - - archiver-maria-db - - hdbpp-es - - hdbpp-cm - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=localhost:10000 - - HDB_TYPE=mysql - - HDB_MYSQL_HOST=localhost - - HDB_MYSQL_PORT=3307 - - HDB_USER=tango - - HDB_PASSWORD=tango - - HDB_NAME=hdbpp - - CLASSPATH=JTango.jar:ATKCore.jar:ATKWidget.jar:jhdbviewer.jar:HDBPP.jar:jython.jar:jcalendar.jar - entrypoint: - - wait-for-it.sh - - localhost:10000 - - --strict - - -- - - ./hdbpp_viewer/hdbpp_viewer_script diff --git a/docker-compose/jive.yml b/docker-compose/jive.yml deleted file mode 100644 index 5a2caea9a1d9d6fb19d235781abc33a3230412e8..0000000000000000000000000000000000000000 --- a/docker-compose/jive.yml +++ /dev/null @@ -1,38 +0,0 @@ -# -# Docker compose file that launches Jive, sending output to a remote X11 -# display. -# -# This container will always run on the same network as the host, -# to make sure the DISPLAY variable can be used verbatim. For the -# same reason, TANGO_HOST is hardcoded to be at localhost:10000: -# the docker network offering our tangodb also exposes it on port 10000 -# on the host. -# -# Defines: -# - jive: container running Jive -# -# Requires: -# - tango.yml -# -version: '2' - -services: - jive: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-java:${TANGO_JAVA_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}jive - network_mode: host - volumes: - - ${XAUTHORITY_MOUNT} - - ..:/opt/lofar/tango:rw - - ${HOME}:/hosthome - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=localhost:10000 - entrypoint: - - /usr/local/bin/wait-for-it.sh - - localhost:10000 - - --timeout=30 - - --strict - - -- - - /usr/local/bin/jive diff --git a/docker-compose/logviewer.yml b/docker-compose/logviewer.yml deleted file mode 100644 index 08da4000b23925980e1683465fa4fdd4c05f04ae..0000000000000000000000000000000000000000 --- a/docker-compose/logviewer.yml +++ /dev/null @@ -1,31 +0,0 @@ -# -# Docker compose file that launches LogViewer, sending output to a remote X11 -# display. -# -# Defines: -# - logviewer: container running LogViewer -# -# Requires: -# - tango.yml -# -version: '2' - -services: - logviewer: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-java:${TANGO_JAVA_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}logviewer - networks: - - control - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/logviewer diff --git a/docker-compose/pogo.yml b/docker-compose/pogo.yml deleted file mode 100644 index 954841746b9f0338d4a84fdae7e043fde04be460..0000000000000000000000000000000000000000 --- a/docker-compose/pogo.yml +++ /dev/null @@ -1,34 +0,0 @@ -# -# Docker compose file that launches Pogo, sending the display to a remote X11 -# display. Pogo output can be persisted by writing to either: -# 1. the /home/tango folder, which is a Docker volume persisted between -# container runs; -# 2. the /hosthome folder, which is a r/w mount of your home folder. -# -# Defines: -# - pogo (service): service running Pogo -# - pogo (volume): persistent volume for writing Pogo outut -# -# Requires: -# - N/A -# -version: '2' - -# Create a volume so that Pogo preferences and Pogo output can be persisted -volumes: - pogo: {} - -services: - pogo: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-pogo:${TANGO_POGO_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}pogo - networks: - - control - volumes: - - pogo:/home/tango - - ${XAUTHORITY_MOUNT} - - ..:/opt/lofar/tango:rw - - ${HOME}:/hosthome:rw - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} diff --git a/docker-compose/tango.yml b/docker-compose/tango.yml index 19500fca1eeba859f74e7ba54fc3cbb021ea0ce6..0d3b5877c97dea565085d8655b07406cf16fad82 100644 --- a/docker-compose/tango.yml +++ b/docker-compose/tango.yml @@ -68,3 +68,29 @@ services: syslog-format: rfc3164 tag: "{{.Name}}" restart: unless-stopped + + dsconfig: + image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-dsconfig:${TANGO_DSCONFIG_VERSION} + container_name: ${CONTAINER_NAME_PREFIX}dsconfig + networks: + - control + depends_on: + - databaseds + environment: + - TANGO_HOST=${TANGO_HOST} + command: > + sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- + json2tango -w -a -u /tango-archiver/data/archiver-devices.json && + sleep infinity" + volumes: + - ..:/opt/lofar/tango:rw + - ${HOME}:/hosthome + - ../docker/tango/tango-archiver:/tango-archiver + logging: + driver: syslog + options: + syslog-address: udp://${LOG_HOSTNAME}:1514 + syslog-format: rfc3164 + tag: "{{.Name}}" + restart: unless-stopped + diff --git a/docker-compose/tangotest.yml b/docker-compose/tangotest.yml deleted file mode 100644 index a97290d48f437b1c65b0bef01f6788fb525b2275..0000000000000000000000000000000000000000 --- a/docker-compose/tangotest.yml +++ /dev/null @@ -1,29 +0,0 @@ -# -# Docker compose file for TANGO test device server. -# -# Defines: -# - tangotest: TANGO test device server -# -# Requires: -# - tango.yml -# -version: '2' - -services: - tangotest: - image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-java:${TANGO_JAVA_VERSION} - container_name: ${CONTAINER_NAME_PREFIX}tangotest - networks: - - control - environment: - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/TangoTest - - test - restart: unless-stopped - diff --git a/tangostationcontrol/tangostationcontrol/clients/attribute_wrapper.py b/tangostationcontrol/tangostationcontrol/clients/attribute_wrapper.py index cc0b35730427440bec8b34c2afde756b1b461557..30432ae3fdedb19d2e8b19743e63320906b7908e 100644 --- a/tangostationcontrol/tangostationcontrol/clients/attribute_wrapper.py +++ b/tangostationcontrol/tangostationcontrol/clients/attribute_wrapper.py @@ -145,13 +145,38 @@ class attribute_wrapper(attribute): return value + def _decorate_read_function(self, read_attr_func): + """ Wrap an attribute read function to annotate its exceptions with our + comms_annotation to be able to identify which attribute triggered the error. """ + def wrapper(): + try: + return read_attr_func() + except Exception as e: + raise Exception(f"Failed to read attribute {self.comms_annotation}") from e + + return wrapper + + def _decorate_write_function(self, write_attr_func): + """ Wrap an attribute write function to annotate its exceptions with our + comms_annotation to be able to identify which attribute triggered the error. """ + def wrapper(value): + try: + write_attr_func(value) + except Exception as e: + raise Exception(f"Failed to write attribute {self.comms_annotation}") from e + + return wrapper + def set_comm_client(self, client): """ takes a communications client as input arguments This client should be of a class containing a "get_mapping" function and return a read and write function that the wrapper will use to get/set data. """ try: - self.read_function, self.write_function = client.setup_attribute(self.comms_annotation, self) + read_attr_func, write_attr_func = client.setup_attribute(self.comms_annotation, self) + + self.read_function = self._decorate_read_function(read_attr_func) + self.write_function = self._decorate_write_function(write_attr_func) except Exception as e: raise Exception(f"Exception while setting {client.__class__.__name__} attribute with annotation: '{self.comms_annotation}'") from e @@ -160,7 +185,10 @@ class attribute_wrapper(attribute): Asynchronous version of set_comm_client. """ try: - self.read_function, self.write_function = await client.setup_attribute(self.comms_annotation, self) + read_attr_func, write_attr_func = await client.setup_attribute(self.comms_annotation, self) + + self.read_function = self._decorate_read_function(read_attr_func) + self.write_function = self._decorate_write_function(write_attr_func) except Exception as e: raise Exception(f"Exception while setting {client.__class__.__name__} attribute with annotation: '{self.comms_annotation}'") from e diff --git a/tangostationcontrol/tangostationcontrol/devices/device_decorators.py b/tangostationcontrol/tangostationcontrol/devices/device_decorators.py index bf6340fc55edeec0d0c44da7cc139aeb297f2176..b54b783090e33812b525b77bf2e015a97019b770 100644 --- a/tangostationcontrol/tangostationcontrol/devices/device_decorators.py +++ b/tangostationcontrol/tangostationcontrol/devices/device_decorators.py @@ -21,7 +21,7 @@ def only_in_states(allowed_states, log=True): if log: logger.warning(f"Illegal command: Function {func.__name__} can only be called in states {allowed_states}. Current state: {self.get_state()}") - Except.throw_exception(f"IllegalCommand: Function {func.__name__} can only be called in states {allowed_states}. Current state: {self.get_state()}") + raise Exception(f"IllegalCommand: Function {func.__name__} can only be called in states {allowed_states}. Current state: {self.get_state()}") return state_check_wrapper