Forum Discussion

Muhammad_64435's avatar
Muhammad_64435
Icon for Nimbostratus rankNimbostratus
Feb 15, 2019

F5-SDK : How to update Virtual Address Traffic Group

I have an Active-Active LTM Deployment. Virtual Servers ( and Virtual Addresses ) are split between two units. I am trying to use F5-SDK to update traffic group so that VS/VA will move between two units.

Vars
BigIP_IP = "10.10.100.100"
V_IP = "172.31.13.151:80"
New_TG = "/Common/traffic-group-2"

Connect
new_mgmt = ManagementRoot(BigIP_IP, username, password)

Load
v_a_info = new_mgmt.tm.ltm.virtual_address_s.load(name=V_IP, partition='Common')

Assign new TG
v_a_info.trafficGroup = New_TG

 Update Virtual Address 
v_a_info.modify(v_a_info.trafficGroup)

But getting this Error :

Traceback (most recent call last):
File "update-virtual-address-traffic-group.py", line 13, in 
v_a_info = new_mgmt.tm.ltm.virtual_address_s.load(name=V_IP, partition='Common')
File "/usr/lib/python3.6/site-packages/f5/bigip/resource.py", line 655, in load
raise InvalidResource(error_message)
f5.sdk_exception.InvalidResource: Only Resources support 'load'.

Then found out that "Virtual Addresses" are "Collections" and I able to read them fine using below command and loop through all attributes of a Virtual Address:

v_a_info = new_mgmt.tm.ltm.virtual_address_s.get_collection()

But then questions comes up how to update an Attribute of a "Virtual Address" in a Collection and push it back to the LTM to implement the change

Versions
F5-SDK : 3.0.20
LTM : 12.1.2 HF2

I highly appreciate any help or link to resolve this issue

-Muhammad

1 Reply

  • Hi Muhammad, virtual_address_s is a collection, you need the resource to load:

    v_a_info = new_mgmt.tm.ltm.virtual_address_s.virtual_address.load(name=V_IP, partition='Common')