Forum Discussion
Disable-Enable virtual server using F5 Python SDK
How to disable/enable a virtual server using f5 python sdk ?
I am getting an error 404, cant have disable when enable is present.I did the following tweak (delete enabled dictionary key, if i have to disable) to make it work.
Is it the correct method?, is there a better way ?Before executing the below script, VS was in enabled state
_virtual = g_f5mgmt.tm.ltm.virtuals.virtual.load(partition=_vs_prt_name, name=_vs_name)
_virtual.disabled = True
del _virtual.raw['enabled']
_virtual.update()
After executing the above script, VS is in disabled state
- JRahmAdmin
Hi Saran, I'd recommend something a little simpler:
Load the vip vip = b.tm.ltm.virtuals.virtual.load(name='testvip') Change from enabled to disabled del vip.enabled vip.disabled = True vip.update() Change from disabled to enabled del vip.disabled vip.enabled = True vip.update()
- SaranSakthivelNimbostratus
Thank You Jason,
I watched one of the videos from Agility 2017 'The F5 Python SDK for iControl REST'.
I was interested in the 'reducing Boolean pairs'. I found the following part of the response.'_meta_data': { 'reduction_forcing_pairs': [('enabled', 'disabled'), ('online', 'offline'), ('vlansEnabled', 'vlansDisabled')]
However when i tried the following i get an error. Is 'reducing Boolean pairs' not supported for virtual server configs ?
_virtual = g_f5mgmt.tm.ltm.virtuals.virtual.load(partition=_vs_prt_name, name=_vs_name) print(_virtual.enabled) print(_virtual.disabled) Output: True '' object has no attribute 'disabled'
- JRahmAdmin
This is actually a bug in how the virtual server endpoint was created in the sdk. I've submitted a PR that should merge for the 3.0.10 release next Friday, but you can grab my branch to test now if you like. Once updated, you can simply set the state and update:
From enabled->disabled vip.disabled = True vip.update() From disabled->enabled vip.enabled = True vip.update()
- JRahmAdmin
good call, I didn't even realize that was in there! See my answer below.
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