2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-28 08:55:52 +00:00

Merge pull request #4113 from hu-weihua/xcatmn

Modify xcatprobe xcatmn depending on new requirement #4092
This commit is contained in:
xuweibj
2017-10-23 14:36:53 +08:00
committed by GitHub

View File

@ -48,7 +48,7 @@ Description:
Options:
-h : Get usage information of $program_name
-V : Output more information for debug
-i : Required. Specify the network interface name of provision network on management node
-i : Specify the network interface name of provision network on management node. if not specified, will guess the provision network from site table master attribute. Recommand to use -i option. If there is vlan in the network interface, provide the network interface with vlan infomation, such as '-i <nic>.<vlan>'.
";
sub do_main_job {
@ -400,22 +400,40 @@ sub check_network {
$rst = 1;
}
} else { # on MN
my $nics = `ip addr show $installnic >/dev/null 2>&1`;
if ($?) {
push @$error_ref, "There isn't NIC '$installnic' in current server";
$rst = 1;
} else {
$$serverip_ref = `ip addr show $installnic 2>&1| awk -F" " '/inet / {print \$2}'|awk -F"/" '{print \$1}'`;
chomp($$serverip_ref);
if (!defined($$serverip_ref) || ($$serverip_ref eq "")) {
push @$error_ref, "There isn't IP address assigned to NIC $installnic";
if($installnic){
#if customer specified install NIC by '-i' option, use that
my $nics = `ip -4 -o a|grep '$installnic\\\\' >/dev/null 2>&1`;
if ($?) {
push @$error_ref, "There isn't NIC '$installnic' in current server";
$rst = 1;
} else {
if ($$serverip_ref ne $sitetable_ref->{master}) {
push @$error_ref, "The IP $$serverip_ref of $installnic doesn't equal the value of 'master' in 'site' table";
$$serverip_ref = `ip -4 -o a|awk -F' ' '/$installnic\\\\/ {print \$4}'|awk -F'/' '{print \$1}'`;
chomp($$serverip_ref);
if (!defined($$serverip_ref) || ($$serverip_ref eq "")) {
push @$error_ref, "There isn't IP address assigned to NIC $installnic";
$rst = 1;
} else {
if ($$serverip_ref ne $sitetable_ref->{master}) {
push @$error_ref, "The IP $$serverip_ref of $installnic doesn't equal the value of 'master' in 'site' table";
$rst = 1;
}
}
}
}else{
#if customer does not specified install NIC by '-i' option, suppose the network which <master> attribute in site table belongs to is install network.
$$serverip_ref = $sitetable_ref->{master};
my $str = `ip -4 -o a|grep '$$serverip_ref'`;
if($?) {
push @$error_ref, "The value $$serverip_ref of master attribute in site table doesn't belong to any NIC in current server";
$rst = 1;
}else{
chomp($str);
my @tmp1 = split("\\\\", $str);
my @tmp2 = split(" ", $tmp1[0]);
$installnic=$tmp2[-1];
probe_utils->send_msg("$output", "w", "No interface provided by '-i' option, detected site table IP attribute $$serverip_ref, checking xCAT configuration using interface: $installnic");
probe_utils->send_msg("$output", "w", "If this is incorrect, rerun with -i <ifname> option");
}
}
}
@ -978,11 +996,6 @@ if ($test) {
exit 0;
}
if (!$installnic){
probe_utils->send_msg("$output", "f", "Option '-i' is required");
probe_utils->send_msg("$output", "d", "$::USAGE");
exit 1;
}
#Handle the interrupt signal from STDIN
$SIG{TERM} = $SIG{INT} = sub {
@ -1019,6 +1032,7 @@ while ($hierarchy_instance->read_reply(\%reply_cache)) {
my $msg = "";
my $logmsg = "";
#print ">>>$reply_cache{$servers}->[$_]<<<\n";
#For cases like below:
#c910f02c04p04: [ok] :All xCAT deamons are running
if ($reply_cache{$servers}->[$_] =~ /^(\w+)\s*:\s*(\[\w+\]\s*):\s*(.*)/) {
@ -1027,6 +1041,14 @@ while ($hierarchy_instance->read_reply(\%reply_cache)) {
$msg = "$2:[$server]: $3";
}
#For cases like below:
#sn02: ssh: connect to host sn02 port 22: No route to host
} elsif ($reply_cache{$servers}->[$_] =~ /^(\w+)\s*:\s*(ssh:.+)/){
if("$1" eq "$server") {
$logmsg = "$2";
$msg = "[failed] :[$server]: $2";
}
#For cases like below:
#c910f02c04p05: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
} elsif ($reply_cache{$servers}->[$_] =~ /^(\w+)\s*:\s*(.*)/) {