2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 17:46:38 +00:00

Add -c option for switchdiscover command to pass in community string

This commit is contained in:
Casandra Qiu 2017-09-22 16:36:06 -04:00
parent 8e9102a057
commit 5ffaebd636
2 changed files with 11 additions and 10 deletions

View File

@ -328,7 +328,7 @@ my %usage = (
pdudiscover [<noderange>|--range ipranges] [-r|-x|-z] [-w] [-V|--verbose] [--setup]",
"switchdiscover" =>
"Usage: switchdiscover [-h|--help|-v|--version]
switchdiscover [<noderange>|--range ipranges] [-s scan_methods] [-r|-x|-z] [-w] [-V|--verbose] [--setup]",
switchdiscover [<noderange>|--range ipranges] [-s scan_methods] [-c community] [-r|-x|-z] [-w] [-V|--verbose] [--setup]",
"switchprobe" =>
"Usage: switchprobe [<noderange>] [-V|--verbose | -c|--check]",
"makentp" =>

View File

@ -25,7 +25,7 @@ use xCAT::data::switchinfo;
#global variables for this module
my $device;
my $community;
my $community="public";
my %globalopt;
my @filternodes;
my @iprange;
@ -144,7 +144,7 @@ sub parse_args {
# Process command-line flags
#############################################
if (!GetOptions( \%opt,
qw(h|help V|verbose v|version x z w r n range=s s=s setup pdu))) {
qw(h|help V|verbose v|version x z w r n range=s s=s c=s setup pdu))) {
return( usage() );
}
@ -252,6 +252,14 @@ sub parse_args {
$globalopt{n} = 1;
}
#########################################################
# Accept the community string from user
#########################################################
if ( exists( $opt{c} )) {
$community=$opt{c};
}
#########################################################
# setup discover switch
#########################################################
@ -892,13 +900,6 @@ sub snmp_scan {
}
my @lines = split /\n/, $result;
#set community string for switch
$community = "public";
my @snmpcs = xCAT::TableUtils->get_site_attribute("snmpc");
my $tmp = $snmpcs[0];
if (defined($tmp)) { $community = $tmp }
foreach my $line (@lines) {
my @array = split / /, $line;
if ($line =~ /\b(\d{1,3}(?:\.\d{1,3}){3})\b/)