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) {
|
|
|
|
`logger -t xCAT "startsyncfiles: Cannot connect to host $ENV{MASTER}"`;
|
|
|
|
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;
|
2010-08-18 03:21:19 +00:00
|
|
|
my $rc;
|
2009-07-15 13:08:51 +00:00
|
|
|
while (<$remote>) {
|
|
|
|
$response .= $_;
|
|
|
|
if ($response =~ m/<\/xcatresponse>/) {
|
|
|
|
$rsp = eval { XMLin($response,SuppressEmpty=>undef,ForceArray=>1) };
|
|
|
|
if ($rsp->{serverdone}) {
|
|
|
|
close $remote;
|
2010-08-18 03:21:19 +00:00
|
|
|
exit !$rc;
|
2009-07-15 13:08:51 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
$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
|
|
|
|