@@ -43,6 +43,13 @@ GITDIR["python-cinderclient"]=$DEST/python-cinderclient
4343GITDIR[" python-brick-cinderclient-ext" ]=$DEST /python-brick-cinderclient-ext
4444CINDER_DIR=$DEST /cinder
4545
46+ if [[ $SERVICE_IP_VERSION == 6 ]]; then
47+ CINDER_MY_IP=" $HOST_IPV6 "
48+ else
49+ CINDER_MY_IP=" $HOST_IP "
50+ fi
51+
52+
4653# Cinder virtual environment
4754if [[ ${USE_VENV} = True ]]; then
4855 PROJECT_VENV[" cinder" ]=${CINDER_DIR} .venv
@@ -88,13 +95,32 @@ CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1}
8895CINDER_VOLUME_CLEAR=${CINDER_VOLUME_CLEAR:- ${CINDER_VOLUME_CLEAR_DEFAULT:- zero} }
8996CINDER_VOLUME_CLEAR=$( echo ${CINDER_VOLUME_CLEAR} | tr ' [:upper:]' ' [:lower:]' )
9097
91- # Default to lioadm
92- CINDER_ISCSI_HELPER=${CINDER_ISCSI_HELPER:- lioadm}
98+
99+ if [[ -n " $CINDER_ISCSI_HELPER " ]]; then
100+ if [[ -z " $CINDER_TARGET_HELPER " ]]; then
101+ deprecated ' Using CINDER_ISCSI_HELPER is deprecated, use CINDER_TARGET_HELPER instead'
102+ CINDER_TARGET_HELPER=" $CINDER_ISCSI_HELPER "
103+ else
104+ deprecated ' Deprecated CINDER_ISCSI_HELPER is set, but is being overwritten by CINDER_TARGET_HELPER'
105+ fi
106+ fi
107+ CINDER_TARGET_HELPER=${CINDER_TARGET_HELPER:- lioadm}
108+
109+ if [[ $CINDER_TARGET_HELPER == ' nvmet' ]]; then
110+ CINDER_TARGET_PROTOCOL=${CINDER_TARGET_PROTOCOL:- ' nvmet_rdma' }
111+ CINDER_TARGET_PREFIX=${CINDER_TARGET_PREFIX:- ' nvme-subsystem-1' }
112+ CINDER_TARGET_PORT=${CINDER_TARGET_PORT:- 4420}
113+ else
114+ CINDER_TARGET_PROTOCOL=${CINDER_TARGET_PROTOCOL:- ' iscsi' }
115+ CINDER_TARGET_PREFIX=${CINDER_TARGET_PREFIX:- ' iqn.2010-10.org.openstack:' }
116+ CINDER_TARGET_PORT=${CINDER_TARGET_PORT:- 3260}
117+ fi
118+
93119
94120# EL and SUSE should only use lioadm
95121if is_fedora || is_suse; then
96- if [[ ${CINDER_ISCSI_HELPER } != " lioadm" ]]; then
97- die " lioadm is the only valid Cinder target_helper config on this platform"
122+ if [[ ${CINDER_TARGET_HELPER } != " lioadm" && ${CINDER_TARGET_HELPER} != ' nvmet ' ]]; then
123+ die " lioadm and nvmet are the only valid Cinder target_helper config on this platform"
98124 fi
99125fi
100126
@@ -187,7 +213,7 @@ function _cinder_cleanup_apache_wsgi {
187213function cleanup_cinder {
188214 # ensure the volume group is cleared up because fails might
189215 # leave dead volumes in the group
190- if [ " $CINDER_ISCSI_HELPER " = " tgtadm" ]; then
216+ if [ " $CINDER_TARGET_HELPER " = " tgtadm" ]; then
191217 local targets
192218 targets=$( sudo tgtadm --op show --mode target)
193219 if [ $? -ne 0 ]; then
@@ -215,8 +241,14 @@ function cleanup_cinder {
215241 else
216242 stop_service tgtd
217243 fi
218- else
244+ elif [ " $CINDER_TARGET_HELPER " = " lioadm " ] ; then
219245 sudo cinder-rtstool get-targets | sudo xargs -rn 1 cinder-rtstool delete
246+ elif [ " $CINDER_TARGET_HELPER " = " nvmet" ]; then
247+ # If we don't disconnect everything vgremove will block
248+ sudo nvme disconnect-all
249+ sudo nvmetcli clear
250+ else
251+ die $LINENO " Unknown value \" $CINDER_TARGET_HELPER \" for CINDER_TARGET_HELPER"
220252 fi
221253
222254 if is_service_enabled c-vol && [[ -n " $CINDER_ENABLED_BACKENDS " ]]; then
@@ -267,19 +299,15 @@ function configure_cinder {
267299
268300 iniset $CINDER_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
269301
270- iniset $CINDER_CONF DEFAULT target_helper " $CINDER_ISCSI_HELPER "
302+ iniset $CINDER_CONF DEFAULT target_helper " $CINDER_TARGET_HELPER "
271303 iniset $CINDER_CONF database connection ` database_connection_url cinder`
272304 iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI
273305 iniset $CINDER_CONF DEFAULT rootwrap_config " $CINDER_CONF_DIR /rootwrap.conf"
274306 iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions
275307 iniset $CINDER_CONF DEFAULT osapi_volume_listen $CINDER_SERVICE_LISTEN_ADDRESS
276308 iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH
277309 iniset $CINDER_CONF oslo_concurrency lock_path $CINDER_STATE_PATH
278- if [[ $SERVICE_IP_VERSION == 6 ]]; then
279- iniset $CINDER_CONF DEFAULT my_ip " $HOST_IPV6 "
280- else
281- iniset $CINDER_CONF DEFAULT my_ip " $HOST_IP "
282- fi
310+ iniset $CINDER_CONF DEFAULT my_ip " $CINDER_MY_IP "
283311 iniset $CINDER_CONF key_manager backend cinder.keymgr.conf_key_mgr.ConfKeyManager
284312 iniset $CINDER_CONF key_manager fixed_key $( openssl rand -hex 16)
285313 if [[ -n " $CINDER_ALLOWED_DIRECT_URL_SCHEMES " ]]; then
@@ -465,9 +493,9 @@ function init_cinder {
465493function install_cinder {
466494 git_clone $CINDER_REPO $CINDER_DIR $CINDER_BRANCH
467495 setup_develop $CINDER_DIR
468- if [[ " $CINDER_ISCSI_HELPER " == " tgtadm" ]]; then
496+ if [[ " $CINDER_TARGET_HELPER " == " tgtadm" ]]; then
469497 install_package tgt
470- elif [[ " $CINDER_ISCSI_HELPER " == " lioadm" ]]; then
498+ elif [[ " $CINDER_TARGET_HELPER " == " lioadm" ]]; then
471499 if is_ubuntu; then
472500 # TODO(frickler): Workaround for https://launchpad.net/bugs/1819819
473501 sudo mkdir -p /etc/target
@@ -476,6 +504,43 @@ function install_cinder {
476504 else
477505 install_package targetcli
478506 fi
507+ elif [[ " $CINDER_TARGET_HELPER " == " nvmet" ]]; then
508+ install_package nvme-cli
509+
510+ # TODO: Remove manual installation of the dependency when the
511+ # requirement is added to nvmetcli:
512+ # http://lists.infradead.org/pipermail/linux-nvme/2022-July/033576.html
513+ if is_ubuntu; then
514+ install_package python3-configshell-fb
515+ else
516+ install_package python3-configshell
517+ fi
518+ # Install from source because Ubuntu doesn't have the package and some packaged versions didn't work on Python 3
519+ pip_install git+git://git.infradead.org/users/hch/nvmetcli.git
520+
521+ sudo modprobe nvmet
522+ sudo modprobe nvme-fabrics
523+
524+ if [[ $CINDER_TARGET_PROTOCOL == ' nvmet_rdma' ]]; then
525+ install_package rdma-core
526+ sudo modprobe nvme-rdma
527+
528+ # Create the Soft-RoCE device over the networking interface
529+ local iface=${HOST_IP_IFACE:- `ip -br -$SERVICE_IP_VERSION a | grep $CINDER_MY_IP | awk ' {print $1}' `}
530+ if [[ -z " $iface " ]]; then
531+ die $LINENO " Cannot find interface to bind Soft-RoCE"
532+ fi
533+
534+ if ! sudo rdma link | grep $iface ; then
535+ sudo rdma link add rxe_$iface type rxe netdev $iface
536+ fi
537+
538+ elif [[ $CINDER_TARGET_PROTOCOL == ' nvmet_tcp' ]]; then
539+ sudo modprobe nvme-tcp
540+
541+ else # 'nvmet_fc'
542+ sudo modprobe nvme-fc
543+ fi
479544 fi
480545}
481546
@@ -512,7 +577,7 @@ function start_cinder {
512577 service_port=$CINDER_SERVICE_PORT_INT
513578 service_protocol=" http"
514579 fi
515- if [ " $CINDER_ISCSI_HELPER " = " tgtadm" ]; then
580+ if [ " $CINDER_TARGET_HELPER " = " tgtadm" ]; then
516581 if is_service_enabled c-vol; then
517582 # Delete any old stack.conf
518583 sudo rm -f /etc/tgt/conf.d/stack.conf
0 commit comments