diff --git a/bin/dump_ConfigDb.sh b/bin/dump_ConfigDb.sh index bbd97a2208381c2fcf39710b9f908814313bdd7b..7745c18482000fe2e7a726e27b6fa5eeae57e88e 100755 --- a/bin/dump_ConfigDb.sh +++ b/bin/dump_ConfigDb.sh @@ -1,6 +1,4 @@ -if [ ${#} -ne 1 ]; then - echo "You must provide a file name for the TANGO_HOST DB dump!" - exit -1 -fi +#!/bin/bash -docker exec -it dsconfig python -m dsconfig.dump > ${1} +# writes the JSON dump to stdout +docker exec -it dsconfig python -m dsconfig.dump diff --git a/bin/update_submodules.sh b/bin/update_submodules.sh new file mode 100755 index 0000000000000000000000000000000000000000..9dcb9745849c01bbf61b9ffae92c5c7cc21a5a8f --- /dev/null +++ b/bin/update_submodules.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git submodule update --init diff --git a/bootstrap/etc/lofar20rc.sh b/bootstrap/etc/lofar20rc.sh index e3bc4ac1e71c43a92a5b7f2ee8f05339b92edeaf..9a9dd658b56f5d30bb1ff8c5de692bd8fe2164de 100755 --- a/bootstrap/etc/lofar20rc.sh +++ b/bootstrap/etc/lofar20rc.sh @@ -12,6 +12,10 @@ ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) export LOFAR20_DIR=${1:-$(realpath ${ABSOLUTE_PATH}/../..)} +if [ ! -f "${LOFAR20_DIR}/.git/hooks/post-checkout" ]; then + alias git="cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-checkout; cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-merge; unalias git; git" +fi + # This needs to be modified for a development environment. # In case you run multiple Docker networks on the same host in parallel, you need to specify a unique # network name for each of them. diff --git a/devices/devices/docker_device.py b/devices/devices/docker_device.py index 81abc26ee8ba4021b8e52bcefcf420a20cbdf28a..2acf7aeecf04755b71337d42f6a64946ef7cd54a 100644 --- a/devices/devices/docker_device.py +++ b/devices/devices/docker_device.py @@ -31,7 +31,6 @@ from clients.docker_client import DockerClient from clients.attribute_wrapper import attribute_wrapper from devices.hardware_device import hardware_device from common.lofar_logging import device_logging_to_python, log_exceptions -from common.lofar_git import get_version __all__ = ["Docker", "main"] @@ -50,7 +49,6 @@ class Docker(hardware_device): # ---------- # Attributes # ---------- - version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) archiver_maria_db_R = attribute_wrapper(comms_annotation={"container": "archiver-maria-db"}, datatype=numpy.bool_) archiver_maria_db_RW = attribute_wrapper(comms_annotation={"container": "archiver-maria-db"}, datatype=numpy.bool_, access=AttrWriteType.READ_WRITE) databaseds_R = attribute_wrapper(comms_annotation={"container": "databaseds"}, datatype=numpy.bool_) diff --git a/devices/devices/hardware_device.py b/devices/devices/hardware_device.py index 6b28fd7ab5acd8bbf4a3742824fde597d5b23d69..a25b863ebc8255fa05c02a5f420f23f309ebf0fb 100644 --- a/devices/devices/hardware_device.py +++ b/devices/devices/hardware_device.py @@ -15,11 +15,12 @@ from abc import ABCMeta, abstractmethod # PyTango imports from tango.server import Device, command, DeviceMeta, attribute -from tango import DevState, DebugIt, Attribute, DeviceProxy +from tango import DevState, DebugIt, Attribute, DeviceProxy, AttrWriteType # Additional import from clients.attribute_wrapper import attribute_wrapper from common.lofar_logging import log_exceptions +from common.lofar_git import get_version from devices.abstract_device import AbstractDeviceMetas from devices.device_decorators import only_in_states, fault_on_error @@ -56,6 +57,8 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): The user triggers their transitions by the commands reflecting the target state (Initialise(), On(), Fault()). """ + version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) + # list of property names too be set first by set_defaults first_default_settings = [] diff --git a/devices/devices/opcua_device.py b/devices/devices/opcua_device.py index d95a8426ed0dc260c0f6eb6d85149e3f5f0ec4ba..698df95705b0dce00cb869ed880a29f97d472cb1 100644 --- a/devices/devices/opcua_device.py +++ b/devices/devices/opcua_device.py @@ -29,7 +29,6 @@ from devices.device_decorators import * from clients.opcua_client import OPCUAConnection from devices.hardware_device import hardware_device from common.lofar_logging import device_logging_to_python, log_exceptions -from common.lofar_git import get_version __all__ = ["opcua_device", "main"] diff --git a/devices/devices/recv.py b/devices/devices/recv.py index e28d402099b71cdcf09f9a7410a271b034e5d689..a078f601c7d1962f4a11367e7ca9745ec590d5f2 100644 --- a/devices/devices/recv.py +++ b/devices/devices/recv.py @@ -30,7 +30,6 @@ from device_decorators import * from clients.attribute_wrapper import attribute_wrapper from devices.opcua_device import opcua_device from common.lofar_logging import device_logging_to_python, log_exceptions -from common.lofar_git import get_version __all__ = ["RECV", "main"] @@ -61,7 +60,6 @@ class RECV(opcua_device): # ---------- # Attributes # ---------- - version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) Ant_mask_RW = attribute_wrapper(comms_annotation=["2:PCC", "2:Ant_mask_RW"], datatype=numpy.bool_, dims=(3, 32), access=AttrWriteType.READ_WRITE) CLK_Enable_PWR_R = attribute_wrapper(comms_annotation=["2:PCC", "2:CLK_Enable_PWR_R"], datatype=numpy.bool_) CLK_I2C_STATUS_R = attribute_wrapper(comms_annotation=["2:PCC", "2:CLK_I2C_STATUS_R"], datatype=numpy.int64) diff --git a/devices/devices/sdp/sdp.py b/devices/devices/sdp/sdp.py index 221afb245361d4f330aab42b395532624fb4edde..693fab3a9b912a3e8e3e30d58dc237be6149df56 100644 --- a/devices/devices/sdp/sdp.py +++ b/devices/devices/sdp/sdp.py @@ -28,7 +28,6 @@ from clients.attribute_wrapper import attribute_wrapper from devices.opcua_device import opcua_device from common.lofar_logging import device_logging_to_python, log_exceptions -from common.lofar_git import get_version import numpy @@ -78,8 +77,6 @@ class SDP(opcua_device): # Attributes # ---------- - version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) - FPGA_beamlet_output_enable_R = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_enable_R"], datatype=numpy.bool_, dims=(16,)) FPGA_beamlet_output_enable_RW = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_enable_RW"], datatype=numpy.bool_, dims=(16,), access=AttrWriteType.READ_WRITE) FPGA_beamlet_output_hdr_eth_destination_mac_R = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_hdr_eth_destination_mac_R"], datatype=numpy.str, dims=(16,)) diff --git a/devices/devices/sdp/statistics.py b/devices/devices/sdp/statistics.py index a884783ddd85c669e35a2230e72e3e4ca2f85d60..63f1cb0a7b1d2763fc51fa79abfa6317684bfd38 100644 --- a/devices/devices/sdp/statistics.py +++ b/devices/devices/sdp/statistics.py @@ -31,7 +31,6 @@ from clients.attribute_wrapper import attribute_wrapper from devices.opcua_device import opcua_device -from common.lofar_git import get_version from common.lofar_logging import device_logging_to_python, log_exceptions import logging @@ -67,8 +66,6 @@ class Statistics(opcua_device, metaclass=ABCMeta): # Attributes # ---------- - version_R = attribute(dtype = str, access = AttrWriteType.READ, fget = lambda self: get_version()) - # number of UDP packets and bytes that were received nof_packets_received_R = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "udp", "parameter": "nof_packets_received"}, datatype=numpy.uint64) nof_bytes_received_R = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "udp", "parameter": "nof_bytes_received"}, datatype=numpy.uint64) diff --git a/devices/devices/unb2.py b/devices/devices/unb2.py index f68402448c73b3a992613273a45231e4d6d919c9..4b071950bb68c52a41758a5eedba32605c0214cf 100644 --- a/devices/devices/unb2.py +++ b/devices/devices/unb2.py @@ -27,7 +27,6 @@ from clients.attribute_wrapper import attribute_wrapper from devices.opcua_device import opcua_device from common.lofar_logging import device_logging_to_python, log_exceptions -from common.lofar_git import get_version import numpy @@ -49,8 +48,6 @@ class UNB2(opcua_device): # Attributes # ---------- - version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) - N_unb = 2 N_fpga = 4 N_ddr = 2 diff --git a/docker-compose/device-docker.yml b/docker-compose/device-docker.yml index 6cf76c650df4b37f204260fa38b2750ff2bb95b0..5386ead921b386741e62febeab399f3007a79281 100644 --- a/docker-compose/device-docker.yml +++ b/docker-compose/device-docker.yml @@ -29,7 +29,7 @@ services: volumes: - ..:/opt/lofar/tango:rw - /var/run/docker.sock:/var/run/docker.sock:rw # we want to control our sibling containers, NOT do docker-in-docker (dind) - user: ${CONTAINER_EXECUTION_UID}:${DOCKER_GID} # user that starts this container by definition has access rights to docker + user: 1000:${DOCKER_GID} # uid 1000 is the default "tango" user environment: - TANGO_HOST=${TANGO_HOST} entrypoint: diff --git a/sbin/load_ConfigDb.sh b/sbin/load_ConfigDb.sh index e62092969301662f5714ce88f028c97b427cc9c8..03ab449a026b5de41056f16de0d2e566a00adfbb 100755 --- a/sbin/load_ConfigDb.sh +++ b/sbin/load_ConfigDb.sh @@ -9,7 +9,10 @@ fi # copy file into container to read it from container, as the file's location # in the container won't be the same as on the host. -docker cp "${file}" dsconfig:/tmp/dsconfig-load-settings.json +docker cp "${file}" dsconfig:/tmp/dsconfig-load-settings.json || exit 1 # write settings docker exec -it dsconfig json2tango --write /tmp/dsconfig-load-settings.json + +# somehow json2tango does not return 0 on success +exit 0 diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index 3b7c09e511a26be4e2c403acb1ed557e8046b463..9d9ec12ae79a2336d5bfd88191930f8c6fa9db36 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ -z "$LOFA20_DIR"]; then # We assume we aren't in the PATH, so we can derive our path. @@ -18,7 +18,7 @@ make start databaseds dsconfig jupyter elk sleep 15 # Update the dsconfig -sbin/update_ConfigDb.sh CDB/integration_ConfigDb.json +${LOFAR20_DIR}/sbin/update_ConfigDb.sh ${LOFAR20_DIR}/CDB/integration_ConfigDb.json cd "$LOFAR20_DIR/docker-compose" || exit 1 make start sdptr-sim recv-sim unb2-sim diff --git a/sbin/update_ConfigDb.sh b/sbin/update_ConfigDb.sh index 90cf92c2418586edf3194f2b0d422040c0f8c7de..8d71c312fc94ba4dba45b17c05a966f62fa9ff34 100755 --- a/sbin/update_ConfigDb.sh +++ b/sbin/update_ConfigDb.sh @@ -9,7 +9,10 @@ fi # copy file into container to read it from container, as the file's location # in the container won't be the same as on the host. -docker cp "${file}" dsconfig:/tmp/dsconfig-update-settings.json +docker cp "${file}" dsconfig:/tmp/dsconfig-update-settings.json || exit 1 # update settings docker exec -it dsconfig json2tango --write --update /tmp/dsconfig-update-settings.json + +# somehow json2tango does not return 0 on success +exit 0