Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

[iControl] : Working with partitions/folders

Hi,

I need to manipulate objects (nodes, pools, …) that are located on a partition.

I did read the SDK doc and the following articles:

and ended with the following code:

----8<----

my $Protocol =  'https';        # force it to be secure.
my $sHost =     $conf{f};
my $proxy =     "$Protocol://$sHost/iControl/iControlPortal.cgi";
my $folder = '/UAT';

my $SoapSession = SOAP::Lite
        -> uri('urn:iControl:System/Session')
        -> proxy($proxy);
eval { $SoapSession->transport->http_request->header(
        'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", ''));
};
my $soapResponse = $SoapSession->get_active_folder();
checkResponse($soapResponse);
my $res = $soapResponse->result;
print "get_active_folder before : $res\n";


$soapResponse = $SoapSession->set_active_folder($folder);
checkResponse($soapResponse);   # !!!  I get error here  !!!

$soapResponse = $SoapSession->get_active_folder();
checkResponse($soapResponse);
$res = $soapResponse->result;
print "get_active_folder after : $res\n";

----8<----

Unfortunately, the "set_active_folder" returns the following error:

SOAP-ENV:Server Could not find element by name: folder

The "get_active_folder" method is working fine though.

How is it intended to work ?

Thank you, Best Olivier

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

The code looks fine to me - note that set_active_folder retutrns a void, it does not return a usable code to say whether it has been implemented.

I would hardcode the '/UAT' into the function first, and check again that /UAT exists. Maybe try changing to /Common to check that the function works ok. It's probably something silly, it usually is.

0
Comments on this Answer
Comment made 1 week ago by IT-Network EIB 10

Hi Pete,

Thank you for taking time to investigate. Right, set_active_folder returns void. So I run the following code:

my $folder = '/UAT';
my $soapResponse = $SoapSession->get_active_folder();
checkResponse($soapResponse);
my $res = $soapResponse->result;
print "get_active_folder before : $res\n";
print "folder value : $folder\n";

$soapResponse = $SoapSession->set_recursive_query_state('STATE_ENABLED');
$SoapSession->set_active_folder($folder);

$soapResponse = $SoapSession->get_active_folder();
checkResponse($soapResponse);
$res = $soapResponse->result;
print "get_active_folder after : $res\n";

And I get:

get_active_folder before : /Common
folder value : /UAT
get_active_folder after : /Common

So it doesn't work ;-(

Are you able to make it work on your side ?

Thank you,

Best

Olivier

0
Comment made 1 week ago by Pete White

It works perfectly for me:

#!/usr/bin/env python
import sys
import bigsuds
if len(sys.argv) == 4:
    hostname = sys.argv[1]
    username = sys.argv[2]
    password = sys.argv[3]
else:
    print "Usage:"+str(sys.argv[0])+" Host Username Password"
    sys.exit()

try:
    b = bigsuds.BIGIP(
    hostname = hostname,
    username = username,
    password = password,
    timeout = 90
            )
except Exception, e:
    print e
# Retrieve partitions
b.System.Session.set_active_folder('/')
print "Active Folder: " + (b.System.Session.get_active_folder())
print "Partitions:"+str(b.Management.Folder.get_list())
b.System.Session.set_active_folder('/Student1')
print "Active Folder: " + (b.System.Session.get_active_folder())
print "Partitions:"+str(b.Management.Folder.get_list())


pwhite@CHR-L-PWHITE6 ~
$ ./test_partition 10.154.42.32 admin admin123
Active Folder: /
Partitions:['/Common', '/Student1', '/Student2', '/Student3', '/Student4', '/Student5', '/Student6', '/Student7', '/Student8', '/Student9', '/Student10', '/Student11', '/Student12', '/']
Active Folder: /Student1
Partitions:[]
0
Comment made 1 week ago by Pete White

You may find that your /UAT folder is not present if the set_active_directory method is puking. Check in tmsh first. PM me if you want to go through this in more detail.

0