Forum Discussion
dani_martinez_2
Nimbostratus
May 28, 2018Assign 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 ...
Dennis_18897
Nimbostratus
Jul 26, 2018Hi 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects