Merge "Refactor deploy ramdisk to allow use of targetcli"
This commit is contained in:
commit
5f0f296f58
@ -1,5 +1,3 @@
|
||||
curl
|
||||
tgtadm
|
||||
tgtd
|
||||
partprobe
|
||||
lsblk
|
||||
|
@ -1,4 +1,3 @@
|
||||
curl:
|
||||
tgt:
|
||||
parted:
|
||||
util-linux:
|
||||
|
7
elements/deploy-targetcli/README.md
Normal file
7
elements/deploy-targetcli/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
Use targetcli for the deploy ramdisk
|
||||
|
||||
Provides the necessary scripts and dependencies to use targetcli
|
||||
for exporting the iscsi target in the deploy ramdisk.
|
||||
|
||||
Implemented as a dracut module, so will only work with dracut-based
|
||||
ramdisks.
|
1
elements/deploy-targetcli/binary-deps.d/deploy-targetcli
Normal file
1
elements/deploy-targetcli/binary-deps.d/deploy-targetcli
Normal file
@ -0,0 +1 @@
|
||||
targetcli
|
@ -0,0 +1,6 @@
|
||||
target_core_mod
|
||||
iscsi_target_mod
|
||||
target_core_iblock
|
||||
target_core_file
|
||||
target_core_pscsi
|
||||
configfs
|
1
elements/deploy-targetcli/element-deps
Normal file
1
elements/deploy-targetcli/element-deps
Normal file
@ -0,0 +1 @@
|
||||
package-installs
|
11
elements/deploy-targetcli/extra-data.d/50-add-targetcli-module
Executable file
11
elements/deploy-targetcli/extra-data.d/50-add-targetcli-module
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
MODULE_PATH="/usr/lib/dracut/modules.d"
|
||||
sudo cp -r $(dirname $0)/module/ ${TMP_MOUNT_PATH}${MODULE_PATH}/50targetcli
|
22
elements/deploy-targetcli/extra-data.d/module/iscsi-func
Executable file
22
elements/deploy-targetcli/extra-data.d/module/iscsi-func
Executable file
@ -0,0 +1,22 @@
|
||||
function start_iscsi_target() {
|
||||
local iqn=$1
|
||||
local dev=$2
|
||||
local cli=$3
|
||||
|
||||
# used by tgtd
|
||||
mkdir -p /var/run
|
||||
|
||||
ln -s /usr/bin/targetcli /targetcli_bin.py
|
||||
/targetcli-wrapper /backstores/block create block1 dev=$dev
|
||||
/targetcli-wrapper /iscsi create $iqn
|
||||
/targetcli-wrapper /iscsi/$iqn/tpg1/luns create /backstores/block/block1 1
|
||||
/targetcli-wrapper /iscsi/$iqn/tpg1/portals create $BOOT_IP_ADDRESS
|
||||
/targetcli-wrapper /iscsi/$iqn/tpg1 set attribute authentication=0
|
||||
/targetcli-wrapper /iscsi/$iqn/tpg1 set attribute demo_mode_write_protect=0
|
||||
/targetcli-wrapper /iscsi/$iqn/tpg1 set attribute generate_node_acls=1
|
||||
|
||||
}
|
||||
|
||||
function stop_iscsi_target() {
|
||||
/targetcli-wrapper clearconfig confirm=True
|
||||
}
|
28
elements/deploy-targetcli/extra-data.d/module/module-setup.sh
Executable file
28
elements/deploy-targetcli/extra-data.d/module/module-setup.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Dracut is bash too, and it doesn't play nicely with our usual sets
|
||||
# dib-lint: disable=setu sete setpipefail dibdebugtrace
|
||||
|
||||
check() {
|
||||
return 0
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst /bin/targetcli
|
||||
inst "$moddir/targetcli-wrapper" /targetcli-wrapper
|
||||
inst "$moddir/iscsi-func" /iscsi-func
|
||||
# Install all of Python
|
||||
# TODO(bnemec): At some point this will need to be extended to support
|
||||
# Python 3, but for the moment we aren't using that anyway.
|
||||
inst /usr/bin/python
|
||||
for i in $(find /usr/lib64/python2.7/ -type f); do
|
||||
inst $i
|
||||
done
|
||||
for i in $(find /usr/lib/python2.7/ -type f); do
|
||||
inst $i
|
||||
done
|
||||
}
|
31
elements/deploy-targetcli/extra-data.d/module/targetcli-wrapper
Executable file
31
elements/deploy-targetcli/extra-data.d/module/targetcli-wrapper
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright 2014 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import rtslib
|
||||
|
||||
import targetcli_bin
|
||||
|
||||
|
||||
class MyISCSIFabricModule(rtslib.fabric.ISCSIFabricModule):
|
||||
def __init__(self):
|
||||
super(rtslib.fabric.ISCSIFabricModule, self).__init__('iscsi')
|
||||
self.wwn_types = ('free',)
|
||||
|
||||
|
||||
rtslib.fabric.fabric_modules['iscsi'] = MyISCSIFabricModule
|
||||
|
||||
|
||||
targetcli_bin.main()
|
1
elements/deploy-targetcli/package-installs.yaml
Normal file
1
elements/deploy-targetcli/package-installs.yaml
Normal file
@ -0,0 +1 @@
|
||||
targetcli:
|
6
elements/deploy-tgtadm/README.md
Normal file
6
elements/deploy-tgtadm/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
Use tgtadm and tgtd for the deploy ramdisk
|
||||
|
||||
Provides the necessary scripts and dependencies to use tgtadm
|
||||
and tgtd for exporting the iscsi target in the deploy ramdisk.
|
||||
|
||||
Will only work with the standard (not dracut) ramdisk.
|
2
elements/deploy-tgtadm/binary-deps.d/deploy-tgtadm
Normal file
2
elements/deploy-tgtadm/binary-deps.d/deploy-tgtadm
Normal file
@ -0,0 +1,2 @@
|
||||
tgtadm
|
||||
tgtd
|
12
elements/deploy-tgtadm/extra-data.d/50-inject-tgtadm-iscsi-func
Executable file
12
elements/deploy-tgtadm/extra-data.d/50-inject-tgtadm-iscsi-func
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
RAMDISK_SCRIPT_PATH="$TMP_MOUNT_PATH/tmp/ramdisk-build/scripts/d"
|
||||
mkdir -p ${RAMDISK_SCRIPT_PATH}
|
||||
cp $(dirname $0)/scripts/iscsi-func ${RAMDISK_SCRIPT_PATH}
|
21
elements/deploy-tgtadm/extra-data.d/scripts/iscsi-func
Normal file
21
elements/deploy-tgtadm/extra-data.d/scripts/iscsi-func
Normal file
@ -0,0 +1,21 @@
|
||||
function start_iscsi_target() {
|
||||
local iqn=$1
|
||||
local dev=$2
|
||||
local cli=$3
|
||||
|
||||
# used by tgtd
|
||||
mkdir -p /var/run
|
||||
|
||||
tgtd
|
||||
wait_for 10 0.5 check_tgtd_socket
|
||||
|
||||
tgtadm --lld iscsi --mode target --op new --tid 1 --targetname "$iqn"
|
||||
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store "$dev"
|
||||
tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address "$cli"
|
||||
}
|
||||
|
||||
function stop_iscsi_target() {
|
||||
tgtadm --lld iscsi --mode logicalunit --op delete --tid 1 --lun 1
|
||||
tgtadm --lld iscsi --mode target --op delete --tid 1
|
||||
killall tgtd
|
||||
}
|
1
elements/deploy-tgtadm/package-installs.yaml
Normal file
1
elements/deploy-tgtadm/package-installs.yaml
Normal file
@ -0,0 +1 @@
|
||||
tgt:
|
@ -1,3 +1,4 @@
|
||||
deploy-targetcli
|
||||
pkg-map
|
||||
ramdisk-base
|
||||
source-repositories
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
source /iscsi-func
|
||||
|
||||
function configure_vmedia_dir() {
|
||||
VMEDIA_MOUNT_POINT="/vfloppy_mnt"
|
||||
VMEDIA_DIR="/vfloppy"
|
||||
@ -238,28 +240,6 @@ wait_for(){
|
||||
return 1
|
||||
}
|
||||
|
||||
function start_iscsi_target() {
|
||||
local iqn=$1
|
||||
local dev=$2
|
||||
local cli=$3
|
||||
|
||||
# used by tgtd
|
||||
mkdir -p /var/run
|
||||
|
||||
tgtd
|
||||
wait_for 10 0.5 check_tgtd_socket
|
||||
|
||||
tgtadm --lld iscsi --mode target --op new --tid 1 --targetname "$iqn"
|
||||
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store "$dev"
|
||||
tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address "$cli"
|
||||
}
|
||||
|
||||
function stop_iscsi_target() {
|
||||
tgtadm --lld iscsi --mode logicalunit --op delete --tid 1 --lun 1
|
||||
tgtadm --lld iscsi --mode target --op delete --tid 1
|
||||
killall tgtd
|
||||
}
|
||||
|
||||
function troubleshoot() {
|
||||
if [ "$TROUBLESHOOT" != 1 ]; then
|
||||
_DO_TROUBLESHOOT=""
|
||||
|
@ -1,2 +1,3 @@
|
||||
deploy-tgtadm
|
||||
pkg-map
|
||||
ramdisk-base
|
||||
|
Loading…
Reference in New Issue
Block a user