unix:linux:iscsi_tricks_and_techniques
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
unix:linux:iscsi_tricks_and_techniques [2019/08/14 19:43] – rodolico | unix:linux:iscsi_tricks_and_techniques [2022/12/17 14:05] (current) – [Adding new target on target device] rodolico | ||
---|---|---|---|
Line 30: | Line 30: | ||
<code perl addAlliSCSIS.pl> | <code perl addAlliSCSIS.pl> | ||
- | #! / | + | #! /usr/bin/env perl |
- | my @servers = ( '10.5.136.1' ); | + | use strict; |
+ | use warnings; | ||
+ | |||
+ | # change following to be a list of 1 or more iSCSI targets to be queried | ||
+ | my @servers = ( '10.10.10.10',' | ||
my %targets; | my %targets; | ||
foreach my $server ( @servers ) { | foreach my $server ( @servers ) { | ||
+ | print " | ||
my @list = `iscsiadm -m discovery -t st -p $server`; | my @list = `iscsiadm -m discovery -t st -p $server`; | ||
chomp @list; | chomp @list; | ||
Line 50: | Line 55: | ||
# only add them if they are in this IP | # only add them if they are in this IP | ||
$targets{ $targetName } = $portal if $portal =~ m/ | $targets{ $targetName } = $portal if $portal =~ m/ | ||
+ | print " | ||
} | } | ||
} | } | ||
+ | print " | ||
# now, get active sessions so we can filter them | # now, get active sessions so we can filter them | ||
my @activeSessions = `iscsiadm -m session`; | my @activeSessions = `iscsiadm -m session`; | ||
chomp @activeSessions; | chomp @activeSessions; | ||
- | foreach $session ( @activeSessions ) { | + | foreach |
- | | + | |
my ( $portal, | my ( $portal, | ||
- | delete | + | print "$portal\t$targetName"; |
+ | if ( exists( $targets{$targetName} ) ) { | ||
+ | print "\tNOT updating\n" | ||
+ | delete $targets{ $targetName }; | ||
+ | } else { | ||
+ | print "Needs to be added\n"; | ||
+ | } | ||
} | } | ||
Line 74: | Line 87: | ||
} | } | ||
# print `ls / | # print `ls / | ||
+ | |||
</ | </ | ||
Line 107: | Line 121: | ||
</ | </ | ||
- | Edit / | + | Edit / |
< | < | ||
Line 115: | Line 129: | ||
</ | </ | ||
Restart iet | Restart iet | ||
- | <code bash> | + | <code bash>/ |
+ | service ctld reload # FreeBSD | ||
+ | </ | ||
==== Adding new target to initiator ==== | ==== Adding new target to initiator ==== | ||
Line 162: | Line 178: | ||
# first, log out of the session | # first, log out of the session | ||
iscsiadm -m node --target=' | iscsiadm -m node --target=' | ||
- | # now, do a discovery and delete the entry from your local database | + | # now, do a remove it from the session |
- | iscsiadm -m discovery | + | iscsiadm -m node --target=' |
</ | </ | ||
unix/linux/iscsi_tricks_and_techniques.1565829800.txt.gz · Last modified: 2019/08/14 19:43 by rodolico