Merge "Refactor deploy ramdisk to allow use of targetcli"

This commit is contained in:
Jenkins 2015-04-01 21:20:59 +00:00 committed by Gerrit Code Review
commit 5f0f296f58
19 changed files with 154 additions and 25 deletions

View File

@ -1,5 +1,3 @@
curl
tgtadm
tgtd
partprobe
lsblk

View File

@ -1,4 +1,3 @@
curl:
tgt:
parted:
util-linux:

View 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.

View File

@ -0,0 +1 @@
targetcli

View File

@ -0,0 +1,6 @@
target_core_mod
iscsi_target_mod
target_core_iblock
target_core_file
target_core_pscsi
configfs

View File

@ -0,0 +1 @@
package-installs

View 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

View 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
}

View 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
}

View 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()

View File

@ -0,0 +1 @@
targetcli:

View 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.

View File

@ -0,0 +1,2 @@
tgtadm
tgtd

View 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}

View 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
}

View File

@ -0,0 +1 @@
tgt:

View File

@ -1,3 +1,4 @@
deploy-targetcli
pkg-map
ramdisk-base
source-repositories

View File

@ -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=""

View File

@ -1,2 +1,3 @@
deploy-tgtadm
pkg-map
ramdisk-base