Forum Discussion

Chanan_Berler_3's avatar
Chanan_Berler_3
Icon for Nimbostratus rankNimbostratus
Feb 08, 2017

Add rule to vs using Python SDK

I have create a new rule X-Forward and now need to attach it to a virtual server using python SDK

 

Q: can someone share an example? thanks

 

1 Reply

  • Jason_Cohen_417's avatar
    Jason_Cohen_417
    Historic F5 Account

    Are you simply adding an X-Forwarded-For header? If that is all you are doing, you could probably do that with a setting in the HTTP profile.

    However, for the sake of answering the "attach a rule" question, this answer may have the information you are looking for.

    https://devcentral.f5.com/questions/python-sdk-assign-irules-to-a-virtual-server-51173

    Copied here for simplicity.

    >>> vip = b.tm.ltm.virtuals.virtual.load(name='testvip')
    >>>vip.rules
    [u'/Common/tcptest'] 
    >>> vip.rules = ['/Common/tcptest', '/Common/platform_info']
    >>> vip.update()
    >>vip.rules
    [u'/Common/tcptest', u'/Common/platform_info']