cancel
Showing results for 
Search instead for 
Did you mean: 

drain a server using a script

SOLVED
xevilstar
Occasional Contributor

drain a server using a script

i am trying to use a perl script to drain a server on my test environment load balancer, the code is this:

#!/usr/bin/perl -w  
use SOAP::Lite 0.60;

my $admin_server = 'https://admin:[email protected]:9090';[email protected]:9090'; 
     
my $conn = SOAP::Lite 
  -> uri('https://admin:[email protected]:9090[email protected]:9090') 
  -> proxy("$admin_server/soap"); 
     
$conn = $conn->addDrainingNodes( ["myNewPool"], [["node.ip:8080"]] );

the script exits with no errors but as I go to the "Draining Nodes" list under "Activity" I cannot see node.ip draining.

where exactly am I failing ?

1 ACCEPTED SOLUTION

Accepted Solutions
markbod
Contributor

Re: Re: drain a server using a script

You seem to be missing a set of square braces in your soap call....


my $res = $conn->addDrainingNodes( [ $poolName ], [[ @theNodes ]] );


This works for me...


#!/usr/bin/perl -w


use SOAP::Lite 0.60;



$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;



# This is the url and password of the ZXTM admin server


my $admin_server = 'https://usernameSmiley Tongue[email protected]:9090';


# The pool to edit, and the nodes to drain


my $poolName = shift @ARGV;


my @theNodes = @ARGV;


# Create the SOAP Connection object


my $conn = SOAP::Lite


-> ns('http://soap.zeus.com/zxtm/1.0/Pool/')


-> proxy("$admin_server/soap")


-> on_fault( sub {


my( $conn, $res ) = @_;


die ref $res?$res->faultstring:$conn->transport->status; } );


# Start the nodes draining


my $res = $conn->addDrainingNodes( [ $poolName ], [[ @theNodes ]] );


Cheers,

Mark

View solution in original post

5 REPLIES 5
xevilstar
Occasional Contributor

Re: drain a server using a script

this script is giving me a "Value isn't an array at ./serverdrain.pl line 14."
error
#!/usr/bin/perl -w
use SOAP::Lite 0.60;
# This is the url and password of the ZXTM admin server
# The pool to edit, and the nodes to drain
my $poolName = shift @ARGV;
my @theNodes = @ARGV;
# Create the SOAP Connection object
my $conn = SOAP::Lite
-> proxy("$admin_server/soap")
-> on_fault( sub {
my( $conn, $res ) = @_;
die ref $res?$res->faultstring:$conn->transport->status; } );
# Start the nodes draining
my $res = $conn->addDrainingNodes( [ $poolName ], [ @theNodes ] );
markbod
Contributor

Re: Re: drain a server using a script

You seem to be missing a set of square braces in your soap call....


my $res = $conn->addDrainingNodes( [ $poolName ], [[ @theNodes ]] );


This works for me...


#!/usr/bin/perl -w


use SOAP::Lite 0.60;



$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;



# This is the url and password of the ZXTM admin server


my $admin_server = 'https://usernameSmiley Tongue[email protected]:9090';


# The pool to edit, and the nodes to drain


my $poolName = shift @ARGV;


my @theNodes = @ARGV;


# Create the SOAP Connection object


my $conn = SOAP::Lite


-> ns('http://soap.zeus.com/zxtm/1.0/Pool/')


-> proxy("$admin_server/soap")


-> on_fault( sub {


my( $conn, $res ) = @_;


die ref $res?$res->faultstring:$conn->transport->status; } );


# Start the nodes draining


my $res = $conn->addDrainingNodes( [ $poolName ], [[ @theNodes ]] );


Cheers,

Mark

xevilstar
Occasional Contributor

Re: Re: drain a server using a script

IT WOOOOOOORKS

thank you

you save my life !!!!!!!!!!!!!!!!!!!!

xevilstar
Occasional Contributor

Re: Re: drain a server using a script

how can I give you points ?

dtoth
New Contributor

Re: Re: drain a server using a script

Hi Renato-

Thanks for marking Mark's response as correct! He received 10 points for his correct response to your question.

Thanks for using Splash!

Dave