From d8debc21588a84d1c12d0b76198e697b769092e1 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 7 Mar 2008 18:30:27 +0000 Subject: [PATCH] fix running under daemon git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@724 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/CONSsn.pm | 25 +++++++++++--------- xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm | 27 +++++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/CONSsn.pm b/xCAT-server-2.0/lib/xcat/plugins/CONSsn.pm index 3fef10f96..e56ee896f 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/CONSsn.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/CONSsn.pm @@ -5,7 +5,9 @@ package xCAT_plugin::CONSsn; use xCAT::Table; use xCAT::Utils; +use xCAT_plugin::conserver; +use xCAT::Client; use xCAT::MsgUtils; use Getopt::Long; @@ -36,16 +38,16 @@ sub handled_commands if (xCAT::Utils->isServiceNode()) { my @nodeinfo = xCAT::Utils->determinehostname; - my $nodename = pop @nodeinfo; # get hostname - my @nodeipaddr = @nodeinfo; # get ip addresses + my $nodename = pop @nodeinfo; # get hostname + my @nodeipaddr = @nodeinfo; # get ip addresses - my $service = "cons"; + my $service = "cons"; $rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr); if ($rc == 1) { # service needed on this Service Node - $rc = &setup_CONS($nodename); # setup CONS + $rc = &setup_CONS($nodename); # setup CONS if ($rc == 0) { xCAT::Utils->update_xCATSN($service); @@ -96,13 +98,13 @@ sub setup_CONS $arch = $retdata->{'arch'}; # make the consever 8 configuration file - $cmd = "makeconservercf"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) - { # error - xCAT::MsgUtils->message("S", "Error running $cmd"); - return 1; - } + my $cmdref; + $cmdref->{command}->[0] = "makeconservercf"; + $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; + + my $modname = "conserver"; + ${"xCAT_plugin::" . $modname . "::"}{process_request} + ->($cmdref,\&xCAT::Client::handle_response); my $cmd = "chkconfig conserver on"; xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) @@ -127,4 +129,5 @@ sub setup_CONS } return $rc; } + 1; diff --git a/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm b/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm index b5cb43b2b..fbd541504 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/DHCPsn.pm @@ -5,8 +5,10 @@ package xCAT_plugin::DHCPsn; use xCAT::Table; use xCAT::Utils; - +use xCAT_plugin::dhcp; use xCAT::MsgUtils; + +use xCAT::Client; use Getopt::Long; #------------------------------------------------------- @@ -33,8 +35,8 @@ sub handled_commands if (xCAT::Utils->isServiceNode()) { my @nodeinfo = xCAT::Utils->determinehostname; - my $nodename = pop @nodeinfo; # get hostname - my @nodeipaddr = @nodeinfo; # get ip addresses + my $nodename = pop @nodeinfo; # get hostname + my @nodeipaddr = @nodeinfo; # get ip addresses my $service = "dhcpserver"; $rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr); @@ -42,7 +44,7 @@ sub handled_commands { # service needed on this Service Node - $rc = &setup_DHCP($nodename); # setup DHCP + $rc = &setup_DHCP($nodename); # setup DHCP if ($rc == 0) { xCAT::Utils->update_xCATSN($service); @@ -97,13 +99,15 @@ sub setup_DHCP { $XCATROOT = $ENV{'XCATROOT'}; } - $cmd = "$XCATROOT/sbin/makedhcp -n"; - @output = xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd, output=@output"); - return 1; - } + my $cmdref; + $cmdref->{command}->[0] = "makedhcp"; + $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; + $cmdref->{arg}->[0] = "-n"; + + 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) @@ -126,4 +130,5 @@ sub setup_DHCP } return $rc; } + 1;