Forum Discussion
Object path for list of partitions in python SDK
Hi all,
I'm trying to get the list of partitions of a BigIP using the f5-Python-SDK. In tmsh, the objects are located under auth/partition, so e.g. "tmsh list auth partition" will list the according configuration.
This is also reflected in iControl REST. Using curl, I can get that list of partitions by using the path /mgmt/tm/auth/partition as follows:
$ curl -sk -u admin:xxxxxxxxxxxx https://my_bigip/mgmt/tm/auth/partition | python -mjson.tool
{
"items": [
{
"defaultRouteDomain": 0,
"description": "Repository for system objects and shared objects.",
"fullPath": "Common",
"generation": 1,
"kind": "tm:auth:partition:partitionstate",
"name": "Common",
"selfLink": "https://localhost/mgmt/tm/auth/partition/Common?ver=11.6.0"
},
{
"defaultRouteDomain": 123,
"fullPath": "my_partition1",
"generation": 1,
"kind": "tm:auth:partition:partitionstate",
"name": "my_partition1",
"selfLink": "https://localhost/mgmt/tm/auth/partition/my_partition1?ver=11.6.0"
},
{
"defaultRouteDomain": 456,
"fullPath": "my_partition2",
"generation": 1,
"kind": "tm:auth:partition:partitionstate",
"name": "my_partition2",
"selfLink": "https://localhost/mgmt/tm/auth/partition/my_partition1?ver=11.6.0"
},
],
"kind": "tm:auth:partition:partitioncollectionstate",
"selfLink": "https://localhost/mgmt/tm/auth/partition?ver=11.6.0"
}
However, when trying to adopt that using the python SDK, I do not get the same results:
>>> from f5.bigip import BigIP
>>> session = BigIP('1.2.3.4', 'admin', 'xxxxxxxxxxxx')
>>> for partition in session.auth.partitions.get_collection():
... print partition.name
...
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/f5_sdk-0.1.5-py2.7.egg/f5/bigip/mixins.py", line 82, in __getattr__
raise AttributeError(error_message)
AttributeError: '' object has no attribute 'auth'
So, .auth.partitions (or .auth generally) does not seem to be the right entry point.
Does anybody know:
-
if there is a comprehensive list of mappings of tmsh / iControl REST / python SDK paths?
-
whether the whole auth tree is still missing in the python modules and will be added later?
-
what is the right way to get a list of partitions using the f5-python-SDK?
Any help is appreciated. Many thanks in advance!
Best regards
Martin
- Arnaud_LemaireEmployee
having a look to the python site-packages/f5 folder you can see all was implemented. for auth, only user and password_policy seem to be available.
until the dev guide/mode doc is done, the easiest way to check is to have a look to this folder.
- tatmotivCirrostratus
I put that into a separate answer for anybody's convenience because formatting in comments sucks. Maybe this will be useful for someone else, too...
Going with the sys/folder resource in order to address this now. However, there are some differences between a system folder and a partition:
- The system folder "/" does not map to any partition
- When polling the system folders via iControl REST, separate folders for iApps are given back, which do not map to any partition. Confusingly, those iApp-folders are not listed when running "tmsh list sys folders" on the machine directly.
You can see what I mean when comparing
curl -sk -u admin:xxxxxxxxx https://my-lb/mgmt/tm/sys/folder | python -mjson.tool | grep name "name": "/", "name": "Common", "name": "backup2.app", <--- ! "name": "backup_scf.app", <--- ! "name": "PA995-LBSS-Test", "name": "PA997-Test1", "name": "PA998-Test2", "name": "PA999-Test1",
to
(/)(tmos) list sys folder | grep folder sys folder / { sys folder Common { sys folder PA995-LBSS-Test { sys folder PA997-Test1 { sys folder PA998-Test2 { sys folder PA999-Test1 {
and
(/)(tmos) list auth partition | grep partition auth partition Common { auth partition PA995-LBSS-Test { auth partition PA997-Test1 { auth partition PA998-Test2 { } auth partition PA999-Test1 {
Putting all of this together, this is basically how to get a list of partitions using the python SDK (at least it works out for me):
>>> list_of_partitions = [] >>> for folder in session.sys.folders.get_collection(): ... if not folder.name == "/" and not folder.name.endswith(".app"): ... list_of_partitions.append(folder.name) ... >>> print list_of_partitions [u'Common', u'PA995-LBSS-Test', u'PA997-Test1', u'PA998-Test2', u'PA999-Test1']
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com