scripts/vagrant: Add possibility to create vm image with devstack

Change-Id: I880dbe9d29ec4822193e6f570107f7fc12e56e3d
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456325
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Pawel Kaminski 2019-05-30 12:23:19 +02:00 committed by Jim Harris
parent b7408943d1
commit aec3021924
3 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,82 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# See: https://app.vagrantup.com/bento/boxes/ubuntu-18.04
config.vm.box = "bento/ubuntu-18.04"
config.vm.box_check_update = false
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
end
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
# use http proxy if avaiable
if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = ENV['http_proxy']
config.proxy.https = ENV['http_proxy']
config.proxy.no_proxy = "localhost,127.0.0.1,10.0.2.15"
end
vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 10)
vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 8192)
spdk_dir=(ENV['SPDK_DIR'] || "none")
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
# Change root passwd and allow root SSH
config.vm.provision "shell", inline: 'echo -e "root\nroot" | sudo passwd root'
config.vm.provision "shell", inline: 'sudo sh -c "echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config"'
config.vm.provision "shell", inline: 'useradd -m -p sys_sgci -s /bin/bash sys_sgci'
config.vm.provision "shell", inline: 'usermod -aG sudo sys_sgci'
# Install needed deps
$apt_script = <<-SCRIPT
sudo apt -y update
sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
SCRIPT
config.vm.provision "shell", inline: $apt_script
# TODO: Next 2 lines break any future ssh communication via "vagrant ssh"
# I'd be good to check NIC names in ifconfig and then sed them in /etc/network/interfaces to eht0, eht1, and so on
config.vm.provision "shell", inline: 'sudo sh -c "echo \"auto eth0\" >> /etc/network/interfaces"'
config.vm.provision "shell", inline: 'sudo sh -c "echo \"iface eth0 inet dhcp\" >> /etc/network/interfaces"'
# This is to avoid annoying "Start job is running for wait for network to be configured" 2 minute timeout
# in case of not-so-perfect NIC and virtual network configuration for the VM
config.vm.provision "shell", inline: 'systemctl disable systemd-networkd-wait-online.service'
config.vm.provision "shell", inline: 'systemctl mask systemd-networkd-wait-online.service'
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.memory = "#{vmram}"
vb.cpus = "#{vmcpu}"
#support for the SSE4.x instruction is required in some versions of VB.
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
end
if spdk_dir != "none"
config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk", type: "rsync",
rsync__exclude: ["ubuntu18"]
end
# Install needed drivers and tools
config.vm.provision "shell", inline: 'sudo apt-get install -y libibverbs* librdmacm* libnuma-dev libaio-dev libcunit1-dev ibverbs-utils rdma-core'
# Copy in the user's tools if they exists
if File.directory?(File.expand_path("~/vagrant_tools"))
config.vm.synced_folder "~/vagrant_tools", "/home/vagrant/tools", type: "rsync", rsync__auto: false
end
config.vm.provision "shell", inline: 'sudo useradd -s /bin/bash -d /opt/stack -m stack | echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack'
config.vm.provision "shell", inline: 'sudo su - stack bash -c "git clone -b stable/stein https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack"'
config.vm.provision "file", source: "#{spdk_dir}/scripts/vagrant/local.conf", destination: "/home/vagrant/local.conf"
config.vm.provision "shell", inline: 'sudo su - stack bash -c "cp /home/vagrant/local.conf /opt/stack/devstack"'
config.vm.provision "shell", inline: 'sudo su - stack bash -c "cd /opt/stack/devstack; ./stack.sh"'
end

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e
testdir=$(readlink -f $(dirname $0))
SPDK_DIR=$(readlink -f $testdir/../..)
VAGRANT_TARGET="$PWD"
VAGRANT_DISTRO="ubuntu18"
export SPDK_DIR
export SPDK_VAGRANT_VMRAM=8192
export SPDK_VAGRANT_VMCPU=10
mkdir -vp "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
cp "${testdir}/Vagrantfile_openstack_vm" "${VAGRANT_TARGET}/${VAGRANT_DISTRO}/Vagrantfile"
pushd "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
if [ ! -z "${http_proxy}" ]; then
export http_proxy
fi
VBoxManage setproperty machinefolder "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
vagrant up
vagrant halt
VBoxManage setproperty machinefolder default
# Convert Vbox .vmdk image to qcow2
vmdk_img=$(find ${VAGRANT_TARGET}/${VAGRANT_DISTRO} -name "ubuntu-18.04-amd64-disk001.vmdk")
qemu-img convert -f vmdk -O qcow2 ${vmdk_img} ${VAGRANT_TARGET}/${VAGRANT_DISTRO}/openstack_vm_image.qcow2
echo ""
echo " SUCCESS!"
echo ""

View File

@ -0,0 +1,38 @@
[[local|localrc]]
enable_plugin heat https://git.openstack.org/openstack/heat stable/stein
enable_plugin tacker https://git.openstack.org/openstack/tacker stable/stein
ADMIN_PASSWORD=secret
DATABASE_PASSWORD=secret
RABBIT_PASSWORD=secret
SERVICE_PASSWORD=secret
HOST_IP=10.0.2.15
# These options define expected driver capabilities
TEMPEST_VOLUME_DRIVER=spdk
TEMPEST_VOLUME_VENDOR="Intel"
TEMPEST_STORAGE_PROTOCOL=nvmet_rdma
# Disable security groups entirely
Q_USE_SECGROUP=False
LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
CINDER_SECURE_DELETE=False
public_interface=eth0
[[post-config|$CINDER_CONF]]
[DEFAULT]
enabled_backends = spdk
target_helper = spdk-nvmeof
debug = True
[spdk]
spdk_rpc_ip = localhost
spdk_rpc_port = 3333
spdk_rpc_username = secret
spdk_rpc_password = secret
target_ip_address = 10.0.2.15
target_port = 4260
target_protocol = nvmet_rdma
target_helper = spdk-nvmeof
target_prefix = nqn.2014-08.org.spdk
volume_driver = cinder.volume.drivers.spdk.SPDKDriver
volume_backend_name = lvmdriver-1