Refactor cinder-vmware role

Change-Id: Ibe86b7794d347e11d0465b927502bd58e2356b1a
Implements: blueprint refactor-cinder-vmware-role
This commit is contained in:
Alexander Arzhanov 2015-12-02 20:22:48 +03:00
parent 0c8de9b59d
commit 5473fb6c33
8 changed files with 178 additions and 38 deletions

View File

@ -44,8 +44,6 @@ if (member($roles, 'cinder') and $storage_hash['volumes_lvm']) {
$manage_volumes = 'iscsi'
} elsif ($storage_hash['volumes_ceph']) {
$manage_volumes = 'ceph'
} elsif member($roles, 'cinder-vmware') {
$manage_volumes = 'vmdk'
} else {
$manage_volumes = false
}

View File

@ -1,6 +1,6 @@
- id: openstack-cinder
type: puppet
groups: [primary-controller, controller, cinder-vmware]
groups: [primary-controller, controller]
required_for: [deploy_end, openstack-controller]
requires: [rabbitmq, keystone, hosts, firewall]
parameters:

View File

@ -146,7 +146,7 @@ $idle_timeout = '3600'
if (member($roles, 'cinder') and $storage_hash['volumes_lvm']) {
$manage_volumes = 'iscsi'
$physical_volumes = false
} elsif (member($roles, 'cinder') and $storage_hash['volumes_vmdk']) {
} elsif member($roles, 'cinder-vmware') {
$manage_volumes = 'vmdk'
$physical_volumes = false
} elsif ($storage_hash['volumes_ceph']) {

View File

@ -20,7 +20,7 @@
- id: top-role-cinder
type: puppet
groups: [cinder,cinder-block-device]
groups: [cinder, cinder-block-device, cinder-vmware]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:

View File

@ -13,7 +13,7 @@
type: puppet
groups: [cinder-vmware]
required_for: [deploy_end]
requires: [openstack-cinder]
requires: [top-role-cinder]
condition: "settings:common.use_vcenter.value == true"
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/vmware/cinder-vmware.pp

View File

@ -0,0 +1,33 @@
description "OpenStack Cinder Volume for VMware"
author "Alexander Arzhanov <aarzhanov@mirantis.com>"
start on runlevel [2345]
stop on runlevel [!2345]
chdir /var/run
respawn
respawn limit 20 5
limit nofile 65535 65535
pre-start script
for i in lock run log lib ; do
mkdir -p /var/$i/cinder
chown cinder /var/$i/cinder
done
end script
script
[ -x "/usr/bin/cinder-volume" ] || exit 0
DAEMON_ARGS=""
CINDER_VOLUME_OPTS=""
[ -r /etc/default/openstack ] && . /etc/default/openstack
[ -r /etc/default/$UPSTART_JOB ] && . /etc/default/$UPSTART_JOB
[ "x$USE_SYSLOG" = "xyes" ] && DAEMON_ARGS="$DAEMON_ARGS --use-syslog"
[ "x$USE_LOGFILE" != "xno" ] && DAEMON_ARGS="$DAEMON_ARGS --log-file=/var/log/cinder/$UPSTART_JOB.log"
exec start-stop-daemon --start --chdir /var/lib/cinder \
--chuid cinder:cinder --make-pidfile --pidfile /var/run/cinder/$UPSTART_JOB.pid \
--exec /usr/bin/cinder-volume -- --config-file=/etc/cinder/cinder.conf ${CINDER_VOLUME_OPTS} ${DAEMON_ARGS}
end script

View File

@ -0,0 +1,114 @@
#!/bin/sh
#
# openstack-cinder-volume OpenStack Cinder Volume Services
#
# chkconfig: - 98 02
# description: Volume Workers interact with iSCSI storage to manage \
# LVM-based instance volumes. Specific functions include: \
# * Create Volumes \
# * Establish Compute volumes
## BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: OpenStack cinder Volume Worker
# Description: Volume Workers interact with iSCSI storage to manage
# LVM-based instance volumes. Specific functions include:
# * Create Volumes
# * Delete Volumes
# * Establish Compute volumes
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=volume
cluster=${0##*-} # s/cluster/index/
prog=openstack-cinder-$suffix-vmware-$cluster
exec="/usr/bin/cinder-$suffix"
config="/etc/cinder/cinder.conf"
pidfile="/var/run/cinder/cinder-$suffix.$cluster.pid"
logfile="/var/log/cinder/$suffix-$cluster.log"
[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user cinder --pidfile $pidfile "$exec --logfile $logfile --config-file=$config ${OPTIONS} &>/dev/null & echo \$! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile ${prog%%.*}
if pgrep -f "cinder-$suffix.*$cluster\.conf" &>/dev/null ; then
sleep 2
pgrep -f "cinder-$suffix.*$cluster\.conf" &>/dev/null && \
pkill -f "$cluster.conf"
fi
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?

View File

@ -33,27 +33,10 @@ define vmware::cinder::vmdk(
$debug = false,
)
{
include cinder::params
$index = $availability_zone_name
$cinder_volume_conf = "${cinder_conf_dir}/vmware-${index}.conf"
$cinder_volume_log = "${cinder_log_dir}/vmware-${index}.log"
$cinder_conf = '/etc/cinder/cinder.conf'
$cinder_volume_conf = "${cinder_conf_dir}/vmware-${index}.conf"
$cinder_volume_vmware = "${::cinder::params::volume_service}-vmware"
$storage_hash = hiera('storage', {})
$nodes_hash = hiera('nodes', {})
$roles = node_roles($nodes_hash, hiera('uid'))
if ($storage_hash['volumes_ceph']) and
!(member($roles, 'primary-controller') or
member($roles, 'controller')) {
service { 'cinder-volume':
enable => false,
ensure => stopped,
name => $::cinder::params::volume_service,
hasstatus => true,
}
}
if ! defined(File[$cinder_conf_dir]) {
file { $cinder_conf_dir:
@ -76,6 +59,15 @@ define vmware::cinder::vmdk(
File[$cinder_conf_dir]->File[$cinder_volume_conf]
if ! defined(Service["cinder_volume_vmware"]) {
service { "cinder_volume_vmware":
enable => false,
ensure => stopped,
name => "${cinder_volume_vmware}",
hasstatus => true,
}
}
if ! defined(Service["cinder_volume_vmware_${index}"]) {
service { "cinder_volume_vmware_${index}":
ensure => running,
@ -88,6 +80,7 @@ define vmware::cinder::vmdk(
'RedHat': {
$src_init = $cinder_volume_vmware
$dst_init = '/etc/init.d'
$file_perm = '0755'
$cinder_volume_vmware_init = "${dst_init}/${cinder_volume_vmware}"
$init_link = "${cinder_volume_vmware_init}-${index}"
if ! defined(File[$init_link]) {
@ -101,26 +94,26 @@ define vmware::cinder::vmdk(
if ! defined(File[$cinder_volume_default]){
file { $cinder_volume_default:
ensure => present,
content => "OPTIONS='--config-file=${cinder_conf} \
--config-file=${cinder_volume_conf}'",
content => "OPTIONS='--config-file=${cinder_volume_conf}'",
}
}
File[$cinder_volume_default]~>
Service["cinder_volume_vmware_${index}"]
Service["cinder_volume_vmware_${index}"]->
Service["cinder_volume_vmware"]
}
'Debian': {
$cinder_volume_default = "/etc/default/${cinder_volume_vmware}-${index}"
$src_init = "${cinder_volume_vmware}.conf"
$dst_init = '/etc/init'
$file_perm = '0644'
ensure_packages($::cinder::params::volume_package)
Package[$::cinder::params::volume_package] -> Exec[$src_init]
Package[$::cinder::params::volume_package] -> File[$src_init]
if ! defined(File[$cinder_volume_default]) {
file { $cinder_volume_default:
ensure => present,
content => "CINDER_VOLUME_OPTS='--config-file=${cinder_conf} \
--config-file=${cinder_volume_conf} --log-file=${cinder_volume_log}'",
content => "CINDER_VOLUME_OPTS='--config-file=${cinder_volume_conf}'",
}
}
@ -144,23 +137,25 @@ define vmware::cinder::vmdk(
File[$cinder_volume_default]~>
Exec[$init_reload]->
Service["cinder_volume_vmware_${index}"]
Service["cinder_volume_vmware_${index}"]->
Service["cinder_volume_vmware"]
}
default: {
fail { "Unsupported OS family (${::osfamily})": }
}
}
$cmd = "cp /usr/share/cinder/${src_init} ${dst_init}"
if ! defined(Exec[$src_init]) {
exec {$src_init:
command => $cmd,
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ]
if ! defined(File[$src_init]) {
file { $src_init:
source => "puppet:///modules/vmware/${src_init}",
path => "${dst_init}/${src_init}",
owner => 'root',
group => 'root',
mode => $file_perm,
}
}
Exec[$src_init]->
File[$src_init]->
File[$init_link]->
File[$cinder_volume_default]
}