Forum Discussion
Add allowed VLAN to Virtual Server - Python F5-SDK
I'm trying to set the allowed vlan on a virtual server using the Python SDK.
Here's my code
newvs = vs.virtual.create(name='myvs', destination='10.0.0.1:80')
newvs.mask = '255.255.255.255'
newvs.pool = 'mypool'
newvs.vlansDisabled = False
newvs.vlansEnabled = True
newvs.vlan = 'myvlan'
newvs.update()
The script runs successfully but the vlan is not added to the allowed vlan list.
If I add the vlan manually via the config utility and browse the API I noticed the vlan option uses square brackets [].
vlans: [ "/Common/myvlan" ]
Please advise. 🙂
- Joel_Breton
Nimbostratus
After a few hours of troubleshooting I found the solution.
newvs.vlans = ['myvlan']
- Joel_Breton
Nimbostratus
I would advise against using an absolute update on a BIG-IP object as this activates the custom checkbox for every setting - unless this is your intent
Instead of
newvs = vs.virtual.create(name='myvs', destination='10.0.0.1:80') newvs.mask = '255.255.255.255' newvs.update()
Use this approach
newvs = vs.virtual.create(name='myvs', destination='10.0.0.1:80') newvs.update(mask='255.255.255.255')
Recent Discussions
Related Content
* 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