TMSH Command via Python SDK

I was hoping to get some assistance in executing TMSH commands via the Python SDK. From the documentation i can easily execute any BASH command but i’m struggling with TMSH commands.

I need to execute the following including console output.

run /cm config-sync to-group Syncfailover

and slso check the status with

show /cm sync-status

  1. Expected console output for show
  2. CM::Sync Status
  3. ----------------------------------------------------------------------------
  4. Color    green
  5. Status   In Sync
  6. Summary
  7. Details
  8. /Common/host1.company.com: connected (for 2548 seconds)
  9. /Common/sync-fail-test (In Sync):
  10. - all 2 devices consistent
  11. /Common/device_trust_group (In Sync):
  12. - all 2 devices consistent

The Documentation doesn’t really give a noob like me information for achieving above. They only mention a very simple example in saving a config. ie

mgmt.tm.sys.config.exec_cmd('save')

>> Check Sync Status

https://f5-sdk.readthedocs.io/en/latest/\_modules/f5/bigip/tm/cm/sync\_status.html#Sync\_Status

>> Sync To-Group

https://f5-sdk.readthedocs.io/en/latest/\_modules/f5/bigip/tm/cm/device\_group.html#Device\_Group.sync\_to

Hope this helps.

KR,

Dario.

Thank you very much for the effort Dario! I’m going to try and figure something out with my very limited coding skills.

Hello Rudi.

Here an example to get access to the status object

from f5.bigip import ManagementRoot
# ----------------------------------------------------------
session = ManagementRoot("F5_mgmt_IP","username","password",token=True)
status = session.tm.cm.sync_status.load()
print(status.raw)

In general in SDK there are 3 kind of objects, here is some documentation.

Tutorial for accessing

  • Collections
  • Named Resources

REF - https://devcentral.f5.com/s/articles/getting-started-with-the-f5-common-python-sdk-27438

Tutorial for accessing

  • Unnamed Resources

REF - https://devcentral.f5.com/s/articles/getting-started-with-the-python-sdk-part-2-unnamed-resources-and-commands-27602

Hope this helps.

KR,

Dario.

OMW Dario, you are such a life saver!!! I’m going to try this right now! Thanks again for your incredibly valuable input sir!!

You are welcome :wink:

BTW, I would appreciate if you mark the answer as ‘the best’ or give me some upvotes.

KR,

Dario.