summaryrefslogtreecommitdiffstats
path: root/mcp/scripts/globals.sh
AgeCommit message (Expand)AuthorFilesLines
2018-02-06[virtual] Add missing ODL dhcp_intAlexandru Avadanii1-0/+5
2018-02-05[PDF] Switch to generate_config, unify templatesAlexandru Avadanii1-1/+5
2018-02-05deploy.sh: Move notify() to globals.shAlexandru Avadanii1-0/+28
2017-12-11[baremetal] Move all MaaS PXE net config to PDFAlexandru Avadanii1-3/+0
2017-12-08[baremetal] PDF: Use net_admin for MaaS PXE netAlexandru Avadanii1-1/+1
2017-10-15states: Break on error, retry states up to 5 timesAlexandru Avadanii1-1/+2
2017-10-03ci/deploy.sh: Move global vars to separate fileAlexandru Avadanii1-0/+21
#n142'>142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
heat_template_version: 2014-10-16
description: HOT template to create a DPI

parameters:
   default_net:
      type: string
   default_subnet:
      type: string
   source_net:
      type: string
   source_subnet:
      type: string
   destination_net:
      type: string
   destination_subnet:
      type: string
   internal_net:
      type: string
   internal_subnet:
      type: string
   node:
      type: string
      default: compB
   name:
      type: string
      default: vtc
   ip_family:
      type: string
   timeout:
      type: number
      description: Timeout for WaitCondition, depends on your image and environment
      default: 1000

