2009-06-05 13:53:52 +00:00
|
|
|
#!/usr/bin/env perl -w
|
|
|
|
# IBM(c) 2009 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#####################################################
|
|
|
|
#
|
|
|
|
# xCAT post script for AIX nodes
|
|
|
|
# This script will send command "syncfiles" to the xcatd on
|
|
|
|
# management node or service node to initiate the sync file
|
|
|
|
# operation by xdcp command
|
|
|
|
#
|
|
|
|
#####################################################
|
|
|
|
|
2009-07-15 13:08:51 +00:00
|
|
|
use XML::Simple;
|
2009-06-05 13:53:52 +00:00
|
|
|
|
2009-07-15 13:08:51 +00:00
|
|
|
my $useSocketSSL=eval { require IO::Socket::SSL; };
|
|
|
|
if ($useSocketSSL) {
|
|
|
|
require IO::Socket::SSL;
|
|
|
|
}
|
2009-06-05 13:53:52 +00:00
|
|
|
|
2009-07-15 13:08:51 +00:00
|
|
|
my $port = "3001";
|
|
|
|
my $remote = IO::Socket::SSL->new( Proto => "tcp", PeerAddr => $ENV{MASTER}, PeerPort => $port, );
|
2009-06-05 13:53:52 +00:00
|
|
|
unless ($remote) {
|
2012-05-15 03:37:12 +00:00
|
|
|
`logger -t xCAT -p local4.err "startsyncfiles: Cannot connect to host $ENV{MASTER}"`;
|
2009-06-05 13:53:52 +00:00
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2009-07-15 13:08:51 +00:00
|
|
|
# Send Syncing File request to the xcatd
|
|
|
|
print $remote "<xcatrequest>\n";
|
|
|
|
print $remote " <command>syncfiles</command>\n";
|
|
|
|
print $remote "</xcatrequest>\n";
|
|
|
|
|
|
|
|
|
|
|
|
my $response='';
|
|
|
|
my $rsp;
|
2011-02-28 07:33:57 +00:00
|
|
|
my $rc = 0;
|
2009-07-15 13:08:51 +00:00
|
|
|
while (<$remote>) {
|
|
|
|
$response .= $_;
|
|
|
|
if ($response =~ m/<\/xcatresponse>/) {
|
|
|
|
$rsp = eval { XMLin($response,SuppressEmpty=>undef,ForceArray=>1) };
|
|
|
|
|
2010-08-18 03:21:19 +00:00
|
|
|
if ($rsp->{errorcode}) {
|
|
|
|
$rc = $rsp->{errorcode}[0];
|
|
|
|
} elsif ($rsp->{error}) {
|
|
|
|
$rc = $rsp->{error}[0];
|
2009-07-15 13:08:51 +00:00
|
|
|
}
|
2011-04-21 09:49:40 +00:00
|
|
|
if ($rsp->{serverdone}) {
|
|
|
|
close $remote;
|
|
|
|
if ($rc) { $rc = 1; }
|
|
|
|
exit $rc;
|
|
|
|
}
|
|
|
|
|
2009-07-15 13:08:51 +00:00
|
|
|
$response='';
|
2009-06-05 13:53:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-15 13:08:51 +00:00
|
|
|
close $remote;
|
|
|
|
exit 0;
|
2009-06-05 13:53:52 +00:00
|
|
|
|