From c822d4f5605bc2d15f0433ed505eff58c55dbed8 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 26 Mar 2014 13:08:41 -0400 Subject: [PATCH] defect 3953 --- xCAT-server/lib/xcat/plugins/dhcp.pm | 33 +++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 7f36d8158..7a46bcaf2 100755 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -881,6 +881,37 @@ sub check_options xCAT::MsgUtils->message("I", $rsp, $callback, 0); return 0; } + # if not help, dhcpd needs to be running + if (!($opt->{h})) { + if (xCAT::Utils->isLinux()) { + my @output = xCAT::Utils->runcmd("service dhcpd status", -1); + if ($::RUNCMD_RC != 0) { # not running + my $rsp = {}; + $rsp->{data}->[0] = "dhcpd is not running. Run service dhcpd start and rerun your command."; + 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)) { @@ -956,7 +987,7 @@ sub preprocess_request if ( $rc ) { return []; } - + my $snonly=0; my @entries = xCAT::TableUtils->get_site_attribute("disjointdhcps"); my $t_entry = $entries[0];