resources:
   wait_condition:
      type: OS::Heat::WaitCondition
      properties:
         handle: {get_resource: wait_handle}
         count: 1
         timeout: {get_param: timeout}

   wait_handle:
      type: OS::Heat::WaitConditionHandle


   ### DEFAULT NETWORK FOR MERLIN DATA
   port_1:
      type: OS::Neutron::Port
      properties:
         network: { get_param: default_net }
         binding:vnic_type: normal
         fixed_ips:
            - subnet: { get_param: default_subnet }

   ### NETWORK FOR RECEIVING TRAFFIC
   port_2:
      type: OS::Neutron::Port
      properties:
         network: { get_param: source_net }
         binding:vnic_type: direct
         fixed_ips:
            - subnet: { get_param: source_subnet }

   ### NETWORK FOR SENDING TRAFFIC
   port_3:
      type: OS::Neutron::Port
      properties:
         network: { get_param: destination_net }
         binding:vnic_type: direct
         fixed_ips:
            - subnet: { get_param: destination_subnet }

   flavor:
      type: OS::Nova::Flavor
      properties:
         disk: 20
         ram: 1024
         vcpus: 2
         #extra_specs: { node: { get_param: node }, "hw:cpu_policy": "#core_pinning_enabled", "hw:cpu_threads_policy": "#core_pinning_mode", "hw:mem_page_size": "#hugepages" }
         extra_specs: { node: { get_param: node } }

   server:
      type: OS::Nova::Server
      properties:
         name: vTC
         key_name: test
         image: ubuntu1404
         user_data:
                str_replace:
                    template: |
                        #!/bin/sh

                        # Creation of a user
                        NAME=$name
                        echo "Creating custom user..."
                        useradd clouduser -g admin -s /bin/bash -m
                        echo clouduser:secrete | chpasswd
                        echo "Enabling ssh password login..."
                        sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
                        service ssh restart
                        sleep 1

                        # wake up interfaces
                        ifconfig eth1 up
                        ifconfig eth2 up
                        dhclient eth1
                        dhclient eth2

                        sed -i 's/localhost/localhost vtc/g' /etc/hosts
                        ip route del 0/0
                        route add default gw 192.168.200.1

                        AA=$(netstat -ie | grep -B1 $IP_FAMILY | awk '{ print $1 }')
                        BB=$(echo $AA | awk '{ print $1 }')

                        # Setup Instrumentation Agent
                        rm -rf cimmaron
                        mkdir cimmaron
                        cd cimmaron
                        apt-get install -y zip
                        wget http://10.2.1.65/~iolie/merlin/MerlinAgent-12-06-2015-TNovaVM-001.zip
                        unzip MerlinAgent-12-06-2015-TNovaVM-001.zip
                        ./updateConfiguration.py ./instrumentation.cfg tags source=tnova_vm
                        ./updateConfiguration.py ./instrumentation.cfg tags role="$NAME"
                        nohup ./Agent.py ./instrumentation.cfg >log.out 2>&1 &
                        cd ..

                        # Setup for PF_RING and bridge between interfaces
                        apt-get update
                        apt-get install -y git build-essential gcc libnuma-dev flex byacc libjson0-dev dh-autoreconf libpcap-dev libpulse-dev libtool pkg-config

                        # Setup multicast
                        echo smcroute -d mgroup from $BB group 224.192.16.1 > /etc/smcroute.conf
                        cd /home/clouduser/
                        git clone https://github.com/troglobit/smcroute.git
                        cd smcroute
                        sed -i 's/aclocal-1.11/aclocal/g' ./autogen.sh
                        sed -i 's/automake-1.11/automake/g' ./autogen.sh
                        ./autogen.sh
                        ./configure
                        make
                        make install
                        cd ..
                        touch multicast.sh
                        echo "#!/bin/bash" > multicast.sh
                        echo "while [ true ]" >> multicast.sh
                        echo "do" >> multicast.sh
                        echo "  smcroute -k" >> multicast.sh
                        echo "  smcroute -d" >> multicast.sh
                        echo "  sleep 50" >> multicast.sh
                        echo "done" >> multicast.sh
                        chmod +x multicast.sh
                        ./multicast.sh &

                        # Setup for PF_RING and bridge between interfaces
                        # Akis Repository
                        #git clone https://akiskourtis:ptindpi@bitbucket.org/akiskourtis/vtc.git
                        #cd vtc
                        #git checkout stable

                        # Intel Repository
                        git clone http://vincenzox.m.riccobene%40intel.com:vincenzo@134.191.243.6:8081/t-nova/vtc_master.git
                        cd vtc_master

                        cd nDPI
                        NDPI_DIR=$(pwd)
                        echo $NDPI_DIR
                        NDPI_INCLUDE=$(pwd)/src/include
                        echo $NDPI_INCLUDE
                        ./autogen.sh
                        ./configure
                        make
                        make install
                        cd ..
                        cd PF_RING
                        make
                        cd userland/examples/
                        sed -i 's/EXTRA_LIBS =/EXTRA_LIBS = '"${NDPI_DIR}"'/src/lib/.libs/libndpi.a -ljson-c/g' ./Makefile
                        sed -i 's/ -Ithird-party/ -Ithird-party -I'"$NDPI_INCLUDE"' -I'"$NDPI_DIR"'/g' ./Makefile
                        make
                        cd ../..
                        cd ..
                        cd ..
                        #insmod ./vtc/PF_RING/kernel/pf_ring.ko min_num_slots=8192 enable_debug=1 quick_mode=1 enable_tx_capture=0
                        #./vtc/PF_RING/userland/examples/pfbridge -a eth1 -b eth2 &
                        insmod ./vtc_master/PF_RING/kernel/pf_ring.ko min_num_slots=8192 enable_debug=1 quick_mode=1 enable_tx_capture=0
                        ./vtc_master/PF_RING/userland/examples/pfbridge -a eth1 -b eth2 &
                        wc_notify --data-binary '{"status": "SUCCESS"}'
                    params:
                        wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
                        $name: { get_param: name }
                        $IP_FAMILY: { get_param: ip_family }

         flavor: { get_resource: flavor }
         networks:
            - port: { get_resource: port_1 }
            - port: { get_resource: port_2 }
            - port: { get_resource: port_3 }
outputs: