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

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.

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']