1 description: Heat template for HV-VES simulator deployment
3 heat_template_version: 2013-05-23
6 name: { description: Instance name, label: Name, type: string, default: hv-ves_sim }
7 flavor_name: { description: Instance flavor to be used, label: Flavor Name, type: string }
8 image_name: { description: Ubuntu 16.04 image to be used, label: Image Name, type: string }
9 private_net_id: { description: Private network id, label: Private Network ID, type: string }
10 private_subnet_id: { description: Private subnetwork id, label: Private Subnetwork ID, type: string }
11 public_net_id: { description: Public network id, label: Public Network ID, type: string }
12 security_group: { description: Security group to be used, label: Security Groups, type: string, default: default }
13 key_pair: { description: Key pair, label: Key Pair, type: string }
14 proxy: { description: Proxy, label: Proxy, type: string, default: "" }
15 mode: { description: Mode - standalone or integrated to ONAP (values - 'standalone' or 'onap'), label: Mode, type: string, default: "onap" }
16 hvves_ip: { description: HV-VES IP, label: HV-VES IP, type: string, default: "" }
17 hvves_port: { description: HV-VES Port, label: HV-VES Port, type: string, default: "30222" }
18 nexus_port: { description: ONAP Nexus Port, label: ONAP Nexus Port, type: string, default: "10001" }
19 tls: { description: HV-VES TLS functionality, label: HV-VES TLS, type: string, default: "false" }
23 type: OS::Nova::Server
25 name: { get_param: name }
26 image: { get_param: image_name }
27 flavor: { get_param: flavor_name }
28 key_name: { get_param: key_pair }
30 - port: { get_resource: hvves-sim_port }
39 DOCKER_COMPOSE_VERSION=1.22.0
40 PROTOBUF_VERSION=3.6.1
44 sed -i 's/PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
45 sed -i 's/PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
47 echo -e "onap\nonap" | passwd root
51 rm -rf /var/lib/apt/lists/*
56 docker_install_configure () {
57 curl "https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh" | sh
58 mkdir -p /etc/systemd/system/docker.service.d/
59 cat > /etc/systemd/system/docker.service.d/docker.conf << EOF
62 ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=nexus3.onap.org:$nexus_port
63 Environment="HTTP_PROXY=$proxy"
65 systemctl daemon-reload
66 systemctl restart docker
67 apt-mark hold docker-ce
68 docker login -u docker -p docker nexus3.onap.org:$nexus_port
71 docker_compose_install () {
72 curl -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
73 chmod +x /usr/local/bin/docker-compose
77 apt-get install -y unzip
78 cd ~;curl -OL "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip"
79 unzip ~/protoc-$PROTOBUF_VERSION-linux-x86_64.zip -d ~/protoc3
80 mv ~/protoc3/bin/* /usr/local/bin/
81 mv ~/protoc3/include/* /usr/local/include/
82 chown "$USER":"$USER" /usr/local/bin/protoc
83 chown -R "$USER":"$USER" /usr/local/include/google
85 rm -f ~/protoc-$PROTOBUF_VERSION-linux-x86_64.zip
88 proto_files_checkout () {
89 mkdir -p ~/hv-ves_sim/proto;cd ~/hv-ves_sim/proto;wget "https://gerrit.onap.org/r/gitweb?p=dcaegen2/collectors/hv-ves.git;a=blob_plain;f=hv-collector-domain/src/main/proto/event/VesEvent.proto;hb=HEAD" -O VesEvent.proto;wget "https://gerrit.onap.org/r/gitweb?p=dcaegen2/collectors/hv-ves.git;a=blob_plain;f=hv-collector-domain/src/main/proto/measurements/HVMeasFields.proto;hb=HEAD" -O HVMeasFields.proto;wget "https://gerrit.onap.org/r/gitweb?p=dcaegen2/collectors/hv-ves.git;a=blob_plain;f=hv-collector-domain/src/main/proto/measurements/MeasDataCollection.proto;hb=HEAD" -O MeasDataCollection.proto
93 apt-get -y install kafkacat
96 hvves_sim_yml_checkout () {
97 cd ~/hv-ves_sim/;wget "https://gerrit.onap.org/r/gitweb?p=dcaegen2/collectors/hv-ves.git;a=blob_plain;f=docker-compose.yml;hb=HEAD" -O docker-compose.yml;sed -i "s/image: o/image: nexus3.onap.org:$nexus_port\/o/g" docker-compose.yml
100 dcae_simulator_disable () {
101 cd ~/hv-ves_sim/;sed -i '/ dcae-app-simulator/,$d' docker-compose.yml
105 apt-get -y install default-jre
106 mkdir ~/hv-ves_sim/ssl
107 cd ~/hv-ves_sim/ssl;wget "https://gerrit.onap.org/r/gitweb?p=dcaegen2/collectors/hv-ves.git;a=blob_plain;f=ssl/gen-certs.sh;hb=HEAD" -O gen-certs.sh;chmod +x gen-certs.sh
108 cd ~/hv-ves_sim/ssl;/bin/bash gen-certs.sh
111 start_simulator_env () {
112 if [ "$mode" == "standalone" ]
114 echo -e "127.0.0.1\tconsul" >> /etc/hosts
115 cd ~/hv-ves_sim;nohup docker-compose up &> ~/hv-ves_sim/docker-compose.log &
118 sim=`grep -q "Started xNF Simulator API server" ~/hv-ves_sim/docker-compose.log ; echo $?`
121 echo '{"kafkaBootstrapServers": "kafka:9092","routing":[{"fromDomain":11,"toTopic":"ves_hvRanMeas"}]}' | curl -X PUT -d @- http://consul:8500/v1/kv/veshv-config -H "Content-Type:application/json"
126 elif [ "$mode" == "onap" ] && [ "$tls" == "true" ]
128 cd ~/hv-ves_sim;nohup docker run -p "6062:6062" -v "$(pwd)/ssl/:/etc/ves-hv/" -i "nexus3.onap.org:$nexus_port/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-xnf-simulator:latest" "--listen-port 6062 --ves-host $hvves_ip --ves-port $hvves_port --trust-store /etc/ves-hv/trust.p12 --trust-store-password onaponap --key-store /etc/ves-hv/client.p12 --key-store-password onaponap" &> ~/hv-ves_sim/docker.log &
129 echo -e "127.0.0.1\tmessage-router-kafka" >> /etc/hosts
130 elif [ "$mode" == "onap" ] && [ "$tls" == "false" ]
132 cd ~/hv-ves_sim;nohup docker run -p "6062:6062" -i "nexus3.onap.org:$nexus_port/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-xnf-simulator:latest" "--listen-port 6062 --ves-host $hvves_ip --ves-port $hvves_port --ssl-disable" &> ~/hv-ves_sim/docker.log &
133 echo -e "127.0.0.1\tmessage-router-kafka" >> /etc/hosts
139 simulator_script_create () {
140 cat > ~/hv-ves_sim/simulator.sh << EOF
143 input_parameters () {
149 echo -e "Usage: simulator.sh [send] [message]"
153 if [[ -z \$1 ]] || [[ -z \$2 ]]
155 echo "Input parameter(s) empty."
158 elif [[ \$1 == "send" ]] && [[ -n \$2 ]]
160 curl -X POST -d @\$2 http://localhost:6062/simulator/async -H "Content-Type:application/json"
167 input_parameters "\$1" "\$2"
168 send_message "\$option" "\$file"
173 chmod +x ~/hv-ves_sim/simulator.sh
177 message_samples_checkout () {
178 mkdir ~/hv-ves_sim/samples
179 cd ~/hv-ves_sim/samples ; wget "https://gerrit.onap.org/r/gitweb?p=integration.git;a=blob_plain;f=test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/scenarios/authorization/xnf-valid-messages-request.json;hb=HEAD" -O xnf-valid-messages-request.json ; wget "https://gerrit.onap.org/r/gitweb?p=integration.git;a=blob_plain;f=test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/scenarios/invalid-gpb-data/xnf-invalid-gpb-data-request.json;hb=HEAD" -O xnf-invalid-gpb-data-request.json ; wget "https://gerrit.onap.org/r/gitweb?p=integration.git;a=blob_plain;f=test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/scenarios/multiple-simulators-payload/xnf-simulator-smaller-valid-request.json;hb=HEAD" -O xnf-simulator-smaller-valid-request.json
185 docker_install_configure
186 docker_compose_install
190 hvves_sim_yml_checkout
191 dcae_simulator_disable
194 simulator_script_create
195 message_samples_checkout
198 $proxy: { get_param: proxy }
199 $mode: { get_param: mode }
200 $hvves_ip: { get_param: hvves_ip }
201 $hvves_port: { get_param: hvves_port }
202 $nexus_port: { get_param: nexus_port }
203 $tls: { get_param: tls }
205 type: OS::Neutron::Port
207 network_id: { get_param: private_net_id }
209 - { get_param: security_group }
211 - subnet_id: { get_param: private_subnet_id }
213 type: OS::Neutron::FloatingIP
215 floating_network_id: { get_param: public_net_id }
216 port_id: { get_resource: hvves-sim_port }
219 hvves-sim_private_ip:
220 description: HV-VES simulator private IP
221 value: { get_attr: [ hvves-sim, first_address ] }
223 description: HV-VES simualtor floating IP
224 value: { get_attr: [ hvves-sim_public, floating_ip_address ] }