summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vagrant/README.md21
-rw-r--r--vagrant/Vagrantfile43
-rw-r--r--vagrant/bootstrap.sh14
-rw-r--r--vagrant/compute.conf23
-rw-r--r--vagrant/control.conf30
-rwxr-xr-xvagrant/create_onap.sh40
-rw-r--r--vagrant/openrc4
-rwxr-xr-xvagrant/run_demo.sh17
-rw-r--r--vagrant/setup_compute.sh17
-rw-r--r--vagrant/setup_control.sh26
-rwxr-xr-xvagrant/setup_proxy.sh49
11 files changed, 284 insertions, 0 deletions
diff --git a/vagrant/README.md b/vagrant/README.md
new file mode 100644
index 00000000..7473beae
--- /dev/null
+++ b/vagrant/README.md
@@ -0,0 +1,21 @@
+Demo
+====
+
+ONAP demo is created by vagrant. It is verified to work in Ubuntu 16.04 64bit
+with 125G memory & 1T disk.
+
+Setup
+-----
+
+./run_demo.sh
+
+Cleanup
+-------
+
+vagrant destroy -f
+
+Proxy
+-----
+
+Proxy setup is optional. If setup is behind sock5 proxy, SOCKS5_IP, SOCKS5_PORT
+and DNS_SERVER is updated and ./setup_proxy is run before running demo.
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
new file mode 100644
index 00000000..46e1fc2f
--- /dev/null
+++ b/vagrant/Vagrantfile
@@ -0,0 +1,43 @@
+$num_compute_nodes = 1
+
+Vagrant.configure("2") do |config|
+
+ config.vm.box = "bento/ubuntu-16.04"
+
+ config.vm.provider :virtualbox do |vb|
+ vb.customize ["modifyvm", :id, "--memory", 8192]
+ vb.customize ["modifyvm", :id, "--cpus", 8]
+ vb.customize ['modifyvm', :id, '--natnet1', '192.168.240.0/24']
+ vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
+ vb.customize "post-boot",["controlvm", :id, "setlinkstate1", "on"]
+ end
+
+ config.vm.provision "shell", path: "bootstrap.sh", privileged: false
+ config.vm.synced_folder "..", "/demo"
+
+ config.vm.define "control" do |config|
+ config.vm.hostname = "control"
+ config.vm.network "private_network", ip: "192.168.0.10"
+ config.vm.network "private_network", ip: "192.168.1.10"
+ config.vm.provision "shell", path: "setup_control.sh", privileged: false
+ end
+
+ (1 .. $num_compute_nodes).each do |n|
+ config.vm.define vm_name = "compute-#{n}" do |config|
+ config.vm.hostname = vm_name
+ config.vm.network "private_network", ip: "192.168.0.#{n+20}"
+ config.vm.network "private_network", ip: "192.168.1.#{n+20}"
+ config.vm.provision "shell", path: "setup_compute.sh", privileged: false
+ config.vm.provider :virtualbox do |v|
+ v.customize ["modifyvm", :id, "--memory", 81920]
+ v.customize ["modifyvm", :id, "--cpus", 8]
+ file_to_disk1 = "large_disk_file.#{n}.vdi1"
+ v.customize ['createhd', '--filename', file_to_disk1, '--size', 1000 * 1024]
+ v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk1 ]
+ file_to_disk2 = "large_disk_file.#{n}.vdi2"
+ v.customize ['createhd', '--filename', file_to_disk2, '--size', 1000 * 1024]
+ v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', file_to_disk2 ]
+ end
+ end
+ end
+end
diff --git a/vagrant/bootstrap.sh b/vagrant/bootstrap.sh
new file mode 100644
index 00000000..fea28a5e
--- /dev/null
+++ b/vagrant/bootstrap.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+set -ex
+
+sudo apt-get update -y
+sudo apt-get install git -y
+git clone https://github.com/openstack-dev/devstack
+cd devstack; git checkout stable/newton
+sudo apt-get install openvswitch-switch -y
+sudo ovs-vsctl add-br br-ex
+inet=$(ip a | grep 'inet.*enp0s9' | cut -f6 -d' ')
+sudo ip addr flush enp0s9
+sudo ovs-vsctl add-port br-ex enp0s9
+sudo ifconfig br-ex $inet up
+echo "source /vagrant/openrc" >> $HOME/.bash_profile
diff --git a/vagrant/compute.conf b/vagrant/compute.conf
new file mode 100644
index 00000000..e692b82c
--- /dev/null
+++ b/vagrant/compute.conf
@@ -0,0 +1,23 @@
+[[local|localrc]]
+SCREEN_LOGDIR=/opt/stack/log
+LOGFILE=stack.sh.log
+LOG_COLOR=False
+
+HOST_IP=HOSTIP
+HOST_NAME=HOSTNAME
+SERVICE_HOST=192.168.0.10
+SERVICE_HOST_NAME=control
+DATABASE_HOST=$SERVICE_HOST
+
+ADMIN_PASSWORD=admin
+SERVICE_PASSWORD=admin
+DATABASE_PASSWORD=mysql
+RABBIT_PASSWORD=rabbit
+
+ENABLED_SERVICES=n-cpu,n-novnc,rabbit,q-agt,c-vol,mysql
+LIBVIRT_TYPE=qemu
+
+# Open vSwitch provider networking configuration
+Q_USE_PROVIDERNET_FOR_PUBLIC=True
+OVS_BRIDGE_MAPPINGS=public:br-ex
+OVS_PHYSICAL_BRIDGE=br-ex
diff --git a/vagrant/control.conf b/vagrant/control.conf
new file mode 100644
index 00000000..2e74f6fc
--- /dev/null
+++ b/vagrant/control.conf
@@ -0,0 +1,30 @@
+[[local|localrc]]
+SCREEN_LOGDIR=/opt/stack/log
+LOGFILE=stack.sh.log
+LOG_COLOR=False
+
+HOST_IP=192.168.0.10
+HOST_NAME=control
+SERVICE_HOST=192.168.0.10
+SERVICE_HOST_NAME=control
+
+ADMIN_PASSWORD=admin
+SERVICE_PASSWORD=admin
+DATABASE_PASSWORD=mysql
+RABBIT_PASSWORD=rabbit
+
+disable_service n-net
+disable_service tempest
+disable_service c-vol
+ENABLED_SERVICES+=q-svc,q-dhcp,q-meta,q-agt,q-l3
+ENABLED_SERVICES+=,h-eng,h-api,h-api-cfn,h-api-cw
+
+## Neutron options
+Q_L3_ENABLED=True
+NEUTRON_CREATE_INITIAL_NETWORKS=False
+
+# Open vSwitch provider networking configuration
+Q_USE_PROVIDERNET_FOR_PUBLIC=True
+OVS_BRIDGE_MAPPINGS=public:br-ex
+OVS_PHYSICAL_BRIDGE=br-ex
+
diff --git a/vagrant/create_onap.sh b/vagrant/create_onap.sh
new file mode 100755
index 00000000..e201d500
--- /dev/null
+++ b/vagrant/create_onap.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+set -ex
+
+source /vagrant/openrc
+cp /demo/heat/OpenECOMP/* .
+
+# Parameters used across all ONAP components
+pub_net=$(openstack network list -f value|grep public | cut -f1 -d' ')
+sed -i "s/public_net_id:.*/public_net_id: $pub_net/" onap_openstack.env
+sed -i "s/ubuntu_1404_image:.*/ubuntu_1404_image: ubuntu1404/" onap_openstack.env
+sed -i "s/ubuntu_1604_image:.*/ubuntu_1604_image: ubuntu1604/" onap_openstack.env
+sed -i "s/flavor_small:.*/flavor_small: m1.small/" onap_openstack.env
+sed -i "s/flavor_medium:.*/flavor_medium: m1.medium/" onap_openstack.env
+sed -i "s/flavor_large:.*/flavor_large: m1.large/" onap_openstack.env
+sed -i "s/flavor_xlarge:.*/flavor_xlarge: m1.xlarge/" onap_openstack.env
+rm -rf onap onap.pub
+ssh-keygen -t rsa -N '' -f onap
+cp onap onap.pub /vagrant
+pub_key=$(cat onap.pub)
+sed -i "s,pub_key:.*,pub_key: $pub_key," onap_openstack.env
+tenant=$(openstack project list -f value | grep " admin" | cut -f1 -d' ')
+sed -i "s/openstack_tenant_id:.*/openstack_tenant_id: $tenant/" onap_openstack.env
+sed -i "s/openstack_username:.*/openstack_username: admin/" onap_openstack.env
+sed -i "s/openstack_api_key:.*/openstack_api_key: apikey/" onap_openstack.env
+sed -i "s,horizon_url:.*,horizon_url: http://192.168.0.10/dashboard," onap_openstack.env
+sed -i "s,keystone_url:.*,keystone_url: http://192.168.0.10/identity/," onap_openstack.env
+
+# Network parameters
+sed -i "s/external_dns:.*/external_dns: 8.8.8.8/" onap_openstack.env
+
+openstack stack create -t onap_openstack.yaml -e onap_openstack.env ONAP
+
+sleep 180
+vms=$(grep "_vm:" onap_openstack.yaml | cut -f1 -d"_")
+sudo rm -rf /vagrant/hosts
+for vm in $vms
+do
+ ip=$(openstack server list --name $vm -f yaml | grep Networks | cut -f2 -d",")
+ echo "$ip $vm.api.simpledemo.openecomp.org" >> /vagrant/hosts
+done
diff --git a/vagrant/openrc b/vagrant/openrc
new file mode 100644
index 00000000..9ffe018b
--- /dev/null
+++ b/vagrant/openrc
@@ -0,0 +1,4 @@
+export OS_PROJECT_NAME=admin
+export OS_USERNAME=admin
+export OS_PASSWORD=admin
+export OS_AUTH_URL=http://192.168.0.10:5000/v2.0
diff --git a/vagrant/run_demo.sh b/vagrant/run_demo.sh
new file mode 100755
index 00000000..e99b28d7
--- /dev/null
+++ b/vagrant/run_demo.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -ex
+
+sudo apt-get install -y virtualbox
+ver=$(apt-cache policy vagrant | grep Installed | cut -d ':' -f 3)
+if [[ "$ver" != "1.8.7" ]]; then
+ wget --no-check-certificate https://releases.hashicorp.com/vagrant/1.8.7/vagrant_1.8.7_x86_64.deb
+ sudo dpkg -i vagrant_1.8.7_x86_64.deb
+fi
+
+vagrant destroy -f
+vagrant up
+vagrant ssh control -c "/vagrant/create_onap.sh"
+sudo sed -i "/.*simpledemo.openecomp.org.*/d" /etc/hosts
+cat hosts | sudo tee -a /etc/hosts
+sleep 300
+ssh -o StrictHostKeyChecking=no ubuntu@portal.api.simpledemo.openecomp.org -i onap "curl sina.com.cn"
diff --git a/vagrant/setup_compute.sh b/vagrant/setup_compute.sh
new file mode 100644
index 00000000..0c3eba7b
--- /dev/null
+++ b/vagrant/setup_compute.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -ex
+
+cd devstack
+cp /vagrant/compute.conf local.conf
+host=$(hostname)
+ip=$(ifconfig | grep 192.168.0 | cut -f2 -d: | cut -f1 -d' ')
+sed -i -e "s/HOSTIP/$ip/" -e "s/HOSTNAME/$host/" local.conf
+./stack.sh
+
+sudo pvcreate /dev/sdb
+sudo vgextend vagrant-vg /dev/sdb
+sudo lvextend -L +800G /dev/mapper/vagrant--vg-root
+sudo resize2fs /dev/mapper/vagrant--vg-root
+
+sudo pvcreate /dev/sdc
+sudo vgextend stack-volumes-lvmdriver-1 /dev/sdc
diff --git a/vagrant/setup_control.sh b/vagrant/setup_control.sh
new file mode 100644
index 00000000..6ff364f6
--- /dev/null
+++ b/vagrant/setup_control.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+set -ex
+
+cd devstack
+cp /vagrant/control.conf local.conf
+./stack.sh
+
+source /vagrant/openrc
+
+openstack network create public --external --provider-network-type=flat --provider-physical-network=public
+openstack subnet create --network=public --subnet-range=192.168.1.0/24 --allocation-pool start=192.168.1.200,end=192.168.1.250 --gateway 192.168.1.1 public-subnet
+openstack security group list -f value | cut -f1 -d" " | xargs -I {} openstack security group rule create --ingress --ethertype=IPv4 --protocol=0 {}
+
+wget https://cloud-images.ubuntu.com/releases/14.04.1/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img
+wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img
+openstack image create ubuntu1404 --file ubuntu-14.04-server-cloudimg-amd64-disk1.img --disk-format qcow2
+openstack image create ubuntu1604 --file ubuntu-16.04-server-cloudimg-amd64-disk1.img --disk-format qcow2
+
+openstack quota set admin --instances 30
+openstack quota set admin --cores 45
+openstack quota set admin --ram 61440
+
+openstack flavor delete m1.large
+openstack flavor create --public m1.large --id auto --ram 6144 --vcpus 3 --disk 80
+openstack flavor delete m1.xlarge
+openstack flavor create --public m1.xlarge --id auto --ram 6144 --vcpus 4 --disk 100
diff --git a/vagrant/setup_proxy.sh b/vagrant/setup_proxy.sh
new file mode 100755
index 00000000..2161f295
--- /dev/null
+++ b/vagrant/setup_proxy.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+set -ex
+
+SOCKS5_IP=${SOCKS5_IP:-127.0.0.1}
+SOCKS5_PORT=${SOCKS5:-1080}
+DNS_SERVER=${DNS_SERVER:-10.248.2.5}
+
+sudo apt-get install -y redsocks iptables
+
+cat <<EOF | sudo tee /etc/redsocks.conf
+base {
+ log_debug = on;
+ log_info = on;
+ log = "file:/root/proxy.log";
+ daemon = on;
+ redirector = iptables;
+}
+
+redsocks {
+ local_ip = 0.0.0.0;
+ local_port = 6666;
+ ip = $SOCKS5_IP;
+ port = $SOCKS5_PORT;
+ type = socks5;
+}
+EOF
+
+echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
+sudo iptables -t filter -F
+sudo iptables -t mangle -F
+sudo iptables -t nat -F
+
+sudo iptables -t nat -N REDSOCKS || true
+sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
+sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
+sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666
+sudo iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
+sudo iptables -t nat -A PREROUTING -p tcp -j REDSOCKS
+sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
+sudo iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to-destination $DNS_SERVER
+
+sudo service redsocks restart
+wget --no-proxy www.sina.com.cn -O /dev/null