A simple library to control Citrix Netscaler 9.2+ with NITRO API.
Project description
###############################################################################
# TODO
# 1. Right now setup.py install creates an extra nsnitro.py along with the folder nsnitro. This creates trouble when running from nsnitro import *
###############################################################################
Simple Python Library to control Citrix Netscaler 9.2+ load balancers with NITRO API.
What we're trying here is implement Citrix NITRO API SDK (that's available for Java and C#) in Python.
You can find simple command-line interface using this library in contrib/.
Feedback/comments welcome.
Very basic usage:
import time
from nsnitro.nsresources.nslbvserverservicebinding import NSLBVServerServiceBinding
from nsnitro.nsresources.nslbvserver import NSLBVServer
from nsnitro.nsresources.nsserver import NSServer
from nsnitro.nsnitro import *
import nsnitro.nsutil
from nsnitro.nsresources.nsservice import NSService
nitro = NSNitro('localhost', 'api_user', 'api_user')
nitro.login()
# add server test
addserver = NSServer()
addserver.set_name("mp-nitroserver")
addserver.set_ipaddress("10.32.110.99")
NSServer.add(nitro, addserver)
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
# disable server test
server = NSServer()
server.set_name("mp-nitroserver")
NSServer.disable(nitro, server)
time.sleep(2)
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
# enable server test
server = NSServer()
server.set_name("mp-nitroserver")
NSServer.enable(nitro, server)
time.sleep(2)
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
# add service test
addservice = NSService()
addservice.set_name("aurora_testnitroadd")
addservice.set_servername("mp-nitroserver")
addservice.set_servicetype("HTTP")
addservice.set_port(11111)
NSService.add(nitro, addservice)
# add lbvserver test
lbvserver = NSLBVServer()
lbvserver.set_name("nitro_lbvserver_test")
lbvserver.set_ipv46("10.32.110.55")
lbvserver.set_port(11111)
lbvserver.set_clttimeout(180)
lbvserver.set_persistencetype("NONE")
lbvserver.set_servicetype("HTTP")
NSLBVServer.add(nitro, lbvserver)
#
print "LB vserver added"
# bind service to lbvserver test
lbbinding = NSLBVServerServiceBinding()
lbbinding.set_name("nitro_lbvserver_test")
lbbinding.set_servicename("aurora_testnitroadd")
lbbinding.set_weight(40)
NSLBVServerServiceBinding.add(nitro, lbbinding)
print "Binding added"
lbbinding = NSLBVServerServiceBinding()
lbbinding.set_name("nitro_lbvserver_test")
lbbindings = NSLBVServerServiceBinding.get(nitro, lbbinding)
for lbb in lbbindings:
print "sgn: " + lbb.get_servicegroupname()
# delete binding test
lbbinding = NSLBVServerServiceBinding()
lbbinding.set_name("nitro_lbvserver_test")
lbbinding.set_servicename("aurora_testnitroadd")
NSLBVServerServiceBinding.delete(nitro, lbbinding)
print "Binding removed"
# delete lbvserver test
lbvserver = NSLBVServer()
lbvserver.set_name("nitro_lbvserver_test")
NSLBVServer.delete(nitro, lbvserver)
# get service test
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
print service.get_name() + ": %s %s" % (service.get_port(), service.get_useproxyport())
#update service test
updateservice = NSService()
updateservice.set_name("aurora_testnitroadd")
updateservice.set_comment("test comment")
updateservice.set_useproxyport("NO")
NSService.update(nitro, updateservice)
# get service test
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
print service.get_name() + ": %s %s %s" % (service.get_port(), service.get_comment(), service.get_useproxyport())
# disable service test
disservice = NSService()
disservice.set_name("aurora_testnitroadd")
NSService.disable(nitro, disservice)
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
# enable service test
enservice = NSService()
enservice.set_name("aurora_testnitroadd")
NSService.enable(nitro, enservice)
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
# rename service test
renservice = NSService()
renservice.set_name("aurora_testnitroadd")
renservice.set_newname("aurora_testnitroadd_rename")
NSService.rename(nitro, renservice)
# rename service back test
renservice = NSService()
renservice.set_name("aurora_testnitroadd_rename")
renservice.set_newname("aurora_testnitroadd")
NSService.rename(nitro, renservice)
# delete service test
delservice = NSService()
delservice.set_name("aurora_testnitroadd")
NSService.delete(nitro, delservice)
try:
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
except nsnitro.nsutil.NSNitroError, e:
print e.message
# delete server test
delserver = NSServer()
delserver.set_name("mp-nitroserver")
NSServer.delete(nitro, delserver)
try:
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
except nsnitro.nsutil.NSNitroError, e:
print e.message
# TODO
# 1. Right now setup.py install creates an extra nsnitro.py along with the folder nsnitro. This creates trouble when running from nsnitro import *
###############################################################################
Simple Python Library to control Citrix Netscaler 9.2+ load balancers with NITRO API.
What we're trying here is implement Citrix NITRO API SDK (that's available for Java and C#) in Python.
You can find simple command-line interface using this library in contrib/.
Feedback/comments welcome.
Very basic usage:
import time
from nsnitro.nsresources.nslbvserverservicebinding import NSLBVServerServiceBinding
from nsnitro.nsresources.nslbvserver import NSLBVServer
from nsnitro.nsresources.nsserver import NSServer
from nsnitro.nsnitro import *
import nsnitro.nsutil
from nsnitro.nsresources.nsservice import NSService
nitro = NSNitro('localhost', 'api_user', 'api_user')
nitro.login()
# add server test
addserver = NSServer()
addserver.set_name("mp-nitroserver")
addserver.set_ipaddress("10.32.110.99")
NSServer.add(nitro, addserver)
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
# disable server test
server = NSServer()
server.set_name("mp-nitroserver")
NSServer.disable(nitro, server)
time.sleep(2)
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
# enable server test
server = NSServer()
server.set_name("mp-nitroserver")
NSServer.enable(nitro, server)
time.sleep(2)
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
# add service test
addservice = NSService()
addservice.set_name("aurora_testnitroadd")
addservice.set_servername("mp-nitroserver")
addservice.set_servicetype("HTTP")
addservice.set_port(11111)
NSService.add(nitro, addservice)
# add lbvserver test
lbvserver = NSLBVServer()
lbvserver.set_name("nitro_lbvserver_test")
lbvserver.set_ipv46("10.32.110.55")
lbvserver.set_port(11111)
lbvserver.set_clttimeout(180)
lbvserver.set_persistencetype("NONE")
lbvserver.set_servicetype("HTTP")
NSLBVServer.add(nitro, lbvserver)
#
print "LB vserver added"
# bind service to lbvserver test
lbbinding = NSLBVServerServiceBinding()
lbbinding.set_name("nitro_lbvserver_test")
lbbinding.set_servicename("aurora_testnitroadd")
lbbinding.set_weight(40)
NSLBVServerServiceBinding.add(nitro, lbbinding)
print "Binding added"
lbbinding = NSLBVServerServiceBinding()
lbbinding.set_name("nitro_lbvserver_test")
lbbindings = NSLBVServerServiceBinding.get(nitro, lbbinding)
for lbb in lbbindings:
print "sgn: " + lbb.get_servicegroupname()
# delete binding test
lbbinding = NSLBVServerServiceBinding()
lbbinding.set_name("nitro_lbvserver_test")
lbbinding.set_servicename("aurora_testnitroadd")
NSLBVServerServiceBinding.delete(nitro, lbbinding)
print "Binding removed"
# delete lbvserver test
lbvserver = NSLBVServer()
lbvserver.set_name("nitro_lbvserver_test")
NSLBVServer.delete(nitro, lbvserver)
# get service test
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
print service.get_name() + ": %s %s" % (service.get_port(), service.get_useproxyport())
#update service test
updateservice = NSService()
updateservice.set_name("aurora_testnitroadd")
updateservice.set_comment("test comment")
updateservice.set_useproxyport("NO")
NSService.update(nitro, updateservice)
# get service test
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
print service.get_name() + ": %s %s %s" % (service.get_port(), service.get_comment(), service.get_useproxyport())
# disable service test
disservice = NSService()
disservice.set_name("aurora_testnitroadd")
NSService.disable(nitro, disservice)
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
# enable service test
enservice = NSService()
enservice.set_name("aurora_testnitroadd")
NSService.enable(nitro, enservice)
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
# rename service test
renservice = NSService()
renservice.set_name("aurora_testnitroadd")
renservice.set_newname("aurora_testnitroadd_rename")
NSService.rename(nitro, renservice)
# rename service back test
renservice = NSService()
renservice.set_name("aurora_testnitroadd_rename")
renservice.set_newname("aurora_testnitroadd")
NSService.rename(nitro, renservice)
# delete service test
delservice = NSService()
delservice.set_name("aurora_testnitroadd")
NSService.delete(nitro, delservice)
try:
service = NSService()
service.set_name("aurora_testnitroadd")
service = service.get(nitro, service)
print service.get_name() + ": " + service.get_svrstate()
except nsnitro.nsutil.NSNitroError, e:
print e.message
# delete server test
delserver = NSServer()
delserver.set_name("mp-nitroserver")
NSServer.delete(nitro, delserver)
try:
server = NSServer()
server.set_name("mp-nitroserver")
server = server.get(nitro, server)
print server.get_name() + ": " + server.get_state()
except nsnitro.nsutil.NSNitroError, e:
print e.message
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
nsnitro-1.0.5-py2.7.egg
(182.6 kB
view details)
File details
Details for the file nsnitro-1.0.5.macosx-10.7-intel.tar.gz
.
File metadata
- Download URL: nsnitro-1.0.5.macosx-10.7-intel.tar.gz
- Upload date:
- Size: 146.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f941ff82799d40d09d233e2a56a54f65c4cd0d13662b6befa5ce69ccd2b5983 |
|
MD5 | bd29f9f66b19fd183cb24bbb49528a37 |
|
BLAKE2b-256 | b3d35c7e29c9790ce4acd3a9fdba0a895615bd8fae97e9b3cab09d7b0a70621e |
File details
Details for the file nsnitro-1.0.5-py2.7.egg
.
File metadata
- Download URL: nsnitro-1.0.5-py2.7.egg
- Upload date:
- Size: 182.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d0ca023b59861c366114aded458cad41c9f0ab820146bbd9efaaa6f6a3e502c |
|
MD5 | d7d890ae16f0e1fe4f1c21496cd1d204 |
|
BLAKE2b-256 | cf1d8e715abc64ff01edccd5c89001ef54d2bff1a0fe560b95b7dcf875f203ce |