4 # Vagrantfile API/syntax version.
5 VAGRANTFILE_API_VERSION = "2"
7 # This is a single-vm vagrant file that will install OpenDaylight and all the tools needed to run
9 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11 # NFS is fragile, disable it and use rsync
12 config.nfs.functional = false
14 # Explicitly using the "insecure" private key below, so don't need the insert_key
15 config.ssh.insert_key = false
17 # Set x11 forwarding so we can run GUIs on host from ssh sessions to guest
18 config.ssh.forward_x11 = true
20 # Box setup (specs, tools, etc)
21 config.vm.define "csit" do |csit|
23 csit.vm.hostname = "csit"
25 # Configure 4G RAM for virtualbox or libvirt.
26 csit.vm.provider :virtualbox do |c|
32 # Build Vagrant box based on Fedora 26
33 csit.vm.box = "fedora/26-cloud-base"
35 # Set prompt for vagrant user to match the default/expected prompt for upstream ODL CSIT
36 # Note: upstream CSIT has the ability to modify expected prompts dynamically, but this
37 # just makes it easier
38 csit.vm.provision "shell", inline: "echo 'PS1=\"[\\u@\\h \\W]> \"' >> ~vagrant/.bashrc"
40 # Forward ODL ports so they are accessible on the host machine
41 # ODL's APIs (REST and GUI) respond on both 8080 and 8181 by default
42 csit.vm.network "forwarded_port", guest: 8080, host: 8080
43 csit.vm.network "forwarded_port", guest: 8181, host: 8181
45 # Install dependencies and tools from dnf
46 csit.vm.provision "shell",
47 inline: "dnf install -y --nogpgcheck git git-review gcc libffi-devel openssl-devel \
48 python-devel redhat-rpm-config python-pip \
49 sshpass openvswitch python-dnf firefox xauth \
50 wireshark wireshark-gnome"
52 # Give vagrant user permission to sniff interfaces
53 csit.vm.provision "shell", inline: "usermod -a -G wireshark vagrant"
54 csit.vm.provision "shell", inline: "setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap"
56 # Install dependencies and tools from pip
57 csit.vm.provision "shell",
58 inline: "pip install --upgrade docker-py importlib requests scapy netifaces netaddr ipaddr \
59 jsonpath-rw robotframework{,-{httplibrary,requests,sshlibrary,selenium2library}}"
61 # Install ODL using the Ansible provisioner
62 csit.vm.provision "ansible" do |ansible|
63 # Path to Ansible playbook that installs ODL using ODL's Ansible role
64 ansible.playbook = "provisioning/all_defaults_playbook.yml"
67 # Modify bashrc to set JAVA path
68 csit.vm.provision "shell", inline: "echo 'export JAVA_HOME=/etc/alternatives/jre_1.8.0' >> /etc/bashrc"
70 # Enable and Start Open vSwitch
71 csit.vm.provision "shell", inline: "sudo systemctl enable openvswitch; \
72 sudo systemctl start openvswitch"
75 csit.vm.provision "shell", inline: "git clone git://github.com/mininet/mininet"
76 csit.vm.provision "shell", inline: "cd mininet;git checkout -b 2.2.1 2.2.1;cd .."
77 csit.vm.provision "shell", inline: "mininet/util/install.sh -nf"
79 # Pull in Integration/Test and Releng/Builder repos
80 csit.vm.provision "shell",
81 inline: "git clone https://git.opendaylight.org/gerrit/p/integration/test.git"
82 csit.vm.provision "shell", inline: "chown -R vagrant:vagrant ~vagrant/test"
84 csit.vm.provision "shell",
85 inline: "git clone https://git.opendaylight.org/gerrit/p/releng/builder.git"
86 csit.vm.provision "shell", inline: "chown -R vagrant:vagrant ~vagrant/builder"
88 # configure ssh to know which key file to use with gerrit
89 # the keypair needs to be created by user with proper name, location and permissions
90 csit.vm.provision "shell",
91 inline: "echo -e \"Host git.opendaylight.org\\n IdentityFile /home/vagrant/.ssh/gerrit_rsa\" > /home/vagrant/.ssh/config"
92 csit.vm.provision "shell", inline: "chmod 0600 /home/vagrant/.ssh/config"
93 csit.vm.provision "shell", inline: "chown vagrant:vagrant /home/vagrant/.ssh/config"
95 # pull private "insecure" vagrant key to match the default public key for key authentication for robot suites
96 csit.vm.provision "shell",
97 inline: "curl -o ~vagrant/.ssh/id_rsa https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant"
98 csit.vm.provision "shell", inline: "chown vagrant:vagrant ~vagrant/.ssh/id_rsa"
99 csit.vm.provision "shell", inline: "chmod 0600 ~vagrant/.ssh/id_rsa"
101 # Install Jenkins Job Builder (JJB)
102 csit.vm.provision "shell",
103 inline: "git clone https://git.openstack.org/openstack-infra/jenkins-job-builder"
104 csit.vm.provision "shell", inline: "chown -R vagrant:vagrant ~vagrant/jenkins-job-builder"
105 csit.vm.provision "shell", inline: "cd ~vagrant/jenkins-job-builder; \
106 pip install -r requirements.txt; \
109 # Disable selinux because once mininet is used for the first time, it is somehow
110 # blocking the vagrant ssh connections after that. Also need to reboot for it to
112 csit.vm.provision "shell",
113 inline: "sed -i 's/SELINUX=\\(enforcing\\|permissive\\)/SELINUX=disabled/g' /etc/selinux/config"
114 csit.vm.provision "shell", inline: "reboot now"