~rlane/nova/ldapimprovements

« back to all changes in this revision

Viewing changes to tools/iscsidev.sh

  • Committer: Ryan Lane
  • Date: 2010-11-24 15:46:32 UTC
  • mfrom: (382.48.1 trunk)
  • Revision ID: laner@controller-20101124154632-zh7kwjuyyd02a2lh
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Copyright 2010 United States Government as represented by the
 
4
# Administrator of the National Aeronautics and Space Administration.
 
5
# All Rights Reserved.
 
6
#
 
7
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
8
#    not use this file except in compliance with the License. You may obtain
 
9
#    a copy of the License at
 
10
#
 
11
#         http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
13
#    Unless required by applicable law or agreed to in writing, software
 
14
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
15
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
16
#    License for the specific language governing permissions and limitations
 
17
#    under the License.
 
18
 
 
19
# NOTE(vish): This script helps udev create  common names for discovered iscsi
 
20
#             volumes under /dev/iscsi.  To use it, create /dev/iscsi and add
 
21
#             a file to /etc/udev/rules.d like so:
 
22
#             mkdir /dev/iscsi
 
23
#             echo 'KERNEL=="sd*", BUS=="scsi", PROGRAM="/path/to/iscsidev.sh
 
24
#             %b",SYMLINK+="iscsi/%c%n"' > /etc/udev/rules.d/55-openiscsi.rules
 
25
 
 
26
BUS=${1}
 
27
HOST=${BUS%%:*}
 
28
 
 
29
if [ ! -e /sys/class/iscsi_host ]; then
 
30
    exit 1
 
31
fi
 
32
 
 
33
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/session*/targetname"
 
34
 
 
35
target_name=$(cat ${file})
 
36
 
 
37
if [ -z "${target_name}" ]; then
 
38
   exit 1
 
39
fi
 
40
 
 
41
echo "${target_name##*:}"