Add Devstack integration
Change-Id: I74f807e52fe1a7dd1521c3d1551b4fe0b17db4a3
This commit is contained in:
parent
1f2ccd8882
commit
5ff7a90c79
89
Vagrantfile
vendored
89
Vagrantfile
vendored
@ -1,89 +0,0 @@
|
||||
# -*- mode: ruby -*-
|
||||
# # vi: set ft=ruby :
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
Vagrant.require_version ">= 1.6.0"
|
||||
|
||||
CONFIG = File.join(File.dirname(__FILE__), "vagrant_config.rb")
|
||||
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
# Devstack init script
|
||||
$devstack_init = <<SCRIPT
|
||||
#!/bin/bash
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get -qqy update || sudo yum update -qy
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -qqy git || sudo yum install -qy git
|
||||
pushd ~
|
||||
git clone https://git.openstack.org/openstack-dev/devstack
|
||||
pushd devstack
|
||||
echo '[[local|localrc]]' > local.conf
|
||||
echo ADMIN_PASSWORD=password >> local.conf
|
||||
echo MYSQL_PASSWORD=password >> local.conf
|
||||
echo RABBIT_PASSWORD=password >> local.conf
|
||||
echo SERVICE_PASSWORD=password >> local.conf
|
||||
echo SERVICE_TOKEN=tokentoken >> local.conf
|
||||
./stack.sh
|
||||
SCRIPT
|
||||
|
||||
# Defaults for config options
|
||||
$hostname = File.basename(File.dirname(__FILE__))
|
||||
$forwarded_port = 8795
|
||||
$install_devstack = false
|
||||
$install_build_deps = true
|
||||
$install_tmate = false
|
||||
$vm_memory = 2048
|
||||
$vm_cpus = 2
|
||||
|
||||
if File.exist?(CONFIG)
|
||||
require CONFIG
|
||||
end
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
config.vm.hostname = "cuedev"
|
||||
config.vm.network "forwarded_port", guest: $forwarded_port, host: $forwarded_port
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.memory = $vm_memory
|
||||
v.cpus = $vm_cpus
|
||||
end
|
||||
|
||||
config.vm.provider "vmware_fusion" do |v, override|
|
||||
v.vmx["memsize"] = $vm_memory
|
||||
v.vmx["numvcpus"] = $vm_cpus
|
||||
override.vm.box = "puphpet/ubuntu1404-x64"
|
||||
end
|
||||
|
||||
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
|
||||
|
||||
# Update package list first and ensure package/repository management tools are present
|
||||
config.vm.provision "shell", inline: "sudo apt-get update"
|
||||
config.vm.provision "shell", inline: "sudo apt-get install -y python-software-properties software-properties-common"
|
||||
|
||||
# Install tmate [optional]
|
||||
if $install_tmate
|
||||
config.vm.provision "shell", inline: "sudo add-apt-repository ppa:nviennot/tmate"
|
||||
config.vm.provision "shell", inline: "sudo apt-get update"
|
||||
config.vm.provision "shell", inline: "sudo apt-get install -y tmate"
|
||||
end
|
||||
|
||||
# Install dependencies
|
||||
if $install_build_deps
|
||||
config.vm.provision "shell", inline: "apt-get install -y build-essential git libmysqlclient-dev python-tox python-dev libxml2-dev libxslt1-dev libffi-dev libssl-dev gettext"
|
||||
end
|
||||
|
||||
# Remove anything unnecessary
|
||||
config.vm.provision "shell", inline: "apt-get autoremove -y"
|
||||
|
||||
# Install devstack
|
||||
if $install_devstack
|
||||
config.vm.provision "shell", inline: $devstack_init, privileged: false
|
||||
end
|
||||
|
||||
# Initialize project and environment
|
||||
config.vm.provision "shell", inline: "pushd /vagrant && tox ; true"
|
||||
config.vm.provision "shell", inline: "source /vagrant/.tox/py27/bin/activate ; pushd /vagrant && python setup.py develop"
|
||||
#config.vm.provision "shell", inline: "echo 'source /vagrant/.tox/py27/bin/activate' >> ~root/.profile"
|
||||
|
||||
end
|
17
contrib/devstack/README.rst
Normal file
17
contrib/devstack/README.rst
Normal file
@ -0,0 +1,17 @@
|
||||
The contrib/devstack directory contrains the files to integrate Cue with Devstack.
|
||||
|
||||
To install Cue
|
||||
|
||||
# Clone devstack and cue
|
||||
git clone https://github.com/openstack-dev/devstack.git
|
||||
git clone https://github.com/stackforge/cue.git
|
||||
|
||||
# Install the cue plugins onto Devstack
|
||||
./cue/contrib/devstack/install.sh
|
||||
|
||||
# Copy the local.conf to your devstack
|
||||
cp cue/contrib/devstack/local.conf devstack/
|
||||
|
||||
This will create the neccessary symlinks to the Cue-devstack-plugin, and setup
|
||||
devstack with a local.conf that enables the Cue services and its dependencies.
|
||||
|
33
contrib/devstack/extras.d/60-zookeeper.sh
Normal file
33
contrib/devstack/extras.d/60-zookeeper.sh
Normal file
@ -0,0 +1,33 @@
|
||||
# check for service enabled
|
||||
if is_service_enabled zookeeper; then
|
||||
|
||||
if [[ "$1" == "source" ]]; then
|
||||
# Initial source of lib script
|
||||
source $TOP_DIR/lib/zookeeper
|
||||
fi
|
||||
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
echo_summary "Installing Zookeeper"
|
||||
install_zookeeper
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
echo_summary "Configuring Zookeeper"
|
||||
configure_zookeeper
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
echo_summary "Initializing Zookeeper"
|
||||
init_zookeeper
|
||||
|
||||
echo_summary "Starting Zookeeper"
|
||||
start_zookeeper
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
stop_zookeeper
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
echo_summary "Cleaning Zookeeper"
|
||||
cleanup_zookeeper
|
||||
fi
|
||||
fi
|
44
contrib/devstack/extras.d/70-cue.sh
Normal file
44
contrib/devstack/extras.d/70-cue.sh
Normal file
@ -0,0 +1,44 @@
|
||||
# check for service enabled
|
||||
if is_service_enabled cue; then
|
||||
|
||||
if [[ "$1" == "source" ]]; then
|
||||
# Initial source of lib script
|
||||
source $TOP_DIR/lib/cue
|
||||
fi
|
||||
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
echo_summary "Installing Cue"
|
||||
install_cue
|
||||
|
||||
echo_summary "Installing Cue Client"
|
||||
install_cueclient
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
echo_summary "Configuring Cue"
|
||||
configure_cue
|
||||
|
||||
if is_service_enabled key; then
|
||||
echo_summary "Creating Cue Keystone Accounts"
|
||||
create_cue_accounts
|
||||
fi
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
echo_summary "Initializing Cue"
|
||||
init_cue
|
||||
|
||||
echo_summary "Starting Cue"
|
||||
start_cue
|
||||
|
||||
echo_summary "Creating Initial Cue Resources"
|
||||
create_cue_initial_resources
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
stop_cue
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
echo_summary "Cleaning Cue"
|
||||
cleanup_cue
|
||||
fi
|
||||
fi
|
14
contrib/devstack/install.sh
Executable file
14
contrib/devstack/install.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR=$(readlink -e $(dirname $(readlink -f $0)))
|
||||
|
||||
pushd $DIR
|
||||
|
||||
for f in lib/* extras.d/*; do
|
||||
if [ ! -e "$DIR/../../../devstack/$f" ]; then
|
||||
echo "Installing symlink for $f"
|
||||
ln -fs $DIR/$f $DIR/../../../devstack/$f
|
||||
fi
|
||||
done
|
||||
|
||||
popd
|
195
contrib/devstack/lib/cue
Normal file
195
contrib/devstack/lib/cue
Normal file
@ -0,0 +1,195 @@
|
||||
# lib/cue
|
||||
# Install and start **Cue** service
|
||||
|
||||
# To enable Cue services, add the following to localrc
|
||||
# enable_service cue,cue-api,cue-worker
|
||||
|
||||
# stack.sh
|
||||
# ---------
|
||||
# install_cue
|
||||
# configure_cue
|
||||
# init_cue
|
||||
# start_cue
|
||||
# stop_cue
|
||||
# cleanup_cue
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
|
||||
# Defaults
|
||||
# --------
|
||||
CUE_PLUGINS=$TOP_DIR/lib/cue_plugins
|
||||
|
||||
# Set up default repos
|
||||
CUE_REPO=${CUE_REPO:-${GIT_BASE}/stackforge/cue.git}
|
||||
CUE_BRANCH=${CUE_BRANCH:-master}
|
||||
CUECLIENT_REPO=${CUECLIENT_REPO:-${GIT_BASE}/stackforge/python-cueclient.git}
|
||||
CUECLIENT_BRANCH=${CUECLIENT_BRANCH:-master}
|
||||
|
||||
# Set up default paths
|
||||
CUE_BIN_DIR=$(get_python_exec_prefix)
|
||||
CUE_DIR=$DEST/cue
|
||||
CUECLIENT_DIR=$DEST/python-cueclient
|
||||
CUE_CONF_DIR=/etc/cue
|
||||
CUE_STATE_PATH=${CUE_STATE_PATH:=$DATA_DIR/cue}
|
||||
CUE_CONF=$CUE_CONF_DIR/cue.conf
|
||||
CUE_LOG_DIR=/var/log/cue
|
||||
CUE_AUTH_CACHE_DIR=${CUE_AUTH_CACHE_DIR:-/var/cache/cue}
|
||||
|
||||
CUE_TF_DB=${CUE_TF_DB:-cue_taskflow}
|
||||
CUE_TF_PERSISTENCE=${CUE_TF_PERSISTENCE:-}
|
||||
|
||||
# Public IP/Port Settings
|
||||
CUE_SERVICE_PROTOCOL=${CUE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
|
||||
CUE_SERVICE_HOST=${CUE_SERVICE_HOST:-$SERVICE_HOST}
|
||||
CUE_SERVICE_PORT=${CUE_SERVICE_PORT:-8795}
|
||||
|
||||
# cleanup_cue - Remove residual data files, anything left over from previous
|
||||
# runs that a clean run would need to clean up
|
||||
function cleanup_cue {
|
||||
sudo rm -rf $CUE_STATE_PATH $CUE_AUTH_CACHE_DIR
|
||||
}
|
||||
|
||||
# configure_cue - Set config files, create data dirs, etc
|
||||
function configure_cue {
|
||||
[ ! -d $CUE_CONF_DIR ] && sudo mkdir -m 755 -p $CUE_CONF_DIR
|
||||
sudo chown $STACK_USER $CUE_CONF_DIR
|
||||
|
||||
[ ! -d $CUE_LOG_DIR ] && sudo mkdir -m 755 -p $CUE_LOG_DIR
|
||||
sudo chown $STACK_USER $CUE_LOG_DIR
|
||||
|
||||
# (Re)create ``cue.conf``
|
||||
rm -f $CUE_CONF
|
||||
|
||||
iniset_rpc_backend cue $CUE_CONF DEFAULT
|
||||
iniset $CUE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
||||
iniset $CUE_CONF DEFAULT verbose True
|
||||
iniset $CUE_CONF DEFAULT state_path $CUE_STATE_PATH
|
||||
iniset $CUE_CONF database connection `database_connection_url cue`
|
||||
|
||||
# Support db as a persistence backend
|
||||
if [ "$CUE_TF_PERSISTENCE" == "db" ]; then
|
||||
iniset $CUE_CONF taskflow persistence_connection `database_connection_url $CUE_TF_DB`
|
||||
fi
|
||||
|
||||
if [ "$SYSLOG" != "False" ]; then
|
||||
iniset $CUE_CONF DEFAULT use_syslog True
|
||||
fi
|
||||
|
||||
# Format logging
|
||||
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
|
||||
setup_colorized_logging $CUE_CONF DEFAULT "tenant" "user"
|
||||
fi
|
||||
|
||||
if is_service_enabled key; then
|
||||
# Setup the Keystone Integration
|
||||
iniset $CUE_CONF service:api auth_strategy keystone
|
||||
configure_auth_token_middleware $CUE_CONF cue $CUE_AUTH_CACHE_DIR
|
||||
fi
|
||||
|
||||
iniset $CUE_CONF service:api api_host $CUE_SERVICE_HOST
|
||||
iniset $CUE_CONF service:api api_base_uri $CUE_SERVICE_PROTOCOL://$CUE_SERVICE_HOST:$CUE_SERVICE_PORT/
|
||||
if is_service_enabled tls-proxy; then
|
||||
# Set the service port for a proxy to take the original
|
||||
iniset $CUE_CONF service:api api_port $CUE_SERVICE_PORT_INT
|
||||
else
|
||||
iniset $CUE_CONF service:api api_port $CUE_SERVICE_PORT
|
||||
fi
|
||||
|
||||
# Install the policy file for the API server
|
||||
cp $CUE_DIR/etc/cue/policy.json $CUE_CONF_DIR/policy.json
|
||||
iniset $CUE_CONF DEFAULT policy_file $CUE_CONF_DIR/policy.json
|
||||
}
|
||||
|
||||
# create_cue_accounts - Set up common required cue accounts
|
||||
|
||||
# Tenant User Roles
|
||||
# ------------------------------------------------------------------
|
||||
# service cue admin # if enabled
|
||||
function create_cue_accounts {
|
||||
local service_tenant=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
|
||||
local admin_role=$(openstack role list | awk "/ admin / { print \$2 }")
|
||||
|
||||
if [[ "$ENABLED_SERVICES" =~ "cue-api" ]]; then
|
||||
local cue_user=$(get_or_create_user "cue" \
|
||||
"$SERVICE_PASSWORD" $service_tenant)
|
||||
get_or_add_user_project_role $admin_role $cue_user $service_tenant
|
||||
|
||||
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
||||
local cue_service=$(get_or_create_service "cue" \
|
||||
"message_queue" "Cue MQ Provisioning Service")
|
||||
get_or_create_endpoint $cue_service \
|
||||
"$REGION_NAME" \
|
||||
"$CUE_SERVICE_PROTOCOL://$CUE_SERVICE_HOST:$CUE_SERVICE_PORT/" \
|
||||
"$CUE_SERVICE_PROTOCOL://$CUE_SERVICE_HOST:$CUE_SERVICE_PORT/" \
|
||||
"$CUE_SERVICE_PROTOCOL://$CUE_SERVICE_HOST:$CUE_SERVICE_PORT/"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function create_cue_initial_resources {
|
||||
#ADMIN_TENANT_ID=$(keystone tenant-list | grep " admin " | get_field 1)
|
||||
echo "Creating initial resources."
|
||||
}
|
||||
|
||||
# init_cue - Initialize etc.
|
||||
function init_cue {
|
||||
# Create cache dir
|
||||
sudo mkdir -p $CUE_AUTH_CACHE_DIR
|
||||
sudo chown $STACK_USER $CUE_AUTH_CACHE_DIR
|
||||
rm -f $CUE_AUTH_CACHE_DIR/*
|
||||
|
||||
# (Re)create cue database
|
||||
recreate_database cue utf8
|
||||
|
||||
# Init and migrate cue database
|
||||
cue-manage --config-file $CUE_CONF database upgrade
|
||||
|
||||
# Init and migrate cue pool-manager-cache
|
||||
if [ "$CUE_TF_PERSISTENCE" == "db" ]; then
|
||||
recreate_database $CUE_TF_DB utf8
|
||||
cue-manage --config-file $CUE_CONF taskflow upgrade
|
||||
fi
|
||||
}
|
||||
|
||||
# install_cue - Collect source and prepare
|
||||
function install_cue {
|
||||
git_clone $CUE_REPO $CUE_DIR $CUE_BRANCH
|
||||
setup_develop $CUE_DIR
|
||||
|
||||
if is_service_enabled horizon; then
|
||||
echo "Not implemented yet..."
|
||||
fi
|
||||
}
|
||||
|
||||
# install_cueclient - Collect source and prepare
|
||||
function install_cueclient {
|
||||
git_clone $CUECLIENT_REPO $CUECLIENT_DIR $CUECLIENT_BRANCH
|
||||
setup_develop $CUECLIENT_DIR
|
||||
}
|
||||
|
||||
# start_cue - Start running processes, including screen
|
||||
function start_cue {
|
||||
run_process cue-api "$CUE_BIN_DIR/cue-api --config-file $CUE_CONF"
|
||||
run_process cue-worker "$CUE_BIN_DIR/cue-worker --config-file $CUE_CONF"
|
||||
|
||||
# Start proxies if enabled
|
||||
if is_service_enabled cue-api && is_service_enabled tls-proxy; then
|
||||
start_tls_proxy '*' $CUE_SERVICE_PORT $CUE_SERVICE_HOST $CUE_SERVICE_PORT_INT &
|
||||
fi
|
||||
|
||||
if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- $CUE_SERVICE_PROTOCOL://$CUE_SERVICE_HOST:$CUE_SERVICE_PORT; do sleep 1; done"; then
|
||||
die $LINENO "Cue did not start"
|
||||
fi
|
||||
}
|
||||
|
||||
# stop_cue - Stop running processes
|
||||
function stop_cue {
|
||||
# Kill the cue screen windows
|
||||
stop_process cue-api
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
51
contrib/devstack/lib/zookeeper
Normal file
51
contrib/devstack/lib/zookeeper
Normal file
@ -0,0 +1,51 @@
|
||||
# lib/zookeeper
|
||||
# Install and start zookeeper
|
||||
|
||||
# To enable zk add the following to your localrc
|
||||
# enable_service zookeeper
|
||||
|
||||
# stack.sh
|
||||
# ----------
|
||||
# install_zookeeper
|
||||
# configure_zookeeper
|
||||
# init_zookeeper
|
||||
# start_zookeeper
|
||||
# stop_zookeeper
|
||||
# cleanup_zookeeper
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
function cleanup_zookeeper {
|
||||
echo "Cleanup zookeeper"
|
||||
}
|
||||
|
||||
function configure_zookeeper {
|
||||
echo "Configure zookeeper"
|
||||
}
|
||||
|
||||
function install_zookeeper {
|
||||
echo "Installing zookeeper"
|
||||
if is_fedora; then
|
||||
install_package zookeeper
|
||||
elif is_ubuntu; then
|
||||
install_package zookeeper zookeeper-bin zookeeperd
|
||||
else
|
||||
exit_distro_not_supported "zookeeper installation"
|
||||
fi
|
||||
|
||||
sudo pip install -e "git+https://github.com/python-zk/kazoo.git#egg=kazoo"
|
||||
}
|
||||
|
||||
function init_zookeeper {
|
||||
echo "Init zookeeper"
|
||||
}
|
||||
|
||||
function start_zookeeper {
|
||||
echo "Starting zookeeper"
|
||||
}
|
||||
|
||||
function stop_zookeeper {
|
||||
echo "Stopping zookeeper"
|
||||
}
|
60
contrib/devstack/local.conf
Normal file
60
contrib/devstack/local.conf
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# Default ${DEVSTACK_DIR}/local.conf file for Cue
|
||||
#
|
||||
|
||||
[[local|localrc]]
|
||||
|
||||
# Default passwords
|
||||
ADMIN_PASSWORD=password
|
||||
MYSQL_PASSWORD=password
|
||||
RABBIT_PASSWORD=password
|
||||
SERVICE_PASSWORD=password
|
||||
SERVICE_TOKEN=password
|
||||
|
||||
# Enable Logging
|
||||
LOGFILE=/opt/stack/logs/stack.sh.log
|
||||
VERBOSE=True
|
||||
LOG_COLOR=True
|
||||
SCREEN_LOGDIR=/opt/stack/logs
|
||||
|
||||
# Disable global requirements checks
|
||||
REQUIREMENTS_MODE=soft
|
||||
|
||||
# Enable novnc
|
||||
enable_service n-novnc
|
||||
|
||||
#
|
||||
# Enable Neutron
|
||||
# https://wiki.openstack.org/wiki/NeutronDevstack
|
||||
#
|
||||
disable_service n-net
|
||||
enable_service q-svc
|
||||
enable_service q-agt
|
||||
enable_service q-dhcp
|
||||
enable_service q-l3
|
||||
enable_service q-meta
|
||||
enable_service neutron
|
||||
|
||||
# Neutron Configuration
|
||||
FLOATING_RANGE=192.168.15.0/27
|
||||
FLAT_INTERFACE=eth0
|
||||
Q_FLOATING_ALLOCATION_POOL=start=192.168.15.10,end=192.168.15.30
|
||||
PUBLIC_NETWORK_GATEWAY=192.168.15.1
|
||||
|
||||
# Enable Swift
|
||||
enable_service s-proxy
|
||||
enable_service s-object
|
||||
enable_service s-container
|
||||
enable_service s-account
|
||||
|
||||
# Swift Configuration
|
||||
SWIFT_HASH=12go358snjw24501
|
||||
|
||||
# Enable Zookeeper
|
||||
enable_service zookeeper
|
||||
|
||||
# Enable Cue
|
||||
enable_service cue
|
||||
enable_service cue-api
|
||||
enable_service cue-worker
|
||||
|
83
contrib/vagrant/Vagrantfile
vendored
Normal file
83
contrib/vagrant/Vagrantfile
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
# -*- mode: ruby -*-
|
||||
# # vi: set ft=ruby :
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
Vagrant.require_version ">= 1.6.0"
|
||||
|
||||
CONFIG = File.join(File.dirname(__FILE__), "vagrant_config.rb")
|
||||
UBUNTU_COMMON = File.join(File.dirname(__FILE__), "lib/ubuntu.rb")
|
||||
FEDORA_COMMON = File.join(File.dirname(__FILE__), "lib/fedora.rb")
|
||||
DEVSTACK_SCRIPT = File.join(File.dirname(__FILE__), "lib/devstack_script.rb")
|
||||
|
||||
GITCONFIG = `cat $HOME/.gitconfig`
|
||||
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
# Defaults for config options
|
||||
$hostname = File.basename(File.dirname(__FILE__))
|
||||
$forwarded_port = {}
|
||||
$install_devstack = false
|
||||
$install_build_deps = true
|
||||
$install_tmate = false
|
||||
$ubuntu_box = "sputnik13/trusty64"
|
||||
$vm_memory = 4096
|
||||
$vm_cpus = 2
|
||||
|
||||
if File.exist?(CONFIG)
|
||||
require CONFIG
|
||||
end
|
||||
|
||||
require UBUNTU_COMMON
|
||||
require FEDORA_COMMON
|
||||
require DEVSTACK_SCRIPT
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
$forwarded_port.each do |guest_port, host_port|
|
||||
config.vm.network "forwarded_port", guest: guest_port, host: host_port
|
||||
end
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.memory = $vm_memory
|
||||
v.cpus = $vm_cpus
|
||||
end
|
||||
|
||||
config.vm.provider "vmware_fusion" do |v, override|
|
||||
v.vmx["memsize"] = $vm_memory
|
||||
v.vmx["numvcpus"] = $vm_cpus
|
||||
v.vmx["vhv.enable"] = TRUE
|
||||
v.vmx["ethernet0.virtualdev"] = "vmxnet3"
|
||||
end
|
||||
|
||||
config.vm.synced_folder "../..", "/home/vagrant/cue"
|
||||
|
||||
if File.directory?("../../../python-cueclient")
|
||||
config.vm.synced_folder "../../../python-cueclient", "/opt/stack/python-cueclient"
|
||||
end
|
||||
|
||||
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
|
||||
|
||||
config.vm.define "ubuntu" do |ubuntu|
|
||||
ubuntu.vm.hostname = "cuedev-ubuntu"
|
||||
ubuntu_common(ubuntu)
|
||||
end
|
||||
|
||||
config.vm.define "fedora" do |fedora|
|
||||
fedora.vm.hostname = "cuedev-fedora"
|
||||
fedora_common(fedora)
|
||||
end
|
||||
|
||||
# Common provisioning steps
|
||||
config.vm.provision :shell, :privileged => true,
|
||||
:inline => "test -d /opt/stack || mkdir -p /opt/stack"
|
||||
config.vm.provision :shell, :privileged => true,
|
||||
:inline => "chown vagrant /opt/stack"
|
||||
config.vm.provision :shell, :privileged => false,
|
||||
:inline => $devstack_script
|
||||
|
||||
if $install_devstack
|
||||
config.vm.provision :shell, :privileged => false,
|
||||
:inline => "pushd $HOME/devstack; ./stack.sh"
|
||||
end
|
||||
|
||||
end
|
35
contrib/vagrant/lib/devstack_script.rb
Normal file
35
contrib/vagrant/lib/devstack_script.rb
Normal file
@ -0,0 +1,35 @@
|
||||
# Devstack init script
|
||||
$devstack_script = <<SCRIPT
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get -qqy update || sudo yum update -qy
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -qqy git || sudo yum install -qy git
|
||||
pushd ~
|
||||
|
||||
# Copy over git config
|
||||
cat << EOF > /home/vagrant/.gitconfig
|
||||
#{GITCONFIG}
|
||||
EOF
|
||||
|
||||
test -d devstack || git clone https://git.openstack.org/openstack-dev/devstack
|
||||
|
||||
rsync -av --exclude='.tox' --exclude='.venv' --exclude='.vagrant' --exclude='contrib/vagrant' /home/vagrant/cue /opt/stack
|
||||
|
||||
if [ -f "/home/vagrant/python-cueclient" ]; then
|
||||
rsync -av --exclude='.tox' --exclude='.venv' --exclude='.vagrant' --exclude='contrib/vagrant' /home/vagrant/python-cueclient /opt/stack
|
||||
fi
|
||||
|
||||
# Install Vagrant local.conf sample
|
||||
if [ ! -f "/home/vagrant/devstack/local.conf" ]; then
|
||||
cp /opt/stack/cue/contrib/devstack/local.conf /home/vagrant/devstack/local.conf
|
||||
fi
|
||||
|
||||
for f in extras.d/* lib/*; do
|
||||
if [ ! -f "/home/vagrant/devstack/$f" ]; then
|
||||
ln -fs /opt/stack/cue/contrib/devstack/$f -t /home/vagrant/devstack/$(dirname $f)
|
||||
fi
|
||||
done
|
||||
|
||||
SCRIPT
|
||||
|
7
contrib/vagrant/lib/fedora.rb
Normal file
7
contrib/vagrant/lib/fedora.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# Common provisioning steps for Fedora VMs
|
||||
def fedora_common(machine)
|
||||
machine.vm.box = $fedora_box
|
||||
|
||||
machine.vm.provision :shell, :privileged => true, :inline => "yum update -y vim-minimal" # RH Bug 1066983
|
||||
machine.vm.provision :shell, :privileged => true, :inline => "yum install -y git-core MySQL-python"
|
||||
end
|
31
contrib/vagrant/lib/ubuntu.rb
Normal file
31
contrib/vagrant/lib/ubuntu.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# Common provisioning steps for Ubuntu VMs
|
||||
def ubuntu_common(machine)
|
||||
machine.vm.box = $ubuntu_box
|
||||
|
||||
machine.vm.provision :shell, :privileged => true,
|
||||
:inline => "DEBIAN_FRONTEND=noninteractive apt-get update"
|
||||
machine.vm.provision :shell, :privileged => true,
|
||||
:inline => "DEBIAN_FRONTEND=noninteractive apt-get install --yes git"
|
||||
machine.vm.provision :shell, :privileged => true,
|
||||
:inline => "DEBIAN_FRONTEND=noninteractive apt-get install --yes python-software-properties software-properties-common squid-deb-proxy-client"
|
||||
|
||||
if $package_proxy
|
||||
machine.vm.provision :shell, :privileged => true,
|
||||
:inline => "echo \"Acquire { Retries \\\"0\\\"; HTTP { Proxy \\\"#{$package_proxy}\\\"; }; };\" > /etc/apt/apt.conf.d/99proxy"
|
||||
end
|
||||
|
||||
# Install build dependencies
|
||||
if $install_build_deps
|
||||
machine.vm.provision "shell", inline: "apt-get install -y build-essential git libmysqlclient-dev python-tox python-dev libxml2-dev libxslt1-dev libffi-dev libssl-dev gettext"
|
||||
end
|
||||
|
||||
# Install tmate [optional]
|
||||
if $install_tmate
|
||||
machine.vm.provision "shell", :inline => "sudo add-apt-repository ppa:nviennot/tmate"
|
||||
machine.vm.provision "shell", :inline => "sudo apt-get update"
|
||||
machine.vm.provision "shell", :inline => "sudo apt-get install -y tmate"
|
||||
end
|
||||
|
||||
# Remove anything unnecessary
|
||||
machine.vm.provision "shell", inline: "apt-get autoremove -y"
|
||||
end
|
@ -4,8 +4,21 @@
|
||||
# Uncomment $hostname and set it to specify an explicit hostname for the VM
|
||||
# $hostname = "dev"
|
||||
|
||||
# Setup a host to guest port mapping for the following port
|
||||
$forwarded_port = 8795
|
||||
# Setup a guest port => host port mapping for the mappings provided below
|
||||
#$forwarded_port = {
|
||||
# 8795 => 8795,
|
||||
# 6080 => 6080,
|
||||
# 80 => 8080
|
||||
#}
|
||||
|
||||
# Ubuntu box
|
||||
$ubuntu_box = "sputnik13/trusty64"
|
||||
|
||||
# Fedora box
|
||||
$fedora_box = "box-cutter/fedora20"
|
||||
|
||||
# Specify a proxy to be used for packages
|
||||
$package_proxy = nil
|
||||
|
||||
# Install devstack in the VM
|
||||
$install_devstack = false
|
||||
@ -17,7 +30,7 @@ $install_build_deps = true
|
||||
$install_tmate = false
|
||||
|
||||
# Set the amount of RAM configured for the VM
|
||||
$vm_memory = 2048
|
||||
$vm_memory = 4096
|
||||
|
||||
# Set the number of CPU cores configured for the VM
|
||||
$vm_cpus = 2
|
Loading…
Reference in New Issue
Block a user