From 2c97a07953c45a070ad79eaa185d505a32e4c695 Mon Sep 17 00:00:00 2001 From: Abhijit Dasgupta Date: Tue, 19 Nov 2019 09:05:51 +0000 Subject: [PATCH] OPC-UA support in IOT Gateway Node Added OPC-UA scripts for deploying in IOT Gateway Blueprint Modified setup.sh script to invoke OPC-UA install script Added License in build.sh and install.sh scripts under OPC-UA Signed-off-by: Abhijit Dasgupta Change-Id: I538a352b4e533670b3502d8e6b26f6d1793183ad --- .../iotgateway/scripts/opc-ua/docker/Dockerfile | 12 +++++ .../iotgateway/scripts/opc-ua/docker/build.sh | 38 ++++++++++++++ blueprints/iotgateway/scripts/opc-ua/install.sh | 61 ++++++++++++++++++++++ blueprints/iotgateway/scripts/setup.sh | 20 +++++++ 4 files changed, 131 insertions(+) create mode 100644 blueprints/iotgateway/scripts/opc-ua/docker/Dockerfile create mode 100755 blueprints/iotgateway/scripts/opc-ua/docker/build.sh create mode 100755 blueprints/iotgateway/scripts/opc-ua/install.sh diff --git a/blueprints/iotgateway/scripts/opc-ua/docker/Dockerfile b/blueprints/iotgateway/scripts/opc-ua/docker/Dockerfile new file mode 100644 index 0000000..b3bafb5 --- /dev/null +++ b/blueprints/iotgateway/scripts/opc-ua/docker/Dockerfile @@ -0,0 +1,12 @@ +FROM centos:centos7 +ADD ./work/ /root/work +RUN yum install -y gcc git +RUN yum groupinstall -y 'Development Tools' +RUN cd /root/work && ls -al && tar xzf cmake-3.15.2.tar.gz && \ + rpm -Uvh scons-2.3.0-1.el7.centos.noarch.rpm && \ + python get-pip.py && \ + cd cmake-3.15.2 && ./bootstrap && \ + make && \ + make install && \ + cd ../protocol-opcua-c/ && \ + ./build.sh diff --git a/blueprints/iotgateway/scripts/opc-ua/docker/build.sh b/blueprints/iotgateway/scripts/opc-ua/docker/build.sh new file mode 100755 index 0000000..3c2d7d4 --- /dev/null +++ b/blueprints/iotgateway/scripts/opc-ua/docker/build.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2019 Huawei Tech and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +set -o errexit + +# set the docker name and docker tag when you build +DOCKER_NAME= +DOCKER_TAG= + +export ELIOT_DIR=$(cd $(dirname $0); pwd) +export WORK_DIR=$ELIOT_DIR/work +export CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz +export SCONS_PPA_URL=http://repo.okay.com.mx/centos/7/x86_64/release//scons-2.3.0-1.el7.centos.noarch.rpm +export GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py +export OPCUA_REPO=https://github.com/edgexfoundry-holding/protocol-opcua-c.git +export DOCKER_NAME=${DOCKER_NAME:-"eliot/opc-ua"} +export DOCKER_TAG=${DOCKER_TAG:-"latest"} + + +rm -rf $WORK_DIR +mkdir -p $WORK_DIR + +cd $WORK_DIR +wget $CMAKE_URL +wget $SCONS_PPA_URL +wget $GET_PIP_URL +git clone $OPCUA_REPO + +cd $ELIOT_DIR +docker build ./ -t $DOCKER_NAME:$DOCKER_TAG diff --git a/blueprints/iotgateway/scripts/opc-ua/install.sh b/blueprints/iotgateway/scripts/opc-ua/install.sh new file mode 100755 index 0000000..5dab3e8 --- /dev/null +++ b/blueprints/iotgateway/scripts/opc-ua/install.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2019 Huawei Tech and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +set -o errexit + +# set the docker name and docker tag when you build +# export DOCKER_NAME=eliot/opc-ua +# export DOCKER_TAG=latest + +export ELIOT_DIR=$(cd $(dirname $0); pwd) +export WORK_DIR=$ELIOT_DIR/work +export CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz +export SCONS_PPA_URL=http://repo.okay.com.mx/centos/7/x86_64/release//scons-2.3.0-1.el7.centos.noarch.rpm +export GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py +export OPCUA_REPO=https://github.com/edgexfoundry-holding/protocol-opcua-c.git +export DOCKER_NAME=${DOCKER_NAME:-"eliot/opc-ua"} +export DOCKER_TAG=${DOCKER_TAG:-"latest"} + +# Clean and Create the work directory +rm -rf $WORK_DIR +mkdir -p $WORK_DIR + +yum install -y gcc git wget +yum groupinstall -y 'Development Tools' +# Get the package and source code +cd $WORK_DIR +wget $CMAKE_URL +wget $SCONS_PPA_URL +wget $GET_PIP_URL +git clone $OPCUA_REPO + +# Install Package +rpm -Uvh scons-2.3.0-1.el7.centos.noarch.rpm +python get-pip.py + +# Build and Install camke +tar xzf cmake-3.15.2.tar.gz +cd ${WORK_DIR}/cmake-3.15.2 +./bootstrap +make +make install + +# Build the opc-ua server and client +cd ${WORK_DIR}/protocol-opcua-c/ +./build.sh + +set +x +echo "####################################################" +echo "# If you want to start the server, follow below steps" +echo "# cd ${WORK_DIR}/protocol-opcua-c/example/out" +echo "# ./server" +echo "####################################################" + diff --git a/blueprints/iotgateway/scripts/setup.sh b/blueprints/iotgateway/scripts/setup.sh index 8406c73..e1af2bb 100755 --- a/blueprints/iotgateway/scripts/setup.sh +++ b/blueprints/iotgateway/scripts/setup.sh @@ -160,6 +160,20 @@ install_prometheus(){ echo "Prometheus deployed successfully on ELIOT Manager Node and integrated with CAdvisor running on IOT-Gateway Nodes " } +install_opcua_centos(){ + set -o xtrace + INSTALL_OPCUA_ATEDGE="cd eliot/blueprints/iotgateway/scripts/opcua/ && source install.sh" + while read line + do + nodeinfo="${line}" + nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) + nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) + nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) + sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${INSTALL_OPCUA_ATEDGE} < /dev/null + done < nodelist > /dev/null 2>&1 + echo " OPC-UA Server and Client are successfully Deployed on all IOT-Gateway Nodes" +} + # Start # @@ -187,6 +201,12 @@ install_edgex sleep 20 verify_edgex +# Installing OPC-UA on IOT Gateway Node + +if [[ $OSPLATFORM = *CentOS* ]]; then + install_opcua_centos + + # Removing the taint from master node kubectl taint nodes --all node-role.kubernetes.io/master- || true -- 2.16.6