~soren/nova/logdir-flag

« back to all changes in this revision

Viewing changes to tools/iscsidev.sh

  • Committer: Tarmac
  • Author(s): Vishvananda Ishaya
  • Date: 2010-11-03 08:29:03 UTC
  • mfrom: (379.3.10 iscsi-volumes)
  • Revision ID: hudson@openstack.org-20101103082903-ewvisg4duas9gik7
ISCSI Volume support

* Rewrite of Volume code to make VolumeManager more generic
* AoE vs. ISCSI moved to driver layer
* Added db support for target ids
* Added code to re-export volumes on restart of VolumeManager
* Includes a script to create /dev/iscsi volumes on remote hosts
* Change libvirt_conn to use the python connection to attach disks instead of shell
* Changed cloud and compute manager to deal with attaching, detaching, and terminating in
  a saner manner.

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##*:}"