Forum Discussion

  • 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