2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-28 07:11:11 +00:00

makedhcp does not work well when all service nodes not running dhcp but disjointdhcps=1 (#4426) (#4440)

- if all service nodes not running dhcp, to treat it as disjointdhcps=0
- nodeset will send request to MN by default even if disjointdhcps=1
- Move out of the dhcp service checking from opts pre-check, and do it just before real makedhcp handling.
This commit is contained in:
Bin Xu
2017-12-05 16:48:29 +08:00
committed by yangsong
parent 9c946c851d
commit ca6024750f
2 changed files with 58 additions and 54 deletions

View File

@@ -219,6 +219,10 @@ sub get_broadcast_disjoint_scope_with_parallel {
my $reqs = get_parallel_scope($req);
my $handled4me = 0; # indicate myself is already handled.
if (xCAT::Utils->isMN()) { # For MN, add itself always.
push @requests, @$reqs;
$handled4me = 1;
}
my %prehandledhash = ();# the servers which is already handled.
foreach (@$extras) {
my $xcatdest = $_;

View File

@@ -978,48 +978,6 @@ sub check_options
return 0;
}
# if not help and not -n, dhcpd needs to be running
if (!($opt->{h}) && (!($opt->{n}))) {
if (xCAT::Utils->isLinux()) {
#my $DHCPSERVER="dhcpd";
#if( -e "/etc/init.d/isc-dhcp-server" ){
# $DHCPSERVER="isc-dhcp-server";
#}
#my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
#if ($::RUNCMD_RC != 0) { # not running
my $ret = 0;
$ret = xCAT::Utils->checkservicestatus("dhcp");
if ($ret != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "dhcp server is not running. please start the dhcp server.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
}
} else { # AIX
my @output = xCAT::Utils->runcmd("lssrc -s dhcpsd ", -1);
if ($::RUNCMD_RC != 0) { # not running
my $rsp = {};
$rsp->{data}->[0] = "dhcpsd is not running. Run startsrc -s dhcpsd and rerun your command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
} else { # check the status
# the return output varies, sometime status is the third sometimes the 4th col
if (grep /inoperative/, @output)
{
my $rsp = {};
$rsp->{data}->[0] = "dhcpsd is not running. Run startsrc -s dhcpsd and rerun your command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
}
}
}
}
# check to see if -q is listed with any other options which is not allowed
if ($opt->{q} and ($opt->{a} || $opt->{d} || $opt->{n} || $opt->{r} || $opt->{l} || $statements)) {
my $rsp = {};
@@ -1132,9 +1090,11 @@ sub preprocess_request
xCAT::MsgUtils->trace($verbose_on_off, "d", "dhcp: dhcp server on $_->{net}: $_->{dhcpserver}");
}
}
} elsif ($snonly == 1) {
$snonly = 0;
xCAT::MsgUtils->trace($verbose_on_off, "d", "dhcp: disjointdhcps mode is disabled as no service nodes are running dhcp service.");
}
my @nodes = ();
# if the new option is not specified
@@ -1381,17 +1341,6 @@ sub process_request
return [];
}
# if option is query then call listnode for each node and return
if ($opt{q})
{
# call listnode for each node requested
foreach my $node (@{ $req->{node} }) {
listnode($node, $callback);
}
return;
}
# if current node is a servicenode, make sure that it is also a dhcpserver
my $isok = 1;
if (xCAT::Utils->isServiceNode()) {
@@ -1413,6 +1362,57 @@ sub process_request
return;
}
# if not -n, dhcpd needs to be running
if (!($opt{n})) {
if (xCAT::Utils->isLinux()) {
#my $DHCPSERVER="dhcpd";
#if( -e "/etc/init.d/isc-dhcp-server" ){
# $DHCPSERVER="isc-dhcp-server";
#}
#my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
#if ($::RUNCMD_RC != 0) { # not running
my $ret = 0;
$ret = xCAT::Utils->checkservicestatus("dhcp");
if ($ret != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "dhcp server is not running. please start the dhcp server.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return;
}
} else { # AIX
my @output = xCAT::Utils->runcmd("lssrc -s dhcpsd ", -1);
if ($::RUNCMD_RC != 0) { # not running
my $rsp = {};
$rsp->{data}->[0] = "dhcpsd is not running. Run startsrc -s dhcpsd and rerun your command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return;
} else { # check the status
# the return output varies, sometime status is the third sometimes the 4th col
if (grep /inoperative/, @output)
{
my $rsp = {};
$rsp->{data}->[0] = "dhcpsd is not running. Run startsrc -s dhcpsd and rerun your command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return;
}
}
}
}
# if option is query then call listnode for each node and return
if ($opt{q})
{
# call listnode for each node requested
foreach my $node (@{ $req->{node} }) {
listnode($node, $callback);
}
return;
}
my $servicenodetab = xCAT::Table->new('servicenode');
my @nodeinfo = xCAT::NetworkUtils->determinehostname;
my $nodename = pop @nodeinfo; # get hostname