Search code examples
pythoncitrixnetscaler

Citrix Nitro API for Netscaler - Enable and Disable server nodes in a service group


I have recently started working with the Nitro API with Python. In order to add some scalability to the Netscaler, I need to be able to add enabling and disabling of the server nodes in a service group. The code below was my attempt at achieving this:

def disable_servicegroup_server_binding(session):
try:


    service_group_service_group_member_binding_obj = {}
    service_group_service_group_member_binding_obj['servicegroupname'] = "testingGroup2"
    service_group_service_group_member_binding_obj['servername'] = "Server1"
    service_group_service_group_member_binding_obj['port'] = 80
    #service_group_service_group_member_binding_obj['delay'] = 30
    #service_group_service_group_member_binding_obj['graceful'] = "YES"

    response = post(session, "disable", "servicegroup_servicegroupmember_binding", service_group_service_group_member_binding_obj)

But when I run this code, it says "This resource already exists". It seems as if it's trying to create a new binding between the server and service group, rather than disabling the server. The 'delay' and 'graceful' attributes are not found even though they are shown in "servicegroup_servicegroupmember_binding" in the nitro library (so that's just temporarily commented out).

Does anyone happen to know of a way to get this disabling to work properly? The only work around I can think of is deleting the binding, then creating a new one with "enabled" or "disabled" set already, but this would be a poor solution because disabling would not be able to add the graceful shutdown.

Thanks all


Solution

  • Someone happened to post the same question in the Nitro API forums. In case anyone happens to need to accomplish the same thing, the answer can be found here:

    http://discussions.citrix.com/topic/364429-nitro-sdk-disable-servicegroupmember/