+xvm-iscsi-config (0.0.12) unstable; urgency=low
+
+ * Refactor postinstall script so it has a separate script for connecting
+ to the targets.
+ * Make connection process more resilient to failed discovery.
+
+ -- Quentin Smith <quentin@mit.edu> Sat, 11 Dec 2010 21:15:11 -0500
+
xvm-iscsi-config (0.0.11) unstable; urgency=low
* Support multiple iSCSI targets and read their addresses
get_new_sessions() {
for i in $(invirt-getconf --ls iscsi.targets); do
- echo $(invirt-getconf iscsi.targets.$i.ip) $(invirt-getconf iscsi.targets.$i.iface)
+ for j in $(invirt-getconf --ls iscsi.targets.$i.ifaces); do
+ echo $(invirt-getconf iscsi.targets.$i.ip) $(invirt-getconf iscsi.targets.$i.ifaces.$j)
+ done
done | sort
}
fi
if ! diff <(get_current_sessions) <(get_new_sessions) >/dev/null; then
if [ -z "$safe" ]; then
- for i in $(invirt-getconf --ls iscsi.targets); do
- iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.targets.$i.ip):3260 -I $(invirt-getconf iscsi.targets.$i.iface)
- iscsiadm -m node -p $(invirt-getconf iscsi.targets.$i.ip):3260 -I $(invirt-getconf iscsi.targets.$i.iface) -l
- done
+ /usr/lib/xvm-iscsi-connect
else
- for i in $(invirt-getconf --ls iscsi.targets); do
- echo " "iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.targets.$i.ip):3260 -I $(invirt-getconf iscsi.targets.$i.iface)
- echo " "iscsiadm -m node -p $(invirt-getconf iscsi.targets.$i.ip):3260 -I $(invirt-getconf iscsi.targets.$i.iface) -l
- done
+ echo " /usr/lib/xvm-iscsi-connect"
fi
cat <<EOF
You may want to recreate the LVM nodes:
--- /dev/null
+#!/bin/bash
+
+set -e
+
+good_nodes=""
+
+for i in $(invirt-getconf --ls iscsi.targets); do
+ # Extract the portal to talk to
+ portal_ip=$(invirt-getconf iscsi.targets.$i.ip)
+
+ # Extract the interfaces we should talk to this portal
+ # on. Unfortunately, we have to ask about all the interfaces
+ # simultaneously, because iscsiadm deletes all existing mentions
+ # of a portal when you run discovery again.
+ ifaces=$(for j in $(invirt-getconf --ls iscsi.targets.$i.ifaces); do invirt-getconf iscsi.targets.$i.ifaces.$j; done)
+
+ echo "Connecting to $portal_ip via $ifaces"
+
+ # Use SendTargets to discover the available targets on the given portal.
+ iscsiadm -m discovery -t st -p $portal_ip:3260 $(for iface in $ifaces; do echo -I $iface; done)
+
+ # Because of protocol limitations (see
+ # http://www.pdl.cmu.edu/mailinglists/ips/mail/msg05174.html), the
+ # discovery attempt may have returned additional targets that are
+ # unreachable via this interface/portal. Make a list of discovered
+ # target, portal, interface combinations so we can later remove
+ # extraneous ones.
+ for iface in $ifaces; do
+ good_nodes="$good_nodes "$(echo /etc/iscsi/nodes/*/$portal_ip,3260,1/$iface)
+ done
+
+ # If the discovery attempt did not log into the target, explicitly do so now.
+ for iface in $ifaces; do
+ iscsiadm -m node -p $portal_ip:3260 -I $iface -l
+ done
+done
+
+# Find all the nodes we now know about that we weren't supposed to
+bad_nodes=$(find /etc/iscsi/nodes -type f | grep -Fxvf <(echo "$good_nodes" | sed 's/ /\n/g'))
+# and delete them.
+echo "Removing "$(echo $bad_nodes | wc -w)" extraneous discovered targets"
+for node in $bad_nodes; do
+ echo "Removing $node"
+
+ # Remove the node entry
+ rm $node;
+
+ # Remove the cached results of the discovery so iscsiadm doesn't
+ # get confused
+ find /etc/iscsi/send_targets -lname "${node%/*}" -delete
+done