Merge "Adds cinder scripts for training labs"
This commit is contained in:
commit
c53e15512c
@ -5,6 +5,8 @@ scripts setup_keystone.sh
|
||||
scripts setup_glance.sh
|
||||
scripts setup_nova_controller.sh
|
||||
scripts setup_neutron_controller.sh
|
||||
scripts setup_cinder_controller.sh
|
||||
scripts setup_cinder_volumes.sh
|
||||
scripts setup_horizon.sh
|
||||
scripts shutdown.sh
|
||||
boot
|
||||
|
89
labs/scripts/setup_cinder_controller.sh
Executable file
89
labs/scripts/setup_cinder_controller.sh
Executable file
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
||||
source "$TOP_DIR/config/paths"
|
||||
source "$CONFIG_DIR/credentials"
|
||||
source "$LIB_DIR/functions.guest"
|
||||
source "$CONFIG_DIR/labs-openstackrc.sh"
|
||||
exec_logfile
|
||||
|
||||
indicate_current_auto
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Set up Block Storage service controller (cinder controller node).
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
echo "Installing cinder."
|
||||
sudo apt-get install -y cinder-api cinder-scheduler
|
||||
|
||||
echo "Setting up database for cinder."
|
||||
setup_database cinder
|
||||
|
||||
function get_database_url {
|
||||
local db_user=$(service_to_db_user cinder)
|
||||
local db_password=$(service_to_db_password cinder)
|
||||
local database_host=controller-mgmt
|
||||
|
||||
echo "mysql://$db_user:$db_password@$database_host/cinder"
|
||||
}
|
||||
|
||||
database_url=$(get_database_url)
|
||||
|
||||
echo "Configuring cinder."
|
||||
|
||||
echo "Setting database connection: $database_url."
|
||||
iniset_sudo /etc/cinder/cinder.conf database connection "$database_url"
|
||||
|
||||
echo "Creating the database tables for cinder."
|
||||
sudo cinder-manage db sync
|
||||
|
||||
cinder_admin_user=$(service_to_user_name cinder)
|
||||
cinder_admin_password=$(service_to_user_password cinder)
|
||||
|
||||
echo "Creating cinder user and giving it admin role under service tenant."
|
||||
keystone user-create \
|
||||
--name "$cinder_admin_user" \
|
||||
--pass "$cinder_admin_password" \
|
||||
--email cinder@domain.com
|
||||
|
||||
keystone user-role-add \
|
||||
--user "$cinder_admin_user" \
|
||||
--tenant "$SERVICE_TENANT_NAME" \
|
||||
--role "$ADMIN_ROLE_NAME"
|
||||
|
||||
echo "Configuring cinder to use keystone for authentication."
|
||||
|
||||
echo "Configuring cinder-api.conf."
|
||||
conf=/etc/cinder/cinder.conf
|
||||
|
||||
# Configure [keystone_authtoken] section.
|
||||
iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000"
|
||||
iniset_sudo $conf keystone_authtoken auth_host controller-mgmt
|
||||
iniset_sudo $conf keystone_authtoken auth_port 35357
|
||||
iniset_sudo $conf keystone_authtoken auth_protocol http
|
||||
iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME"
|
||||
iniset_sudo $conf keystone_authtoken admin_user "$cinder_admin_user"
|
||||
iniset_sudo $conf keystone_authtoken admin_password "$cinder_admin_password"
|
||||
|
||||
# Configure [DEFAULT] section.
|
||||
iniset_sudo $conf DEFAULT rpc_backend cinder.openstack.common.rpc.impl_kombu
|
||||
iniset_sudo $conf DEFAULT rabbit_host controller-mgmt
|
||||
iniset_sudo $conf DEFAULT rabbit_port 5672
|
||||
iniset_sudo $conf DEFAULT rabbit_userid guest
|
||||
iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD"
|
||||
|
||||
echo "Registering cinder with keystone so that other services can locate it."
|
||||
keystone service-create \
|
||||
--name cinder \
|
||||
--type volume \
|
||||
--description "OpenStack Block Storage"
|
||||
|
||||
cinder_service_id=$(keystone service-list | awk '/ volume / {print $2}')
|
||||
keystone endpoint-create \
|
||||
--service-id "$cinder_service_id" \
|
||||
--publicurl "http://controller-api:8776/v1" \
|
||||
--adminurl "http://controller-mgmt:8776/v1" \
|
||||
--internalurl "http://controller-mgmt:8776/v1"
|
||||
|
||||
echo "Restarting cinder service."
|
||||
sudo service cinder-scheduler restart
|
||||
sudo service cinder-api restart
|
81
labs/scripts/setup_cinder_volumes.sh
Executable file
81
labs/scripts/setup_cinder_volumes.sh
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
||||
source "$TOP_DIR/config/paths"
|
||||
source "$CONFIG_DIR/credentials"
|
||||
source "$CONFIG_DIR/openstack"
|
||||
source "$LIB_DIR/functions.guest"
|
||||
source "$CONFIG_DIR/labs-openstackrc.sh"
|
||||
exec_logfile
|
||||
|
||||
indicate_current_auto
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Set up Block Storage service (cinder).
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
echo "Installing cinder."
|
||||
|
||||
sudo apt-get install -y lvm2
|
||||
|
||||
echo "Configuring LVM physical and logical volumes."
|
||||
cinder_loop_path=/var/lib/cinder-volumes
|
||||
cinder_loop_dev=/dev/loop2
|
||||
sudo dd if=/dev/zero of=$cinder_loop_path bs=1 count=0 seek=2G
|
||||
sudo losetup $cinder_loop_dev $cinder_loop_path
|
||||
sudo pvcreate $cinder_loop_dev
|
||||
sudo vgcreate cinder-volumes $cinder_loop_dev
|
||||
|
||||
# Tell upstart to run losetup again when the system is rebooted
|
||||
cat << UPSTART | sudo tee "/etc/init/cinder-losetup.conf"
|
||||
description "Set up loop device for cinder."
|
||||
|
||||
start on mounted MOUNTPOINT=/
|
||||
task
|
||||
exec /sbin/losetup $cinder_loop_dev $cinder_loop_path
|
||||
UPSTART
|
||||
|
||||
sudo apt-get install -y cinder-volume
|
||||
|
||||
function get_database_url {
|
||||
local db_user=$(service_to_db_user cinder)
|
||||
local db_password=$(service_to_db_password cinder)
|
||||
local database_host=controller-mgmt
|
||||
|
||||
echo "mysql://$db_user:$db_password@$database_host/cinder"
|
||||
}
|
||||
|
||||
database_url=$(get_database_url)
|
||||
|
||||
echo "Configuring cinder."
|
||||
|
||||
echo "Setting database connection: $database_url."
|
||||
iniset_sudo /etc/cinder/cinder.conf database connection "$database_url"
|
||||
|
||||
cinder_admin_user=$(service_to_user_name cinder)
|
||||
cinder_admin_password=$(service_to_user_password cinder)
|
||||
|
||||
echo "Configuring cinder to use keystone for authentication."
|
||||
|
||||
conf=/etc/cinder/cinder.conf
|
||||
echo "Configuring $conf."
|
||||
|
||||
# Configure [keystone_authtoken] section.
|
||||
iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000"
|
||||
iniset_sudo $conf keystone_authtoken auth_host controller-mgmt
|
||||
iniset_sudo $conf keystone_authtoken auth_port 35357
|
||||
iniset_sudo $conf keystone_authtoken auth_protocol http
|
||||
iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME"
|
||||
iniset_sudo $conf keystone_authtoken admin_user "$cinder_admin_user"
|
||||
iniset_sudo $conf keystone_authtoken admin_password "$cinder_admin_password"
|
||||
|
||||
# Configure [DEFAULT] section.
|
||||
iniset_sudo $conf DEFAULT rpc_backend cinder.openstack.common.rpc.impl_kombu
|
||||
iniset_sudo $conf DEFAULT rabbit_host controller-mgmt
|
||||
iniset_sudo $conf DEFAULT rabbit_port 5672
|
||||
iniset_sudo $conf DEFAULT rabbit_userid guest
|
||||
iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD"
|
||||
iniset_sudo $conf DEFAULT glance_host controller-mgmt
|
||||
|
||||
echo "Restarting cinder service."
|
||||
sudo service cinder-volume restart
|
||||
sudo service tgt restart
|
Loading…
x
Reference in New Issue
Block a user