Forum Discussion

Mark_Saunders_1's avatar
Mark_Saunders_1
Icon for Altostratus rankAltostratus
Jun 22, 2016

Adding nodes to LTM with iRest::Client

I have been able to add VIPs and Pools, but not having success adding nodes. I know I'm close. Any clue what I'm missing? I know the various values are getting to the function. I believe the issue is with the function. Any help is appreciated, Thanks. Here's my sample code:

 

!/usr/bin/perl

use REST::Client;

 

use MIME::Base64;

 

use JSON;

 

$F5User='username';

 

$F5Pass='password';

 

$User='jsmith';

 

$LTM="ltm.domain.com";

 

$PoolMember1 = "172.22.99.100";

 

$PoolMember2 = "172.22.99.101";

 

$ConnectionLimit1 = "0";

 

$ConnectionLimit2 = "0";

 

$Ratio1 = "1";

 

$Ratio2 = "1";

 

$Ticket = "11-123";

 

my $bigip = REST::Client->new();

 

$bigip->addHeader('Content-Type', 'application/json');

 

$bigip->addHeader('Authorization', 'Basic ' . encode_base64($F5User . ':' . $F5Pass));

 

$bigip->setHost('https://' . $LTM . '/mgmt/tm');

 

$NODE_STRING = "$PoolMember1:$ConnectionLimit1:$Ratio1,$PoolMember2:$ConnectionLimit2:$Ratio2";

 

@NODE_MEMBERS = split(',',$NODE_STRING);

 

&create_node($bigip, $User, [@NODE_MEMBERS], $Ticket);

 

sub create_node {

 

my ($bigip, $User, $name, $Ticket) = @_;

$now = localtime();

 convert member format
foreach $node(@$name) {
    ($address, $ConnectionLimit, $Ratio) = split(':',$node);

 define node properties
my %payload;
$payload{'kind'} = 'tm:ltm:node:nodestate';
$payload{'name'} = $address;
$payload{'description'} = 'Created by: ' . $User . ' via web page on ' . $now . ' as per ' . $Ticket;
$payload{'connectionLimit'} = $ConnectionLimit;
$payload{'ratio'} = $Ratio;
my $json = encode_json \%payload;
$bigip->POST('ltm/node', $json);
                    }  End foreach $node
          }  End create_node

1 Reply

  • hello, you just forget the / in the POST

    $bigip->POST('/ltm/node', $json);
    

    don 't hesitate to echo response to see what is the problem :

    print $bigip->responseContent;