From 3bcbd1ec26dbeab0190d8784f7cf49c4c0f4d401 Mon Sep 17 00:00:00 2001 From: "Vigneshvar.A.S" Date: Wed, 28 Jan 2015 13:20:17 +0530 Subject: [PATCH] Add LBaaS in the lab scripts This patch adds support to enable neutron LBaaS support in the training guide's OpenStack installation. Changes made are as follows * Pre-download neutron-lbaas-agent to base disk * Enable LBaaS support on horizon on controller node * Configure neutron server to support LBaaS with haproxy as provider on controller node * Enable and configure LBaaS agent on network node Change-Id: I35f8c19ebceb7420f735354337bf71b4d92edf93 Closes-Bug: 1414767 --- labs/config/scripts.controller | 2 + labs/config/scripts.network | 2 + labs/scripts/apt_pre-download.sh | 2 +- labs/scripts/setup_lbaas_controller.sh | 41 ++++++++++++++++++ labs/scripts/setup_lbaas_network.sh | 57 ++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 labs/scripts/setup_lbaas_controller.sh create mode 100644 labs/scripts/setup_lbaas_network.sh diff --git a/labs/config/scripts.controller b/labs/config/scripts.controller index 4919492c..889225bf 100644 --- a/labs/config/scripts.controller +++ b/labs/config/scripts.controller @@ -20,5 +20,7 @@ cmd queue setup_horizon.sh cmd snapshot_cycle horizon_installed cmd queue config_external_network.sh cmd queue config_tenant_network.sh +cmd snapshot_cycle openstack_networks_configured +cmd queue setup_lbaas_controller.sh cmd snapshot_cycle controller_node_installed cmd boot diff --git a/labs/config/scripts.network b/labs/config/scripts.network index e4c73ce4..be5c7789 100644 --- a/labs/config/scripts.network +++ b/labs/config/scripts.network @@ -4,6 +4,8 @@ cmd queue etc_hosts.sh cmd queue osbash/enable_vagrant_ssh_keys.sh cmd snapshot_cycle network_configured cmd queue setup_neutron_network.sh +cmd snapshot_cycle neutron_configured +cmd queue setup_lbaas_network.sh cmd snapshot_cycle network_node_installed # Take snapshot of changes on controller VM, too cmd queue shutdown_controller.sh diff --git a/labs/scripts/apt_pre-download.sh b/labs/scripts/apt_pre-download.sh index 66be02bf..9d6361b8 100755 --- a/labs/scripts/apt_pre-download.sh +++ b/labs/scripts/apt_pre-download.sh @@ -61,7 +61,7 @@ apt_download nova-api nova-cert nova-conductor nova-consoleauth \ nova-novncproxy nova-scheduler python-novaclient # Neutron Controller -apt_download neutron-server neutron-plugin-ml2 +apt_download neutron-server neutron-plugin-ml2 neutron-lbaas-agent # Cinder Controller apt_download cinder-api cinder-scheduler diff --git a/labs/scripts/setup_lbaas_controller.sh b/labs/scripts/setup_lbaas_controller.sh new file mode 100644 index 00000000..d5eb61bd --- /dev/null +++ b/labs/scripts/setup_lbaas_controller.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -o errexit -o nounset +TOP_DIR=$(cd $(dirname "$0")/.. && pwd) +source "$TOP_DIR/config/paths" +source "$CONFIG_DIR/credentials" +source "$LIB_DIR/functions.guest" +source "$CONFIG_DIR/admin-openstackrc.sh" +exec_logfile + +indicate_current_auto + +#------------------------------------------------------------------------------ +# Set up OpenStack neutron LBaaS for controller node. +# http://docs.openstack.org/admin-guide-cloud/content/install_neutron-lbaas-agent.html +#------------------------------------------------------------------------------ + +echo "Configuring neutron lbaas for controller node." +conf=/etc/neutron/neutron.conf + +# Configure network plugin parameters +iniset_sudo $conf DEFAULT service_plugins "router,lbaas" + +echo "Restarting neutron service." +sudo service neutron-server restart + +# Configure openstack dashboard +function check_dashboard_settings { + local memcached_conf=/etc/memcached.conf + local dashboard_conf=/etc/openstack-dashboard/local_settings.py + + # Enabling Neutron LBaaS on Horizon + echo "Enabling neutron LBaaS on horizon." + sudo sed -i "s/'enable_lb': False/\'enable_lb\': True/" $dashboard_conf +} + +echo "Checking dashboard configuration." +check_dashboard_settings + +echo "Reloading apache and memcached service." +sudo service apache2 restart +sudo service memcached restart diff --git a/labs/scripts/setup_lbaas_network.sh b/labs/scripts/setup_lbaas_network.sh new file mode 100644 index 00000000..5d05a883 --- /dev/null +++ b/labs/scripts/setup_lbaas_network.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -o errexit -o nounset +TOP_DIR=$(cd $(dirname "$0")/.. && pwd) +source "$TOP_DIR/config/paths" +source "$CONFIG_DIR/credentials" +source "$LIB_DIR/functions.guest" +source "$CONFIG_DIR/openstack" +exec_logfile + +indicate_current_auto + +#------------------------------------------------------------------------------ +# Set up OpenStack neutron LBaaS for network node. +# http://docs.openstack.org/admin-guide-cloud/content/install_neutron-lbaas-agent.html +#------------------------------------------------------------------------------ + +echo "Installing neutron lbaas agent for network node." +sudo apt-get install -y neutron-lbaas-agent + +echo "Configuring LBaaS agent for network node." +conf=/etc/neutron/lbaas_agent.ini +iniset_sudo $conf DEFAULT device_driver neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver +iniset_sudo $conf DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver + +echo "Restarting the neutron lbaas agent service." +sudo service neutron-lbaas-agent restart + +#------------------------------------------------------------------------------ +# Verify the neutron LBaaS installation +#------------------------------------------------------------------------------ + +echo "Verifying neutron lbaas installation." + +echo "Waiting for neutron-lbaas-agent to start." +AUTH="source $CONFIG_DIR/demo-openstackrc.sh" +until node_ssh controller-mgmt "$AUTH; neutron lb-pool-list" >/dev/null 2>&1; do + sleep 1 +done + +LB_NUMBER=$(date +"%d%m%y%H%M%S") +echo "neutron lb-pool-create --lb-method ROUND_ROBIN --name test-lb$LB_NUMBER --protocol HTTP --subnet-id demo-subnet" +node_ssh controller-mgmt "$AUTH; neutron lb-pool-create --lb-method ROUND_ROBIN --name test-lb$LB_NUMBER --protocol HTTP --subnet-id demo-subnet" + +echo "Checking if created pool is active." +until node_ssh controller-mgmt "$AUTH; neutron lb-pool-list | grep test-lb$LB_NUMBER | grep -i ACTIVE" > /dev/null 2>&1; do + sleep 1 +done +echo "Success." + +echo "neutron lb-pool-list" +node_ssh controller-mgmt "$AUTH; neutron lb-pool-list" + +echo "neutron lb-pool-delete test-lb$LB_NUMBER" +node_ssh controller-mgmt "$AUTH; neutron lb-pool-delete test-lb$LB_NUMBER" + +echo "neutron lb-pool-list" +node_ssh controller-mgmt "$AUTH; neutron lb-pool-list"