sdk
28 TopicsF5 SDK LTM Policy Listing
Hello, I have been working on a script using the SDK to list a VS configuration, so far so good, however I got stuck with the LTM policy. I got to the nested object of the policy and the rules, however the conditions/actions have been done with (**kwargs), example of the dictionary: {'kind': 'tm:ltm:policy:rules:conditions:conditionsstate', 'name': '0', 'fullPath': '0', 'generation': 125791, 'selfLink': 'https://localhost/mgmt/tm/ltm/policy/~test~policy_test/rules/test/conditions/0?ver=16.1.3.4', 'all': True, 'caseInsensitive': True, 'equals': True, 'external': True, 'httpHost': True, 'index': 0, 'present': True, 'remote': True, 'request': True, 'values': ['test'], '_meta_data': {'container': <f5.bigip.tm.ltm.policy.Conditions_s object at 0x7f8705eb1960>, 'bigip': <f5.bigip.ManagementRoot object at 0x7f870f653bb0>, 'icr_session': <icontrol.session.iControlRESTSession object at 0x7f870f653430>, 'icontrol_version': '', 'minimum_version': '11.5.0', 'allowed_commands': [], 'required_command_parameters': set(), 'exclusive_attributes': [], 'object_has_stats': True, 'minimum_additional_parameters': set(), 'required_creation_parameters': {'name'}, 'required_load_parameters': {'name'}, 'read_only_attributes': [], 'reduction_forcing_pairs': [('enabled', 'disabled'), ('online', 'offline'), ('vlansEnabled', 'vlansDisabled')], 'required_json_kind': 'tm:ltm:policy:rules:conditions:conditionsstate', 'uri': 'https://bigip.example.info:443/mgmt/tm/ltm/policy/~test~policy_test/rules/test/conditions/0/', 'creation_uri_qargs': {'ver': ['16.1.3.4']}, 'creation_uri_frag': '', 'allowed_lazy_attributes': [<class 'f5.bigip.resource.Stats'>]}} TCL BigIP code: rules { test { actions { 0 { forward select pool /test/test } } conditions { 0 { http-host values { test } } } } } Is there a way to get the non-default (**kwargs), the conditions/actions, which are non-default and passed as arguments during the creation? Is it possible to extract something like the GUI: All your help is much appreciated!228Views0likes1Commentpython f5-vserver-tool
Problem this snippet solves: What the tool does: List all virtual server, nodes and pools and their assignment for a big-ip system or device group print sync status of a device group assign a pool for a specific virtual server How to use this snippet: Usage https://github.com/FalcoSuessgott/f5-vserver-tool Print out information List virtual server and their assigned pools and their respective nodes [user@host ~]$ loadbalancer -l Password: Virtual Server Pool Pool member xxx-8010 xxxx 1.1.1.1:100, 1.1.1.1:200 xxx-8020 xxxx 1.1.1.1:100, 1.1.1.1:200 ....` List all virtual server [user@host ~]$ loadbalancer --list-vserver Password: vserver-1 vserver-2 vserver-3 ....` List all pools [user@host ~]$ loadbalancer --list-pools Password: pool-1 pool-2 pool-3 .... List all nodes [user@host ~]$ loadbalancer --list-nodes Password: node1 node2 node3 .... List all virtual server [user@host ~]$ loadbalancer --list-vserver Password: vserver-1 vserver-2 vserver-3 .... Print out sync-status [user@host ~]$ loadbalancer --show-sync-status Password: deviceGroup is currently In Sync Set assign pool1 to vserver1 [user@host ~]$ loadbalancer -s vserver1 pool1 Password: Changing pool for "vserver1" to "pool1" Synchronizing new configuration to device group "devicegroup" devicegroup is In Sync Print out sample config file [user@host ~]$ loadbalancer -m [AUTH] user = "user" password = "password" [BASIC] devicegroup = "devicegroup" loadbalancer = "fqdn" Code : https://github.com/FalcoSuessgott/f5-vserver-tool433Views0likes0CommentsTMSH 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 Expected console output for show CM::Sync Status ---------------------------------------------------------------------------- Color green Status In Sync Summary Details /Common/host1.company.com: connected (for 2548 seconds) /Common/sync-fail-test (In Sync): - all 2 devices consistent /Common/device_trust_group (In Sync): - 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')Solved1.6KViews0likes5CommentsRelease Announcement: F5 Python SDK v1.0.0
Release Announcement 06 July 2016 We are pleased to announce the release of v1.0.0 of the F5 Python SDK.This is the first stable release of the SDK. Summary This release is not backwards compatible because support for aliased resources has been removed. This means that x = y.create(...) no longer changes both x and y . Instead, xis the created configuration object and y is a creation factory. The release also incorporates several important bug-fixes, noted below. Release Highlights The following bug-fixes are included in this release. Most importantly, the SDK now allows a minimum BIG-IP® version of `11.5.0` and has no maximum version. * #523 Add support for ltm.data_group * #491 allows all versions >= 11.5.0 by default * #492 fix the sys ntp resource * #411 calling `create` and `load` on Resources now returns a new instance of the relevant resource (a factory pattern); this fixes an aliasing bug * #497 New API endpoints for GTM datacenters and iRules * This release fixes multiple type-errors in the concrete subclasses. * #533 Turns off `_check_generation` because it is buggy. * #521 migrate clustering to support non-aliased pattern See the changelog for the full list of changes in this release. Open Issues See the project issues pagefor a full list of open issues in this release. - The F5 OpenStack Product Team and F5 Python SDK Contributors555Views0likes4CommentsF5 SDK - backup virtual server config to file
Hi all, I am working to create a script using the python F5-sdk to rollout changes to 200+ VS objects. With the script, I'd like to take a backup config of each VS and save it locally before making my change. Is this possible with the F5 SDK? Reviewing the SDK, it looks like I can get the VS config with: vip_config_backup=b.tm.ltm.virtuals.virtual.load(name='test-2') But saving it to a file is giving me issues. Psudocode below: 1.) Capture VS objects in-scope. 2.) For each VS object: 2a.) Backup the VS object and save to file. 2b.) Apply policy. 2c.) Check VS object to ensure policy was applied successfully. My goal with step 2a is to create additional functionality to restore a backup of just the VS if issues are identified. Thanks!325Views0likes0CommentsF5 Python SDK: How to get virtual server availability?
Due to my limited Python and SDK experience I am finding it difficult to easily obtain the availability state of a virtual server. Given a 'virtual' object, what is the best/easiest way to return the value of that VS' 'Availability' state (offline, available, unknown, etc)? I can do the following: my_virtual = mgmt.tm.ltm.virtuals.virtual.load(name='some_virtual') stats = my_virtual.stats.load() Printing the stats.raw shows that there is a nested dictionary entry keyed 'status.availibityState' that appears to hold the value I'm looking for. Forgive my inexperience, but what is the easiest way to get the availability state of a virtual using the SDK? Perhaps a method I'm missing that retrieves the value above, or the value is easily obtained elsewhere. Appreciate any assitance!2KViews0likes27CommentsCheck if property exists in F5 SDK Python
Hello. After get a virtual server collection, I'm looking for a method to validate if an specific resource property exists, for example pools & rules, which are optional parameters. Next below, three ways with errors: virtuals = session.tm.ltm.virtuals.get_collection() for virtual in virtuals: if virtual.pool != None: print(virtual.pool) --->> AttributeError: '' object has no attribute 'pool' if virtual.get('pool') != None: print(virtual.pool) --->> AttributeError: '' object has no attribute 'get' if virtual['pool'] != None: print(virtual.pool) --->> TypeError: 'Virtual' object is not subscriptable Same way for rules :-S I'm newbie in python. How do you do this in your scenarios? Thanks in advance! KR, Dario.447Views0likes1CommentHow can I list distributed applications using the Python SDK?
I am trying to get a list of distributed applications using the Python SDK. I can do this via REST/Postman by drilling down to /mgmt/tm/gtm/distributed-app. However when I drill down to gtm using the Python SDK, there is no "distributed-app" class to call. I see the following... {'_meta_data': {'container': , 'bigip': , 'icr_session': , 'icontrol_version': '', 'uri': 'https://beiglb1:443/mgmt/tm/gtm/', 'minimum_version': '11.5.0', 'allowed_commands': [], 'required_command_parameters': set(), 'exclusive_attributes': [], 'object_has_stats': True, 'minimum_additional_parameters': set(), 'allowed_lazy_attributes': [, , , , , , , , , ]}} As you can see I can access my wide ips/pools, servers, data_centers, etc... from here just fine, but I cannot see my distributed apps. Any ideas on how to access them via Python SDK, or do I have to use REST?384Views0likes1CommentHow to get bundle certificates subcollection using f5-sdk
Hi, I'm trying to get the content of my certificate bundles using F5-sdk but I cannot find the way to load the subcollection. certificates = b.tm.sys.file.ssl_certs.get_collection() for cert in certificates: if cert.isBundle == 'true': cert_bundle = cert.bundlecertificates_s.get_collection() I get the following error AttributeError: '<class 'f5.bigip.tm.sys.file.Ssl_Cert'>' object has no attribute 'bundlecertificates_s' If I copy the link I get from the attribute bundleCertificatesReference.link of the 'cert' object and access directly the link in a browser, it works. Not sure what I'm doing wrong and would need help. Thanks, Marc427Views0likes2Comments