diff --git a/bootstrap/etc/lofar20rc.sh b/bootstrap/etc/lofar20rc.sh index e9e8ac326b32aa0130c98005e2f472457bb65f42..e3bc4ac1e71c43a92a5b7f2ee8f05339b92edeaf 100755 --- a/bootstrap/etc/lofar20rc.sh +++ b/bootstrap/etc/lofar20rc.sh @@ -12,14 +12,6 @@ ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) export LOFAR20_DIR=${1:-$(realpath ${ABSOLUTE_PATH}/../..)} -# This needs to be modified for a development environment. -# Example: ~/lofar2.0/tango -# The current setting is for a production environment. -export TANGO_LOFAR_LOCAL_DIR=${LOFAR20_DIR}/ - -export TANGO_LOFAR_CONTAINER_DIR=/opt/lofar2.0/tango/ -export TANGO_LOFAR_CONTAINER_MOUNT=${TANGO_LOFAR_LOCAL_DIR}:${TANGO_LOFAR_CONTAINER_DIR}:rw - # 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. @@ -35,9 +27,6 @@ export TANGO_HOST=$(hostname):10000 # NO MODIFICATION BEYOND THIS POINT! # -# Provide the -v parameters for Docker and the -e ENV variables. -export TANGO_CONTAINER_ENV="-e TANGO_LOFAR_CONTAINER_DIR=${TANGO_LOFAR_CONTAINER_DIR}" - # Remove all LOFAR1 related environment modifications function remove_lofar() { diff --git a/devices/devices/sdp/sdp.py b/devices/devices/sdp/sdp.py index 75e027b571cefe0bdfa68621b37f45dd26d98aae..16f6d89737742f1f3d475c619a60513e4579a115 100644 --- a/devices/devices/sdp/sdp.py +++ b/devices/devices/sdp/sdp.py @@ -98,7 +98,16 @@ class SDP(hardware_device): version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) - # SDP will switch from FPGA_mask_RW to TR_FPGA_mask_RW, offer both for now as its a critical flag + 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,)) + FPGA_beamlet_output_hdr_eth_destination_mac_RW = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_hdr_eth_destination_mac_RW"], datatype=numpy.str, dims=(16,), access=AttrWriteType.READ_WRITE) + FPGA_beamlet_output_hdr_ip_destination_address_R = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_hdr_ip_destination_address_R"], datatype=numpy.str, dims=(16,)) + FPGA_beamlet_output_hdr_ip_destination_address_RW = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_hdr_ip_destination_address_RW"], datatype=numpy.str, dims=(16,), access=AttrWriteType.READ_WRITE) + FPGA_beamlet_output_hdr_udp_destination_port_R = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_hdr_udp_destination_port_R"], datatype=numpy.uint16, dims=(16,)) + FPGA_beamlet_output_hdr_udp_destination_port_RW = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_hdr_udp_destination_port_RW"], datatype=numpy.uint16, dims=(16,), access=AttrWriteType.READ_WRITE) + FPGA_beamlet_output_scale_R = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_scale_R"], datatype=numpy.uint32, dims=(16,)) + FPGA_beamlet_output_scale_RW = attribute_wrapper(comms_annotation=["2:FPGA_beamlet_output_scale_RW"], datatype=numpy.uint32, dims=(16,), access=AttrWriteType.READ_WRITE) FPGA_firmware_version_R = attribute_wrapper(comms_annotation=["2:FPGA_firmware_version_R"], datatype=numpy.str, dims=(16,)) FPGA_global_node_index_R = attribute_wrapper(comms_annotation=["2:FPGA_global_node_index_R"], datatype=numpy.uint32, dims=(16,)) FPGA_hardware_version_R = attribute_wrapper(comms_annotation=["2:FPGA_hardware_version_R"], datatype=numpy.str, dims=(16,)) diff --git a/devices/integration_test/README.md b/devices/integration_test/README.md index a94aa174badfe5b44ccab770dd8437106c432ad3..6609a2da61665aab3d93c9f4d716148e03428fba 100644 --- a/devices/integration_test/README.md +++ b/devices/integration_test/README.md @@ -16,8 +16,7 @@ are running and are in the required state. **Warning running these tests will make changes to your CDB database config!** ```shell -source bootstrap/etc/lofar20rc.sh -$LOFAR20_DIR/sbin/run_integration_test.sh +sbin/run_integration_test.sh ``` ## Limitations diff --git a/devices/integration_test/client/test_unb2_sim.py b/devices/integration_test/client/test_unb2_sim.py index 678930cd5f092c94f9242a01a58d139993f2504f..227e031e3651fdc1c0523e103b072762271b647a 100644 --- a/devices/integration_test/client/test_unb2_sim.py +++ b/devices/integration_test/client/test_unb2_sim.py @@ -20,11 +20,12 @@ class TestUNB2Sim(base.IntegrationTestCase): def test_opcua_connection(self): """Check if we can connect to unb2-sim""" - client = Client("opc.tcp://recv-sim:4842") + client = Client("opc.tcp://unb2-sim:4844") root_node = None + client.connect() + try: - client.connect() root_node = client.get_root_node() finally: client.disconnect() diff --git a/devices/test/README.md b/devices/test/README.md index 4007ef0a30b75869e04b0e69745947f73d4520ba..050b1de05d9206151661aabd11a77358ab464576 100644 --- a/devices/test/README.md +++ b/devices/test/README.md @@ -120,7 +120,7 @@ Docker container. A simple interactive Docker exec is enough to access them: ```sh docker exec -it device-sdp /bin/bash -cd /opt/lofar2.0/tango/devices/ +cd /opt/lofar/tango/devices/ tox ``` diff --git a/docker-compose/Makefile b/docker-compose/Makefile index b964653b1f1d0764c254b9e68c0d97ea8f3ef396..8e660436fb7ab61d86f704a00c5a386fcc25c401 100644 --- a/docker-compose/Makefile +++ b/docker-compose/Makefile @@ -1,11 +1,3 @@ -# Before doing anything, make 100% certain that all necessary environment -# variables are set. -ifndef LOFAR20_DIR - # Generate the full path to the lofar20rc.sh file - # for exactly this repository. - LOFAR20RC = $(subst docker-compose,bootstrap/etc/lofar20rc.sh,$(abspath .)) - $(error There are essential LOFAR2.0 environment variables missing. You must source the lofar20rc.sh file of this repo first. You can do it like this (paste without quotes): ". $(LOFAR20RC)") -endif # Set dir of Makefile to a variable to use later MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST))) BASEDIR := $(notdir $(patsubst %/,%,$(dir $(MAKEPATH)))) @@ -22,7 +14,12 @@ ATTACH_COMPOSE_FILE_ARGS := $(foreach yml,$(filter-out tango.yml,$(COMPOSE_FILES NETWORK_MODE ?= tangonet # Host name through which others can reach our control interfaces -HOSTNAME ?= $(shell hostname -f) +ifneq (,$(wildcard /run/WSL)) + # Microsoft Windows Subsystem for Linux + HOSTNAME ?= host.docker.internal +else + HOSTNAME ?= $(shell hostname -f) +endif # If the first make argument is "start" or "stop"... ifeq (start,$(firstword $(MAKECMDGOALS))) @@ -114,11 +111,10 @@ endif DOCKER_COMPOSE_ARGS := DISPLAY=$(DISPLAY) \ XAUTHORITY=$(XAUTHORITY) \ TANGO_HOST=$(TANGO_HOST) \ + MYSQL_HOST=$(MYSQL_HOST) \ HOSTNAME=$(HOSTNAME) \ NETWORK_MODE=$(NETWORK_MODE) \ XAUTHORITY_MOUNT=$(XAUTHORITY_MOUNT) \ - TANGO_LOFAR_CONTAINER_MOUNT=$(TANGO_LOFAR_CONTAINER_MOUNT) \ - TANGO_LOFAR_CONTAINER_DIR=${TANGO_LOFAR_CONTAINER_DIR} MYSQL_HOST=$(MYSQL_HOST) \ CONTAINER_NAME_PREFIX=$(CONTAINER_NAME_PREFIX) \ COMPOSE_IGNORE_ORPHANS=true \ CONTAINER_EXECUTION_UID=$(shell id -u) \ @@ -159,7 +155,7 @@ endif $(DOCKER_COMPOSE_ARGS) docker-compose -f tango.yml -f networks.yml up -d start: up ## start a service (usage: make start <servicename>) - if [ $(UNAME_S) = Linux ]; then chmod a+r ~/.Xauthority; fi + if [ $(UNAME_S) = Linux ]; then touch ~/.Xauthority; chmod a+r ~/.Xauthority; fi $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) start $(SERVICE) stop: ## stop a service (usage: make stop <servicename>) diff --git a/docker-compose/archiver.yml b/docker-compose/archiver.yml index 5204b52c0ffd05fcee800d0f7faebc9345628a48..8a357d371e89377a1bfa2ce89e341ba708526fef 100644 --- a/docker-compose/archiver.yml +++ b/docker-compose/archiver.yml @@ -70,7 +70,7 @@ services: json2tango -w -a -u /tango-archiver/data/archiver-devices.json && sleep infinity" volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw - ${HOME}:/hosthome - ../docker/tango/tango-archiver:/tango-archiver restart: on-failure diff --git a/docker-compose/device-docker.yml b/docker-compose/device-docker.yml index 7ed5ecf40dd02a0a9d39941c144dc9958e2ed794..6cf76c650df4b37f204260fa38b2750ff2bb95b0 100644 --- a/docker-compose/device-docker.yml +++ b/docker-compose/device-docker.yml @@ -27,7 +27,7 @@ services: ports: - "5705:5705" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/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 environment: @@ -40,5 +40,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/docker_device.py LTS -v -ORBendPoint giop:tcp:0:5705 -ORBendPointPublish giop:tcp:${HOSTNAME}:5705 + - python3 -u /opt/lofar/tango/devices/devices/docker_device.py LTS -v -ORBendPoint giop:tcp:0:5705 -ORBendPointPublish giop:tcp:${HOSTNAME}:5705 restart: on-failure diff --git a/docker-compose/device-observation_control.yml b/docker-compose/device-observation_control.yml index c3cbb19d6bcf331b9ce96fccb74c9d0d6f76b758..011fe0a94112df557670a218518b6492520f4480 100644 --- a/docker-compose/device-observation_control.yml +++ b/docker-compose/device-observation_control.yml @@ -26,7 +26,7 @@ services: ports: - "5703:5703" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} entrypoint: @@ -37,5 +37,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/observation_control.py LTS -v -ORBendPoint giop:tcp:0:5703 -ORBendPointPublish giop:tcp:${HOSTNAME}:5703 + - python3 -u /opt/lofar/tango/devices/devices/observation_control.py LTS -v -ORBendPoint giop:tcp:0:5703 -ORBendPointPublish giop:tcp:${HOSTNAME}:5703 restart: on-failure diff --git a/docker-compose/device-recv.yml b/docker-compose/device-recv.yml index f553ba61476557fdeef1cdd3757d96184e8a5c76..fdf8a535b002d629b29ee48b49b9ee91d8e925d7 100644 --- a/docker-compose/device-recv.yml +++ b/docker-compose/device-recv.yml @@ -27,7 +27,7 @@ services: ports: - "5707:5707" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} entrypoint: @@ -38,5 +38,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/recv.py LTS -v -ORBendPoint giop:tcp:0:5707 -ORBendPointPublish giop:tcp:${HOSTNAME}:5707 + - python3 -u /opt/lofar/tango/devices/devices/recv.py LTS -v -ORBendPoint giop:tcp:0:5707 -ORBendPointPublish giop:tcp:${HOSTNAME}:5707 restart: on-failure diff --git a/docker-compose/device-sdp.yml b/docker-compose/device-sdp.yml index a65bb8ae3e3111ad6c2954b44b9c20a6e8085321..cdd8d137d6f249ef91e500dd4b9bb32734b23c90 100644 --- a/docker-compose/device-sdp.yml +++ b/docker-compose/device-sdp.yml @@ -27,7 +27,7 @@ services: ports: - "5701:5701" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} entrypoint: @@ -38,5 +38,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/sdp/sdp.py LTS -v -ORBendPoint giop:tcp:0:5701 -ORBendPointPublish giop:tcp:${HOSTNAME}:5701 + - python3 -u /opt/lofar/tango/devices/devices/sdp/sdp.py LTS -v -ORBendPoint giop:tcp:0:5701 -ORBendPointPublish giop:tcp:${HOSTNAME}:5701 restart: on-failure diff --git a/docker-compose/device-sst.yml b/docker-compose/device-sst.yml index a7f2e867bc4075d002d764189ef3906ff81fb12a..a9547f53830a564eeba6c9123c753c0062d1da30 100644 --- a/docker-compose/device-sst.yml +++ b/docker-compose/device-sst.yml @@ -30,7 +30,7 @@ services: - "5101:5101/tcp" # port to emit SST TCP packets on - "5702:5702" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} entrypoint: @@ -41,5 +41,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/sdp/sst.py LTS -v -ORBendPoint giop:tcp:0:5702 -ORBendPointPublish giop:tcp:${HOSTNAME}:5702 + - python3 -u /opt/lofar/tango/devices/devices/sdp/sst.py LTS -v -ORBendPoint giop:tcp:0:5702 -ORBendPointPublish giop:tcp:${HOSTNAME}:5702 restart: on-failure diff --git a/docker-compose/device-unb2.yml b/docker-compose/device-unb2.yml index f41651c95c4bb0677b81fa9a8f4b717144bc0828..67c443121cf02bc9c1652978b1dd67a5ebf3a80b 100644 --- a/docker-compose/device-unb2.yml +++ b/docker-compose/device-unb2.yml @@ -27,7 +27,7 @@ services: ports: - "5704:5704" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} entrypoint: @@ -38,5 +38,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/unb2.py LTS -v -ORBendPoint giop:tcp:0:5704 -ORBendPointPublish giop:tcp:${HOSTNAME}:5704 + - python3 -u /opt/lofar/tango/devices/devices/unb2.py LTS -v -ORBendPoint giop:tcp:0:5704 -ORBendPointPublish giop:tcp:${HOSTNAME}:5704 restart: on-failure diff --git a/docker-compose/device-xst.yml b/docker-compose/device-xst.yml index 8b0ba2d77cffe33caf4130f29ee83e1db1911f2b..1f75009dc6042b83aff706e34a811c1023f532b0 100644 --- a/docker-compose/device-xst.yml +++ b/docker-compose/device-xst.yml @@ -30,7 +30,7 @@ services: - "5102:5102/tcp" # port to emit XST TCP packets on - "5706:5706" # unique port for this DS volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} entrypoint: @@ -41,5 +41,5 @@ services: - -- # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u ${TANGO_LOFAR_CONTAINER_DIR}/devices/devices/sdp/xst.py LTS -v -ORBendPoint giop:tcp:0:5706 -ORBendPointPublish giop:tcp:${HOSTNAME}:5706 + - python3 -u /opt/lofar/tango/devices/devices/sdp/xst.py LTS -v -ORBendPoint giop:tcp:0:5706 -ORBendPointPublish giop:tcp:${HOSTNAME}:5706 restart: on-failure diff --git a/docker-compose/integration-test.yml b/docker-compose/integration-test.yml index e6a0e54939179ba0c4f5b043da3191dd9e11945d..239dce0235dcd2b2a6a2a731f373e84c49ea671b 100644 --- a/docker-compose/integration-test.yml +++ b/docker-compose/integration-test.yml @@ -16,10 +16,10 @@ services: networks: - control volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw environment: - TANGO_HOST=${TANGO_HOST} - working_dir: ${TANGO_LOFAR_CONTAINER_DIR}/devices + working_dir: /opt/lofar/tango/devices entrypoint: - /usr/local/bin/wait-for-it.sh - ${TANGO_HOST} diff --git a/docker-compose/itango.yml b/docker-compose/itango.yml index 34161eb43f752716f28d44170898d94c4b6d76cd..5b0874f2f3c936c1b57915580ac79be81b5edcb9 100644 --- a/docker-compose/itango.yml +++ b/docker-compose/itango.yml @@ -22,7 +22,7 @@ services: networks: - control volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw - ${HOME}:/hosthome environment: - TANGO_HOST=${TANGO_HOST} diff --git a/docker-compose/jive.yml b/docker-compose/jive.yml index b810073e6a2ddf691b88a47c2d805331605379e8..456ae1fc96771bad1ab6b99e52e3b0c9c046c20c 100644 --- a/docker-compose/jive.yml +++ b/docker-compose/jive.yml @@ -23,7 +23,7 @@ services: network_mode: host volumes: - ${XAUTHORITY_MOUNT} - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw - ${HOME}:/hosthome environment: - XAUTHORITY=${XAUTHORITY} diff --git a/docker-compose/jupyter.yml b/docker-compose/jupyter.yml index 989601cf8d858f493ba47ed607a9e4cd5a6d2770..e7bbd5d00a3813dc0ce9562d64de77683f1eeaee 100644 --- a/docker-compose/jupyter.yml +++ b/docker-compose/jupyter.yml @@ -20,8 +20,8 @@ services: networks: - control volumes: - - ${TANGO_LOFAR_CONTAINER_MOUNT} - - ${TANGO_LOFAR_LOCAL_DIR}/jupyter-notebooks:/jupyter-notebooks:rw + - ..:/opt/lofar/tango:rw + - ../jupyter-notebooks:/jupyter-notebooks:rw - ${HOME}:/hosthome environment: - TANGO_HOST=${TANGO_HOST} diff --git a/docker-compose/pogo.yml b/docker-compose/pogo.yml index 2029874a5247ead93054a6f83e8185ea01be2487..826daac9fbd6ef3226a690832eedab505bbeaba3 100644 --- a/docker-compose/pogo.yml +++ b/docker-compose/pogo.yml @@ -27,7 +27,7 @@ services: volumes: - pogo:/home/tango - ${XAUTHORITY_MOUNT} - - ${TANGO_LOFAR_CONTAINER_MOUNT} + - ..:/opt/lofar/tango:rw - ${HOME}:/hosthome:rw environment: - XAUTHORITY=${XAUTHORITY} diff --git a/sbin/load_ConfigDb.sh b/sbin/load_ConfigDb.sh index 6b5fbb11d31a6f2ce727312111be67486038365e..e62092969301662f5714ce88f028c97b427cc9c8 100755 --- a/sbin/load_ConfigDb.sh +++ b/sbin/load_ConfigDb.sh @@ -1,32 +1,15 @@ -function help() -{ - echo -e "\nERROR: ${1}\nYou must provide a file that can be accessed from within the Docker container. This is possible for files that\n\t- Have a path in \${HOME} or\n\t- Have a full file path that begins with one of \"/hosthome/\", \"/opt/lofar2.0/tango/\" or \"/opt/lofar2.0/\".\n\nWhy is that? Because the file will be loaded from within the Docker container and only some of the host's file system directories are mounted in the container." - exit -2 -} +#!/bin/bash if [ ${#} -eq 1 ]; then file=${1} else - help "A file name must be provided." + echo "A file name must be provided." + exit 1 fi -# Check if the filename begins with /hosthome/, /opt/lofar2.0/tango or -# /opt/lofar2.0/ or if it is in the ${HOME} directory: -if [ ${1:0:10} != /hosthome/ -a ${1:0:20} != /opt/lofar2.0/tango/ -a ${1:0:14} != /opt/lofar2.0/ ]; then - pushd $(dirname ${file}) >/dev/null - full_path=${PWD} - popd >/dev/null - # Check if the file's directory begins with ${HOME}. Then it can be - # accessed via /hosthome. The replacement will then shorten the result. - home_replaced=${full_path#${HOME}} - if [ ${#home_replaced} -ne ${#full_path} ]; then - if [ ! -f ${file} ]; then - help "The file \"${1}\" does not exist." - 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 - # The file can be accessed through /hosthome. Modify the parameter. - file=/hosthome${home_replaced}/$(basename ${file}) - fi -fi - -docker exec -it ${TANGO_CONTAINER_ENV} dsconfig json2tango --write ${file} +# write settings +docker exec -it dsconfig json2tango --write /tmp/dsconfig-load-settings.json diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index 684e7584ee20fb22803b9d3e8e29537f52f52aff..3b7c09e511a26be4e2c403acb1ed557e8046b463 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -1,9 +1,12 @@ #!/bin/bash -# Check if lofar20rc.sh is sourced and environment variables are set. -if [ -z "$LOFAR20_DIR" ]; then - echo "\$LOFAR20_DIR is unset or blank, is lofar20rc.sh sourced correctly?" - exit 1 +if [ -z "$LOFA20_DIR"]; then + # We assume we aren't in the PATH, so we can derive our path. + # We need our parent directory. + LOFAR20_DIR_RELATIVE=`dirname "$0"`/.. + + # As an absolute path + LOFAR20_DIR=`readlink -f "${LOFAR20_DIR_RELATIVE}"` fi # Start and stop sequence @@ -15,7 +18,6 @@ make start databaseds dsconfig jupyter elk sleep 15 # Update the dsconfig -cd "$TANGO_LOFAR_LOCAL_DIR" || exit 1 sbin/update_ConfigDb.sh CDB/integration_ConfigDb.json cd "$LOFAR20_DIR/docker-compose" || exit 1 diff --git a/sbin/update_ConfigDb.sh b/sbin/update_ConfigDb.sh index fc3dc051b95b8eee5bb679088e0877da37aae8fa..90cf92c2418586edf3194f2b0d422040c0f8c7de 100755 --- a/sbin/update_ConfigDb.sh +++ b/sbin/update_ConfigDb.sh @@ -1,37 +1,15 @@ -function help() -{ - echo -e "\nERROR: ${1}\nYou must provide a file that can be accessed from within the Docker container. This is possible for files that\n\t- Have a path in \${HOME} or\n\t- Have a full file path that begins with one of \"/hosthome/\", \"/opt/lofar2.0/tango/\" or \"/opt/lofar2.0/\".\n\nWhy is that? Because the file will be loaded from within the Docker container and only some of the host's file system directories are mounted in the container." - exit -2 -} +#!/bin/bash if [ ${#} -eq 1 ]; then file=${1} else - help "A file name must be provided." + echo "A file name must be provided." + exit 1 fi -# Check if the filename begins with /hosthome/, /opt/lofar2.0/tango or -# /opt/lofar2.0/ or if it is in the ${HOME} directory: -if [ ${1:0:10} != /hosthome/ -a ${1:0:20} != /opt/lofar2.0/tango/ -a ${1:0:14} != /opt/lofar2.0/ ]; then - pushd $(dirname ${file}) >/dev/null - full_path=${PWD} - popd >/dev/null - # Check if the file's directory begins with ${HOME}. Then it can be - # accessed via /hosthome. The replacement will then shorten the result. - home_replaced=${full_path#${HOME}} - if [ ${#home_replaced} -ne ${#full_path} ]; then - if [ ! -f ${file} ]; then - help "The file \"${1}\" does not exist." - 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 - # The file can be accessed through /hosthome. Modify the parameter. - file=/hosthome${home_replaced}/$(basename ${file}) - else - # The file is in one of the two: /opt/lofar2.0/tango/ /opt/lofar2.0/ - # Provide the full path since it is accessible from within the docker - # image because both directories are mounted. - file=${full_path}/$(basename ${file}) - fi -fi - -docker exec -it ${TANGO_CONTAINER_ENV} dsconfig json2tango --write --update ${file} +# update settings +docker exec -it dsconfig json2tango --write --update /tmp/dsconfig-update-settings.json