++Table of Contents++
[TOC]
The bare metal machine MUST have ubuntu server 16.04 LTS installed with the following packages (and only the following packages) selected during installation:
[*] standard system utilities
[*] Virtual Machine host
[*] OpenSSH server
This will ensure that the user you've defined during the installation can run the virsh shell as a standard user rather than as the root user. This is necessary to ensure the installer software operates as designed. Please ensure that ubuntu server is installed and NOT ubuntu desktop. ![Ubuntu Installer Graphic](file:///C:Users/sslobodr/Documents/Works In Progress/2017/voltha/UbuntuInstallLaptop.png)
Start with a clean installation of Ubuntu16.04 LTS on a bare metal server that is capable of virtualization. How to determine this is beyond th scope of this document. Ensure that package selection is as outlined above. Once the installation is complete, login to the box and type virsh list
. If this doesnt work then you'll need to troubleshoot the installation. If it works, then proceed to the next section. Please note use exactly virsh list
NOT sudo virsh list
. If you must use the sudo
command then the installation was not performed properly and should be repeated. If you're familiar with the KVM environment there are steps to solve this and other issues but this is also beyond the scope of this document. So if unfamiluar with the KVM environment a re-installation exactly as outlined above is required.
##Create the base ubuntu/xenial box Though there are some flavors of ubuntu boxes available but they usually have additional features installed or missing so it's best to just create the image from the ubuntu installation iso image.
voltha> wget http://releases.ubuntu.com/xenial/ubuntu-16.04.2-server-amd64.iso
voltha> echo "virt-install -n Ubuntu16.04 -r 1024 --vcpus=2 --disk size=50 -c ubuntu-16.04.2-server-amd64.iso --accelerate --network network=default,model=virtio --connect=qemu:///system --vnc --noautoconsole -v" > Ubuntu16.04Vm
voltha> . Ubuntu16.04Vm
voltha> virt-manager
Once the virt manager opens, open the console of the Ubuntu16.04 VM and follow the installation process.
When promprompted use the hostname voltha
. Also when prompted you should create one user Vagrant Vagrant
and use the offered up userid of vagrant
. When prompted for the password of the vagrant user, use vagrant
. When asked if a weak password should be used, select yes. Don't encrypt the home directory. Select the OpenSSH server when prompted for packages to install. The last 3 lines of your package selection screen should look likethis. Everything above standard system utilities
should not be selected.
[*] standard system utilities
[ ] Virtual Machine host
[*] OpenSSH server
Once the installation is complete, run the VM and log in as vagrant password vagrant and install the default vagrant key (this can be done one of two ways, through virt-manager and the console or by uing ssh from the hypervisor host, the virt-manager method is shown below):
vagrant@voltha$ mkdir -p /home/vagrant/.ssh
vagrant@voltha$ chmod 0700 /home/vagrant/.ssh
vagrant@voltha$ wget --no-check-certificate \
https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \
-O /home/vagrant/.ssh/authorized_keys
vagrant@voltha$ chmod 0600 /home/vagrant/.ssh/authorized_keys
vagrant@voltha$ chown -R vagrant /home/vagrant/.ssh
Also create a .ssh directory for the root user:
vagrant@voltha$ sudo mkdir /root/.ssh
Add a vagrant file to /etc/sudoers.d/vagrant with the following:
vagrant@voltha$ echo "vagrant ALL=(ALL) NOPASSWD:ALL" > tmp.sudo
vagrant@voltha$ sudo chown root.root tmp.sudo
vagrant@voltha$ sudo mv tmp.sudo /etc/sudoers.d/vagrant
That's all that's required to prepare the VM imsage to be vagrant enabled. Before proceeding to the next step, shut down the vm.
vagrant@voltha$ sudo telinit 0
Vagrant comes with the Ubuntu 16.04 but it doesn't work with kvm. Downloading and installing the version from hashicorp solves the problem.
voltha> wget https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.3_x86_64.deb
voltha> sudo dpkg -i vagrant_1.9.3_x86_64.deb
voltha> vagrant plugin install vagrant-cachier
voltha> sudo apt-get install libvirt-dev
voltha> vagrant plugin install vagrant-libvirt
When doing this, be careful that you're not in a directory where a Vagrantfile already exists or you'll trash it. It is recommended that a temporary directory is created to perform these actions and then removed once the new box has been added to vagrant.
voltha> cp /var/lib/libvirt/images/Ubuntu16.04.qcow2 box.img
voltha> echo '{
"provider" : "libvirt",
"format" : "qcow2",
"virtual_size" : 50
}' > metadata.json
voltha> cat <<HERE > Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.host = 'localhost'
libvirt.uri = 'qemu:///system'
end
config.vm.define "new" do |custombox|
custombox.vm.box = "custombox"
custombox.vm.provider :libvirt do |test|
test.memory = 1024
test.cpus = 1
end
end
end
HERE
voltha> tar czvf ubuntu1604.box ./metadata.json ./Vagrantfile ./box.img
voltha> vagrant box add --name ubuntu1604 ubuntu1604.box
Important Note: Because of a known issue with Ubuntu 16.04 LTS, it is likely the VM booted by vagrant may be assigned a different interface name (ens5 instead of ens3 for example). If this happens, vagrant will hang waiting for an IP address. The following workaround needs to be applied.
From virt-manager open the console and log into the running vagrant box and do the following. Remember the userid is vagrant
and the password is vagrant vagrant
. First check the name that the interface was assigned:
vagrant@voltha$ ifconfig -a
There should be 2 interfaces ensX and lo. Make note of what X is for the ensX interface, log out, and close the console window.
Now using virt manager again, boot up Ubuntu16.04 and open the console window for it. Remember the userid is vagrant
and the password is vagrant
. Use your favorite editor (vi in this case)
vagrant@voltha$ sudo vi /etc/network/interfaces
In there you should see references to ensY which doesn't correspond to the ensX you saw earlier. Find and replace all instances of ensY with ensX then shutdown the VM.
vagrant@voltha$ telinit 0
Now go back to where you were running vagrant up and hit ctrl-c to kill vagrant and shutdown the VM it can't coonect to.
Issue the following vagrant command to blow away the defective box.
vagrant box remove Ubuntu1604
Now go back to create the default vagrant box and repeat those steps and the problem will no longer occur.
##Download the voltha tree
The voltha tree contains the Vagrant files required to build a multitude of VMs required to both run, test, and also to deploy voltha. The easiest approach is to download the entire tree rather than trying to extract the specific Vagrantfile(s)
required.
Create a .gitconfig file using your favorite editor and add the following:
# This is Git's per-user configuration file.
[user]
name = Your Name
email = [email protected]
[color]
ui = auto
[review "https://gerrit.opencord.org/"]
username=yourusername
[push]
default = simple
Now you can install the repo command and pull the voltha repo.
voltha> sudo apt-get install repo
voltha> mkdir cord
voltha> cd cord
voltha> repo init -u https://gerrit.opencord.org/manifest -g voltha
voltha> repo sync
First create the voltah VM using vagrant.
voltha> cd ~/cord/incubator/voltha
voltha> vagrant up
Finally, log into the vm using vagrant.
voltha> vagrant ssh
That's it! Enjoy voltha running in QEMU/KVM virtual machines.