Forum Discussion
Assign an existing Security Policy through Python SDK
Can I assign to an Existing Virtual Server an existing Security Policy? Not a local Traffic Policy, I have already created a Automatic Security Policy through the Deployment Wizard but I would like to automate the process through a Python Script. Thanks in advance.
- Dennis_18897Nimbostratus
Hi Dani,
Just spent some time digging into this ... was quite painful. Here is a very basic and rudimentary code snippet on how to modify the virtual server assignment for a given security policy. Aka you can add or remove servers as you see fit:
from f5.bigip import ManagementRoot mgmt = ManagementRoot('ip', 'user', 'pass') policies = mgmt.tm.asm.policies_s.get_collection() policy = [p for p in policies if p.fullPath == '/partition/name'][0] policy.modify(**{'virtualServers': []})
If you want to modify other parameters of the security policy you have to use tasks to apply them.
HTH, Dennis
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