From b7e5a7116f2e1ecf5593b8d4d9256bbb8ac2e9b1 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 13 May 2008 14:49:54 +0000 Subject: [PATCH] change to system calls git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1367 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm | 78 ++++++++++------------ 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm b/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm index 3b2bc4e84..147689ab6 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm @@ -55,8 +55,15 @@ sub handled_commands if ($rc == 2) { # setup, just start the daemon - $cmd = "/etc/rc.d/init.d/dhcpd start"; - xCAT::Utils->runcmd($cmd, -1); + $cmd = " service dhcpd restart"; + system $cmd; + if ($? > 0) + { # error + xCAT::MsgUtils->message("S", "Error on command: $cmd"); + return 1; + } + + } } @@ -92,61 +99,48 @@ sub setup_DHCP my ($nodename) = @_; my $rc = 0; my $cmd; - my @output; - # read DB for nodeinfo - my $retdata = xCAT::Utils->readSNInfo($nodename); - if ($retdata->{'arch'}) - { # no error - my $master = $retdata->{'master'}; - my $os = $retdata->{'os'}; - my $arch = $retdata->{'arch'}; - # run makedhcp - $XCATROOT = "/opt/xcat"; # default + # run makedhcp + $XCATROOT = "/opt/xcat"; # default - if ($ENV{'XCATROOT'}) - { - $XCATROOT = $ENV{'XCATROOT'}; - } - my $cmdref; - $cmdref->{command}->[0] = "makedhcp"; - $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; - $cmdref->{arg}->[0] = "-n"; + if ($ENV{'XCATROOT'}) + { + $XCATROOT = $ENV{'XCATROOT'}; + } + my $cmdref; + $cmdref->{command}->[0] = "makedhcp"; + $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; + $cmdref->{arg}->[0] = "-n"; - my $modname = "dhcp"; - ${"xCAT_plugin::" . $modname . "::"}{process_request} + my $modname = "dhcp"; + ${"xCAT_plugin::" . $modname . "::"}{process_request} ->($cmdref, \&xCAT::Client::handle_response); - $cmd = "chkconfig dhcpd on"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) - { + $cmd = "chkconfig dhcpd on"; + system $cmd; + if ($? > 0) + { # error xCAT::MsgUtils->message("S", "Error from $cmd"); return 1; - } - $cmd = "/etc/rc.d/init.d/dhcpd start"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) - { + } + $cmd = "service dhcpd restart"; + system $cmd; + if ($? > 0) + { xCAT::MsgUtils->message("S", "Error from $cmd"); return 1; - } - $cmdref; - $cmdref->{command}->[0] = "makedhcp"; - $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; - $cmdref->{arg}->[0] = "-a"; + } + $cmdref; + $cmdref->{command}->[0] = "makedhcp"; + $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; + $cmdref->{arg}->[0] = "-a"; - my $modname = "dhcp"; + my $modname = "dhcp"; ${"xCAT_plugin::" . $modname . "::"}{process_request} ->($cmdref, \&xCAT::Client::handle_response); - } - else - { # error reading Db - $rc = 1; - } return $rc; }