# Can only disable a node, not enable.

**URL:** <https://community.f5.com/t/can-only-disable-a-node-not-enable/39829>\
**Category:** Technical Forums\
**Tags:** icontrol, dev, devops\
**Created:** [June 20, 2013, 8:42pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829 "2013-06-20T20:42:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_82142](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chris\_82142](https://community.f5.com/u/Chris_82142)\
**Post date:** [June 20, 2013, 8:42pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/1 "2013-06-20T20:42:20Z")

</div>

Hello Everyone,

I am trying to use Pycontrol V2.0 to enable and disable a node:

!/bin/python

import sys

import pycontrol.pycontrol as pc

import suds

b = pc.BIGIP(

hostname = “LTM”,

username = “Uname”,

password = "Pword ",

fromurl = True,

wsdls = [‘LocalLB.NodeAddressV2’])

nodes = [‘1.2.3.4’]

state = [‘1’]

b.LocalLB.NodeAddressV2.set\_session\_enabled\_state(nodes, state)

Regardless of what number I enter for “state” the node will disable but not enable. I feel I am overlooking something very simple and am unsure how to contrust “state”. Could someone please explain what I am overlooking of provide an example (preferably in Python)

Thanks!

---

<div class="post-metadata">

**Author:** ![mhite\_60883](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mhite\_60883](https://community.f5.com/u/mhite_60883)\
**Post date:** [June 20, 2013, 11:07pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/2 "2013-06-20T23:07:26Z")

</div>

Might want to use the typefactory to create the enabled state argument.

Also, if you want to avoid all the typefactory stuff, you should probably look at moving over to ‘bigsuds’ which is the replacement for pycontrol.

---

<div class="post-metadata">

**Author:** ![Chris\_82142](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chris\_82142](https://community.f5.com/u/Chris_82142)\
**Post date:** [June 21, 2013, 2:09pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/3 "2013-06-21T14:09:04Z")

</div>

Yes, the type factory is a pain and I still don’t quite understand it. Is there a resource for bigsuds that will show me how to do this?

Thanks!

---

<div class="post-metadata">

**Author:** ![mhite\_60883](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mhite\_60883](https://community.f5.com/u/mhite_60883)\
**Post date:** [June 21, 2013, 4:11pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/4 "2013-06-21T16:11:16Z")

</div>

The good news about bigsuds is that you don’t have to deal with the typefactory stuff or WSDLs. With pycontrol, you do.

Here’s information on bigsuds:

> **[DevCentral](https://community.f5.com/)**
>
> DevCentral is an online technical community where engineers and practitioners collaborate, share knowledge, and solve problems related to F5 technologies and industry trends.

More about the typefactory stuff:

> **[DevCentral](https://community.f5.com/)**
>
> DevCentral is an online technical community where engineers and practitioners collaborate, share knowledge, and solve problems related to F5 technologies and industry trends.

If you really want to do this with pycontrol, try adding this:

```tcl
enabledstate = b.LocalLB.NodeAddressV2.typefactory.create('Common.EnabledState')
    enabledstateseq = b.LocalLB.NodeAddressV2.typefactory.create('Common.EnabledStateSequence')
    enabledstateseq.item = enabledstate.STATE_ENABLED
    b.LocalLB.NodeAddressV2.set_session_enabled_state(nodes, enabledstateseq)

```

… or something like that.

However, I highly suggest using bigsuds as it is far more approachable.

I’m sure I’ll also be telling you to start using the new 11.4 REST API sooner or later, too. 😉

Good luck,

-M

---

<div class="post-metadata">

**Author:** ![mhite\_60883](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mhite\_60883](https://community.f5.com/u/mhite_60883)\
**Post date:** [June 21, 2013, 4:12pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/5 "2013-06-21T16:12:14Z")

</div>

And if you want to disable, use STATE\_DISABLED in the typefactory.

---

<div class="post-metadata">

**Author:** ![Chris\_82142](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chris\_82142](https://community.f5.com/u/Chris_82142)\
**Post date:** [June 21, 2013, 7:19pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/6 "2013-06-21T19:19:34Z")

</div>

Thanks a lot! I switched over to Big Suds and you’re right. It’s so much easier!

```tcl
!/bin/python
import suds
import bigsuds

nodes = ['IP']
b = bigsuds.BIGIP(hostname = 'IP',
      username = "Uname",
      password = "Pword",)

disable = ["STATE_DISABLED"]
enable = ["STATE_ENABLED"]
status = b.LocalLB.NodeAddressV2.set_session_enabled_state(nodes, disable)

```

---

<div class="post-metadata">

**Author:** ![mhite\_60883](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mhite\_60883](https://community.f5.com/u/mhite_60883)\
**Post date:** [June 21, 2013, 8:50pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/7 "2013-06-21T20:50:52Z")

</div>

Glad it’s working better for you! Good luck.

-M

---

<div class="post-metadata">

**Author:** ![msaunders](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@msaunders](https://community.f5.com/u/msaunders)\
**Post date:** [November 8, 2018, 2:14pm UTC](https://community.f5.com/t/can-only-disable-a-node-not-enable/39829/8 "2018-11-08T14:14:12Z")

</div>

I got errors from all of the above methods. This works for me.

```tcl
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

WhichLTM = '192.168.1.100'
LTMUser = 'admin'
LTMPass = 'admin'
PoolName = 'test.domain.com_pool'
NodePort = '1.2.3.4:80'
Partition = 'Common'

def DisablePoolMember(WhichLTM, LTMUser, LTMPass, PoolName, Partition, NodePort):
    headers = {'Content-Type': 'application/json',}
    data = '{"session":"user-disabled"}'
    response = requests.put('https://' + WhichLTM + '/mgmt/tm/ltm/pool/' + PoolName + '/members/~' + Partition + '~' + NodePort, headers=headers, data=data, verify=False, auth=(LTMUser, LTMPass))

def EnablePoolMember(WhichLTM, LTMUser, LTMPass, PoolName, Partition, NodePort):
    headers = {'Content-Type': 'application/json',}
    data = '{"session":"user-enabled"}'
    response = requests.put('https://' + WhichLTM + '/mgmt/tm/ltm/pool/' + PoolName + '/members/~' + Partition + '~' + NodePort, headers=headers, data=data, verify=False, auth=(LTMUser, LTMPass))

DisablePoolMember(WhichLTM, LTMUser, LTMPass, PoolName, Partition, NodePort)

```
