Pycontrol 2 - issue disabling nodes

Created a script via python to disable nodes, and nodes are not being disabled. Script & log included. Any suggestions would be apperciated.

Script:

import sys

import pycontrol.pycontrol as pc

import time

import csv

import logging

logging.basicConfig(level=logging.INFO)

logging.getLogger(‘suds.client’).setLevel(logging.DEBUG)

b = pc.BIGIP(

hostname = ‘xx.xx.xx.xx’,

username = ‘xxxxx’,

password = ‘xxxxx’,

fromurl = True,

wsdls = [‘LocalLB.NodeAddress’])

def enable_node():

enable_disable_node(‘STATE_ENABLED’)

def disable_node():

enable_disable_node(‘STATE_DISABLED’)

def enable_disable_node(target_state):

nodes = ‘xx.xx.xx.xx’

states = []

states.append(target_state)

b.LocalLB.NodeAddress.set_session_enabled_state(node_addresses=nodes, states=states)

disable_node()

Respose:

DEBUG:suds.client:sending to (https://xx.xx.xx.xx/iControl/iControlPortal.cgi)

message:

xx.xx.xx.xx

STATE_DISABLED

DEBUG:suds.client:headers = {‘SOAPAction’: u’“urn:iControl:LocalLB/NodeAddress”', ‘Content-Type’: ‘text/xml; charset=utf-8’}

DEBUG:suds.client:http succeeded:

DEBUG:suds.client:sending to ()

message:

http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0=“urn:iControl:LocalLB/NodeAddress” xmlns:ns1=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ns2=“http://schemas.xmlsoap.org/soap/encoding/” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/” SOAP-ENV:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”>

xx.xx.xx.xx

STATE_DISABLED

DEBUG:suds.client:headers = {‘SOAPAction’: u’“urn:iControl:LocalLB/NodeAddress”', ‘Content-Type’: ‘text/xml; charset=utf-8’}

DEBUG:suds.client:http succeeded:

xmlns:E=“http://schemas.xmlsoap.org/soap/envelope/”

xmlns:A=“http://schemas.xmlsoap.org/soap/encoding/”

xmlns:s=“http://www.w3.org/2001/XMLSchema-instance”

xmlns:y=“http://www.w3.org/2001/XMLSchema”

xmlns:iControl=“urn:iControl”

E:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”>

xmlns:m=“urn:iControl:LocalLB/NodeAddress”>

your code appears to work for me, however, the monitor state and the session state need to be disabled. Also, this interface is deprecated, so if you are on v11+, please use the NodeAddressV2 interface instead.

>>> na = b.LocalLB.NodeAddress
>>> def enable_node():
...     enable_disable_node('STATE_ENABLED')
... 
>>> def disable_node():
...     enable_disable_node('STATE_DISABLED')
... 
>>> def enable_disable_node(target_state):
...     nodes = ['10.10.10.10']
...     states = []
...     states.append(target_state)
...     na.set_session_enabled_state(nodes=nodes, states = states)
...     
>>> 
>>> def enable_disable_node(target_state):
...     nodes = ['10.10.10.10']
...     states = []
...     states.append(target_state)
...     na.set_session_enabled_state(node_addresses = nodes, states = states)
...     na.set_monitor_state(node_addresses = nodes, states = states)
... 
>>> enable_node()
>>> na.get_monitor_status(node_addresses = ['10.10.10.10'])
[MONITOR_STATUS_UNCHECKED]
>>> na.get_session_status(node_addresses = ['10.10.10.10'])
[SESSION_STATUS_ENABLED]
>>> disable_node()
>>> na.get_monitor_status(node_addresses = ['10.10.10.10'])
[MONITOR_STATUS_FORCED_DOWN]
>>> na.get_session_status(node_addresses = ['10.10.10.10'])
[SESSION_STATUS_FORCED_DISABLED]

Jason, I was doing disabling both in a prior example and removed the monitor state since I thought there was something wrong with my code. I used the NodeAddressV2 and it is now working. Thanks for the help.

~Jon