diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4a9602f20..03265d0c6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ stages: # Build docker image which is used to build & test VILLASnode prepare:docker: stage: prepare - image: docker:19.03 + image: docker:20.10 script: - docker build ${DOCKER_OPTS} --file ${DOCKER_FILE} @@ -206,17 +206,18 @@ pkg:rpm: pkg:alpine: stage: packaging - image: docker:19.03 + image: docker:20.10 before_script: - mkdir -p ~/.docker/cli-plugins/ - wget -O ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.4.2/buildx-v0.4.2.linux-amd64 - chmod a+x ~/.docker/cli-plugins/docker-buildx - - docker buildx create --use --name cross-platform-build + - docker buildx create --use --name cross-platform-build --buildkitd-flags "--allow-insecure-entitlement security.insecure" - docker buildx inspect --bootstrap cross-platform-build - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} script: - docker buildx build ${DOCKER_OPTS} --pull + --allow security.insecure --output type=docker --target app --build-arg ARCH=${ARCH} @@ -267,7 +268,7 @@ deploy:web: deploy:docker: stage: deploy - image: docker:19.03 + image: docker:20.10 variables: DOCKER_CLI_EXPERIMENTAL: enabled before_script: @@ -324,7 +325,7 @@ deploy:packages:tags: .latest:docker:latest: &deploy_latest_docker stage: latest - image: docker:19.03 + image: docker:20.10 before_script: - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} script: diff --git a/lib/nodes/websocket.cpp b/lib/nodes/websocket.cpp index 87fd29137..d7918fa7f 100644 --- a/lib/nodes/websocket.cpp +++ b/lib/nodes/websocket.cpp @@ -311,10 +311,6 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi int avail, enqueued; struct websocket *w = (struct websocket *) n->_vd; struct sample *smps[cnt]; - if (!smps) { - warning("Failed to allocate memory for connection: %s", websocket_connection_name(c)); - break; - } avail = sample_alloc_many(&w->pool, smps, cnt); if (avail < cnt) diff --git a/packaging/docker/Dockerfile.alpine b/packaging/docker/Dockerfile.alpine index f17b2a5af..ad38a2ed4 100644 --- a/packaging/docker/Dockerfile.alpine +++ b/packaging/docker/Dockerfile.alpine @@ -1,12 +1,5 @@ -# Dockerfile for VILLASnode development. -# -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. -# -# This image can be used for developing VILLASnode -# by running: -# make docker-dev +#syntax=docker/dockerfile:1.2-labs +# Alpine Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC @@ -87,7 +80,8 @@ ADD packaging/deps.sh / # https://github.com/creytiv/re/issues/256 # https://github.com/mz-automation/libiec61850/issues/279 -RUN export SKIP_CRITERION=1; \ +RUN --security=insecure \ + export SKIP_CRITERION=1; \ export SKIP_ETHERLAB=1; \ export SKIP_LIBRE=1; \ if [ "${ARCH}" == "armv6" -o "${ARCH}" == "armv7" ]; then \ @@ -103,9 +97,10 @@ COPY . /villas/ RUN mkdir -p /villas/build WORKDIR /villas/build -RUN cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} \ +RUN --security=insecure \ + cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} \ -DCMAKE_PREFIX_PATH=${PREFIX} .. && \ - make -j$(nproc) install + make -j8 install FROM alpine:edge AS app @@ -115,22 +110,23 @@ ARG TRIPLET=x86_64-alpine-linux-musl RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories +RUN apk update RUN apk add \ - openssl \ - ossp-uuid@testing \ - libconfig \ - curl \ - jansson \ - spdlog \ - fmt \ - libnl3 \ - graphviz \ - protobuf \ - protobuf-c \ - zeromq \ - rabbitmq-c \ - mosquitto \ - libusb + openssl \ + libconfig \ + curl \ + jansson \ + spdlog \ + fmt \ + libnl3 \ + graphviz \ + protobuf \ + protobuf-c \ + zeromq \ + rabbitmq-c \ + mosquitto \ + libusb \ + ossp-uuid@testing RUN if [ "${ARCH}" != "armv6" -a "${ARCH}" != "armv7" ]; then \ apk add \ @@ -144,7 +140,7 @@ ENV LD_LIBRARY_PATH=/app/lib:/app/lib64 ENV PATH=/app/bin:${PATH} # Test if it runs -RUN villas node -h 2&>1 > /dev/null +RUN /app/bin/villas-node -h 2>&1 > /dev/null ARG GIT_REV=unknown ARG GIT_BRANCH=unknown diff --git a/packaging/docker/Dockerfile.centos b/packaging/docker/Dockerfile.centos index ecb1100a1..bc60fce1d 100644 --- a/packaging/docker/Dockerfile.centos +++ b/packaging/docker/Dockerfile.centos @@ -1,12 +1,4 @@ -# Dockerfile for VILLASnode development. -# -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. -# -# This image can be used for developing VILLASnode -# by running: -# make docker +# CentOS Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC @@ -39,7 +31,7 @@ USER root # Enable Extra Packages for Enterprise Linux (EPEL) repo and PowerTools RUN dnf -y install epel-release dnf-plugins-core -RUN dnf config-manager --set-enabled PowerTools +RUN dnf config-manager --set-enabled powertools # Toolchain RUN dnf -y install \ diff --git a/packaging/docker/Dockerfile.debian b/packaging/docker/Dockerfile.debian index 8bccba0ba..2d3c836ec 100644 --- a/packaging/docker/Dockerfile.debian +++ b/packaging/docker/Dockerfile.debian @@ -1,12 +1,4 @@ -# Dockerfile for VILLASnode development. -# -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. -# -# This image can be used for developing VILLASnode -# by running: -# make docker +# Debian Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC diff --git a/packaging/docker/Dockerfile.debian-multiarch b/packaging/docker/Dockerfile.debian-multiarch index 5fd6cfae6..ef4fdffa4 100644 --- a/packaging/docker/Dockerfile.debian-multiarch +++ b/packaging/docker/Dockerfile.debian-multiarch @@ -1,12 +1,4 @@ -# Dockerfile for VILLASnode development. -# -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. -# -# This image can be used for developing VILLASnode -# by running: -# make docker +# Debian Multiarch Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC diff --git a/packaging/docker/Dockerfile.fedora b/packaging/docker/Dockerfile.fedora index 739a2d9f0..2c19c8f5d 100644 --- a/packaging/docker/Dockerfile.fedora +++ b/packaging/docker/Dockerfile.fedora @@ -1,12 +1,4 @@ -# Dockerfile for VILLASnode development. -# -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. -# -# This image can be used for developing VILLASnode -# by running: -# make docker-dev +# Fedora Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC diff --git a/packaging/docker/Dockerfile.fedora-minimal b/packaging/docker/Dockerfile.fedora-minimal index 2d6d5810c..a7880ac29 100644 --- a/packaging/docker/Dockerfile.fedora-minimal +++ b/packaging/docker/Dockerfile.fedora-minimal @@ -1,4 +1,4 @@ -# Minimal Dockerfile for building VILLASnode +# Minimal Fedora Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC diff --git a/packaging/docker/Dockerfile.ubuntu b/packaging/docker/Dockerfile.ubuntu index b34bf1e29..6ac0ff816 100644 --- a/packaging/docker/Dockerfile.ubuntu +++ b/packaging/docker/Dockerfile.ubuntu @@ -1,12 +1,4 @@ -# Dockerfile for VILLASnode development. -# -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. -# -# This image can be used for developing VILLASnode -# by running: -# make docker +# Ubuntu Dockerfile # # @author Steffen Vogel # @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC diff --git a/python/examples/Shmem_CIGRE_MV.py b/python/examples/Shmem_CIGRE_MV.py new file mode 100644 index 000000000..c5cb8d713 --- /dev/null +++ b/python/examples/Shmem_CIGRE_MV.py @@ -0,0 +1,106 @@ +import time +from villas.node.node import Node as VILLASnode + +# This could be moved to the DPsim Python code later + + +def get_dpsim_shmem_interface_signals(): + """ It would be nice if the DPsim Shmem interface could + build-up a list of actual signal descriptions + (names, units, etc..) which attributes are exported. + This would eliviate the user from manually configuring + signal mappings """ + signals = [] + + for i in range(0, 30): + signals.append({ + 'name': f'signal_{i}', + 'type': 'float', + 'unit': 'volts' + }) + + return signals + + +def get_dpsim_shmem_interface_config(): + return { + 'type': 'shmem', + 'in': { + 'name': '/dpsim1-villas', + 'hooks': [ + { + 'type': 'stats' + } + ], + 'signals': get_dpsim_shmem_interface_signals() + }, + 'out': { + 'name': '/villas-dpsim1' + } + } + + +def get_villas_config(): + return { + 'nodes': { + 'broker1': { + 'type': 'mqtt', + 'format': 'json', + 'host': '172.17.0.1', + 'in': { + 'subscribe': '/powerflow-dpsim'}, + 'out': { + 'publish': '/dpsim-powerflow' + } + }, + 'dpsim1': get_dpsim_shmem_interface_config(), + }, + 'paths': [ + { + 'in': 'dpsim1', + 'out': 'broker1', + + 'hooks': [ + { + 'type': 'limit_rate', + 'rate': 50 + } + ] + } + ] + } + + +def main(): + + node = VILLASnode( + config=get_villas_config() + ) + + node.start() # VILLASnode starts running in the background from here.. + + # Some infos from the running VILLASnode instance queried via its REST API + print('VILLASnode running?: ', node.is_running()) + print('VILLASnode status: ', node.status) + print('VILLASnode nodes: ', node.nodes) + print('VILLASnode paths: ', node.paths) + print('VILLASnode config: ', node.active_config) + print('VILLASnode version: ', node.get_version()) + + # Load a new config into the running + # VILLASnode instance (old config will be replaced) + new_config = node.active_config + new_config['paths'].append({ + 'out': 'dpsim1', + 'in': 'broker1' + }) + + node.load_config(new_config) + + time.sleep(100) + + node.stop() + + +if __name__ == 'main': + main()