• Home
  • Podcast
  • Contact
Ervik.as
Cloud, Cyber Security, EUC, DaaS and HCI
  • Cloud
    • Azure
    • Citrix Cloud
    • Cloud Management
    • Nutanix Clusters
  • Cyber Security
    • Arctic Wolf
    • Cyber Security News
  • EUC
    • Citrix
      • Citrix Analytics
      • Citrix NetScaler
      • Citrix Provisioning
      • Receiver
      • ShareFile
      • Citrix Virtual Apps (XenApp)
      • Citrix Virtual Desktops (XenDesktop)
      • Workspace
      • Workspace app
    • DaaS
      • Azure Virtual Desktop
      • Frame
    • Microsoft
      • HoloLens
      • Microsoft App-V
      • Remote Desktop Services
      • Windows 7
      • Windows 8
      • Windows 10
      • Windows Server 2008
      • Windows Server 2008 R2
      • Windows Server 2012
      • Windows Server 2012 R2
      • Windows Server 2016
    • Thin Clients
      • Igel
      • Wyse
    • VMware
      • Fusion
      • Horizon View
      • Vmware ThinApp
      • Vmware Workstation
    • Parallels
      • Remote Application Server
  • End User Experience
    • ControlUp
    • eG Innovations
    • Goliath Technologies
    • Liquidware
  • Datacenter
    • Backup & Disaster Recovery
      • Altaro
      • HYCU
      • Unitrends
      • Rubrik
      • Veeam Software
    • Containers
      • Docker
      • Red Hat OpenShift
    • Hybrid Multi Cloud
      • Nutanix
        • Nutanix Database Service
        • Files
        • Flow
        • Nutanix AHV
        • Nutanix Cloud Platform
    • Server Virtualization
      • Nutanix AHV
      • Microsoft Hyper-V
      • VMware vSphere
      • Citrix Hypervisor (XenServer)
    • Network & Security
      • Nutanix Flow
      • Palo Alto Networks
  • About
    • Cookie Policy (EU)
    • News
      • Citrix Community News

NetScaler

How to get information from the Netscaler using Python and Suds

Alexander Ervik Johnsen Citrix, NetScaler, Python, suds 2010-02-09

Citrix has a ton of documentation for Perl/C/C# and Java ( None for Python ). SOAP client support has not been the best for Python, but is getting better.
If you have soappy/ZSI, which have had issues with regards to consuming Broken WSDL files ( Having to fix the Broken WSDL file manually, SUCKS!).

Enter SUDS. This module is by far, the best SOAP client for Python.
There documentation is simple and straight to the point, with a bunch of nice samples to get you on your way.

Install SUDS before proceeding further. You can get suds from here. https://fedorahosted.org/suds/

Connection to my netscaler was as simple as this…

Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from suds.client import Client
>>> url = "https://nsip/api/NSConfig.wsdl"
>>> from suds.xsd.doctor import *
>>> imp = Import('https://schemas.xmlsoap.org/soap/encoding/')
>>> imp.filter.add("urn:NSConfig")
>>> d = ImportDoctor(imp)
>>> client = Client(url, doctor=d, location="https://nsip/soap/")
>>> client.service.login(username="login", password="pass")
(simpleResult){
rc = 0
message = "Done"
}
>>>

As you can see above,  here we used the xsd doctor to import Soap encoding URL and added a filter for the Netscaler URN.
If you do not import the SOAP encoding schema, this is the error you will receive..

suds.TypeNotFound: Type not found: ‘(Array, https://schemas.xmlsoap.org/soap/encoding/, )

Once you type the above, you can now run commands in the python shell. for instance…

  • client.service.getlbvserver()
  • client.service.getservice()
  • client.service.getservicegroup()

I am attaching a script that I have written, to get Load Balanced Virtual Servers and its Services and ServiceGroups.
This script can also just list all the Virtual Servers, Services, or Service Groups. Examples below..

python queryns.py -c "ZenossTest2_svc" -n "nsip" -u "login" -p "pass"

Service Name Server Name Status IPAddress Port Protocol
ZenossTest2_svc zenossTest OUT OF SERVICE 192.168.101.221 9090 HTTP

python queryns.py -s foobar_test -n "nsip" -u "login" -p "pass"

Virtual Server State IPAddress Port Protocol
foobar_test UP 192.168.101.19 55555 HTTP

ServiceGroup Name SG State Server Name Status IPAddress Port Protocol
"Foo Bar" ENABLED billyboy UP 192.168.101.31 8080 HTTP
"Foo Bar" ENABLED zenossTest UP 192.168.101.221 8080 HTTP

Service Name Server Name Status IPAddress Port Protocol
ZenossTest2_svc zenossTest OUT OF SERVICE 192.168.101.221 9090 HTTP
------------------------------------------------------------------------------------------------------------------------

All the options are here..

python queryns.py -h
usage: queryns.py [options] arg --username=username --password=password --netscaler=netscalerip

options:
-h, --help show this help message and exit
-n NETSCALER, --netscaler=NETSCALER
Here you will put the netscaler IPAddress or the
netscaler hostname
-u USERNAME, --username=USERNAME
Your username
-p PASSWORD, --password=PASSWORD
Your password
-l LIST, --list=LIST List all the names of the Virtual Servers, Services,
ServiceGroups. Example --list=lbvserver,
--list=service, --list=servicegroup
-s SERVER, --vserver=SERVER
Virtual Server that you want to query. You can choose
a Virtual Server or you can pass all, so you get all
the Virtual Servers and its associated
ServiceGroups or Services. Example....
--vserver="foobar_test" or --vserver="all"
-g SGROUP, --sgroup=SGROUP
ServiceGroup that you want the info from
-c SERVICE, --service=SERVICE
Service that you want the info from

Source

Related Posts

NetScaler /

DoS and RCE Vulnerabilities Exploited in Citrix NetScaler ADC and NetScaler Gateway multiple CVE´s

NetScaler /

Citrix NetScaler is back

NetScaler /

Citrix and FireEye Mandiant Launch Indicator of Compromise Scanner

NetScaler /

Permanent fixes for CVE-2019-19781 – Vulnerability for Citrix ADC versions 11.1 and 12.0

NetScaler /

CVE-2019-19781 – Vulnerability in Citrix Application Delivery Controller and Citrix Gateway

‹ FrontRange Solutions launches Discovery 9› Join Citrix and OK Labs webinar on the Nirvana Phone

Back to Top

Crafted in the land of the Vikings 🇳🇴 by Alexander Ervik Johnsen.
Copyright 2000-2025 - www.ervik.as - All Rights Reserved