This commit is contained in:
deamonkai
2026-01-23 12:11:21 -06:00
commit fc94008530
16494 changed files with 2974672 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
This document provides description for each of the sample files on what they are used for.
* add_mps_ssl_certkey - is used to install SSL Certificate on NetScaler Console using the SSL Key and SSL certificate file.
* add_ntp_server - is used to add a new NTP server and enabling synchronization for the server using ntp_sync resource.ss
* add_snmp_view - is used to create a new snmp view on NetScaler Console. This requires two mandatory parameters namely, snmp view name and valid subtree.
* config_job - is used to create a Configuration Job on NetScaler Console. Particularly, the config job that is created is "show ns config". This job displays the configuration details of the specified NetScaler instance.
* external_auth - is used to add a new LDAP server for external authentication and enabling the server using aaa_server resource.
* get_inventory - is used to perform rediscovery for a device added to the NetScaler Console. It fetches the activity ID of the rediscovery process.
* get_license_file - is used to fetch the details of a license file. It displays file size and file last modified details of the given license file after fecthing. You can modify it to display any other details of the license file.
* get_ns_device_profile - is used to fetch details of a NetScaler device profile. It displays is_default and ID fields of the given NetScaler device profile.
* get_ns_ns_running_config - is used to fetch the running configuration details of a NetScaler instance.
* get_nssdx - is used to get the list of all NetScaler SDX instances managed by NetScaler Console. It diplays name and ID of each SDX instance.
* get_snmp_manager - is used to fetch the details of a particular snmp manager. It displays community and netmask details of the given snmp manager.
* get_snmp_trap - is used to fetch the details of a particular snmp trap. It displays community, version and user_name of the given snmp trap.
* get_stylebooks - is used to get the list of all stylebooks managed. It diplays name and source of each stylebooks.
* get_system_settings - is used to get system settings of the NetScaler Console. It displays svm_ns_comm, session_timeout and id of the NetScaler Console system.
* get_techsupport - is used to fetch the details of a tech support file. It displays mode, fil size and activity id of the given techsupport
* get_traceroute - is used to perform traceroute function for a device associated with the NetScaler Console. It dsiplays the device ip address and status of the traceroute operation for the given device.
* getcount_docker_host - is used to retrieve the count for the number of docker hosts that are associated with NetScaler Console.
* managed_device - is used to perform add, get and delete operation on devices managed by NetScaler Console. It adds a managed device by uploading csv file using add_device operation and deletes a managed device identified by its ID.
* modify_ns_lbvserver - is used to enable/disable a given NetScaler Load Balancing Virtual Server through NetScaler Console.
* mps_data_center - is used to add and delete a datacenter with NetScaler Console. To add a datacenter, name and lat-long values are required and to delete a datacenter, name of the dataceneter is required.
* mps_group - is used to create a new user group on NetScaler Console. Every group has certain permissions and list of users belonging to that group.
* mps_user - is used to update the details of a system user. It updates the password of a user named "nsroot" by first fetching the ID of the user.
* notifications - is used to set the notifications for certain event categories. Different actions can be used to indicate notifications such as send mail, send sms, send trap, run command, execute job, suppress action. The sample code is creating smtp and sms servers and corresponding profiles for setting those as the action for the events DeviceRebootState, DeviceDelete, DeviceChang, UserLogin.sss
* poll_ns_ssl_certkey_policy - is used to poll a NetScaler SSL Certkey policy and update the polling interval of the policy. It displays the poll interval of the policy.
*reboot_ns - is used to reboot an instance identified by the given ID with NetScaler Console.
* system_session - is used to get the details of a user session with NetScaler Console. It displays the session ID and the duration after which the session expires after fetching.
* system_version - is used to get the details of NetScaler Console. It displays the product and build number of the NetScaler Console System.
* track_activity - is used to fetch the details about a particular activity from the NetScaler Console.
* update_prune_policy - is used to modify a particular prune policy. It modifies the "days" field of the prune policy named "mps_policy_prune".
* upload_ns_ssl_cert - is used to upload a NetScaler SSL Certificate on NetScaler Console. It requires certificate filename and file location path.

View File

@@ -0,0 +1,101 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.mps_ssl_certkey import mps_ssl_certkey
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class add_mps_ssl_certkey_class :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = add_mps_ssl_certkey_class()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_mps_ssl_certkey(client)
def add_mps_ssl_certkey(self,client) :
try:
my_mps_ssl_certkey = mps_ssl_certkey()
my_mps_ssl_certkey.ssl_certificate = "giri.cer"
my_mps_ssl_certkey.ssl_key = "giri.key"
mps_ssl_certkey.add(client, my_mps_ssl_certkey)
print "--------------"
print "Response Came :"
print "--------------"
print("add_mps_ssl_certkey - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
add_mps_ssl_certkey_class().main(add_mps_ssl_certkey_class(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,124 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.ntp_server import ntp_server
from massrc.com.citrix.mas.nitro.resource.config.mps.ntp_sync import ntp_sync
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class add_ntp_server :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = add_ntp_server()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_ntp_server(client)
self.enable_ntp_sync(client)
def add_ntp_server(self,client) :
try:
my_ntp_server = ntp_server()
my_ntp_server.server = "204.9.54.119"
my_ntp_server.maxpoll = 10
my_ntp_server.minpoll = 5
my_ntp_server.autokey = True
ntp_server.add(client, my_ntp_server)
print "--------------"
print "Response Came :"
print "--------------"
print("add_ntp_server - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def enable_ntp_sync(self,client) :
try:
my_ntp_sync = ntp_sync()
my_ntp_sync.ntpd_status = True
ntp_sync.update(client, my_ntp_sync)
print "--------------"
print "Response Came :"
print "--------------"
print("enable_ntp_sync - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
add_ntp_server().main(add_ntp_server(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,103 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.snmp_view import snmp_view
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class add_snmp_view :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = add_snmp_view()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_snmp_view(client)
def add_snmp_view(self, client):
try:
snmp_view_obj = snmp_view()
snmp_view_obj.name = "new_view"
snmp_view_obj.subtree = "<subtree>" #Replace <subtree> with Valid value
simplelist = snmp_view.add(client, snmp_view_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("view name: "+simplelist[0].name)
print("subtree :"+simplelist[0].subtree)
print("add_snmp_view - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
add_snmp_view().main(add_snmp_view(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,32 @@
@echo on
python -m py_compile add_mps_ssl_certkey.py
python -m py_compile add_ntp_server.py
python -m py_compile add_snmp_view.py
python -m py_compile config_job.py
python -m py_compile external_auth.py
python -m py_compile get_inventory.py
python -m py_compile get_license_file.py
python -m py_compile get_ns_device_profile.py
python -m py_compile get_ns_ns_running_config.py
python -m py_compile get_nssdx.py
python -m py_compile get_snmp_manager.py
python -m py_compile get_snmp_trap.py
python -m py_compile get_stylebooks.py
python -m py_compile get_system_settings.py
python -m py_compile get_techsupport.py
python -m py_compile get_traceroute.py
python -m py_compile getcount_docker_host.py
python -m py_compile managed_device.py
python -m py_compile modify_ns_lbvserver.py
python -m py_compile mps_data_center.py
python -m py_compile mps_group.py
python -m py_compile mps_user.py
python -m py_compile notifications.py
python -m py_compile poll_ns_ssl_certkey_policy.py
python -m py_compile reboot_ns.py
python -m py_compile system_session.py
python -m py_compile system_version.py
python -m py_compile track_activity.py
python -m py_compile update_prune_policy.py
python -m py_compile upload_ns_ssl_cert.py

View File

@@ -0,0 +1,101 @@
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.config_job import config_job
from massrc.com.citrix.mas.nitro.resource.config.mps.configuration_template import configuration_template
from massrc.com.citrix.mas.nitro.resource.config.mps.config_command import config_command
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class add_config_job :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = add_config_job()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.create_configjob(client)
def create_configjob(self,client) :
try:
device_list=[]
device_list.append('10.102.201.86-p1')
config_commandObj=config_command()
config_commandObj.protocol='SSH'
config_commandObj.command='show ns config'
command_list=[]
command_list.append(config_commandObj)
config_temp=configuration_template()
config_temp.commands=command_list
config_job_obj= config_job()
config_job_obj.name='test2'
config_job_obj.devices=device_list
config_job_obj.device_family='ns'
config_job_obj.scheduleTimesEpoch='1481997540'
config_job_obj.tz_offset=19800
config_job_obj.on_error="CONTINUE"
config_job_obj.template_info=config_temp
simplelist = config_job.add(client, config_job_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("name : "+simplelist[0].name)
print("status : "+simplelist[0].status)
print("create_configjob - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
add_config_job().main(add_config_job(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,129 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.ldap_server import ldap_server
from massrc.com.citrix.mas.nitro.resource.config.mps.aaa_server import aaa_server
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class external_auth :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = external_auth()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_ldap_server(client)
self.enable_aaa_server(client)
def add_ldap_server(self,client) :
try:
my_ldap_server = ldap_server()
my_ldap_server.name = "MyLDAPServer"
my_ldap_server.ip_address = "10.140.50.5"
my_ldap_server.type = "AD"
my_ldap_server.sec_type = "PLAINTEXT"
my_ldap_server.base_dn = "DC=citrite,DC=net"
my_ldap_server.bind_dn = "arunkumara@citrite.net"
my_ldap_server.bind_passwd = "OmSai@@(18"
ldap_server.add(client, my_ldap_server)
print "--------------"
print "Response Came :"
print "--------------"
print("add_ldap_server - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def enable_aaa_server(self,client) :
try:
my_aaa_server = aaa_server()
my_aaa_server.primary_server_type = "LDAP"
my_aaa_server.primary_server_name = "MyLDAPServer"
my_aaa_server.fallback_local_authentication = True
aaa_server.update(client, my_aaa_server)
print "--------------"
print "Response Came :"
print "--------------"
print("enable_aaa_server - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
external_auth().main(external_auth(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,111 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.inventory import inventory
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_inventory :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_inventory()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.inventory_check(client,"10.106.101.112")
def inventory_check(self,client,device_ip,partition = None) :
'''
This function emulates the 'rediscover' option for a device added to the NetScaler Console.
Args:
mas_client: [mandatory] The nitro service object using which the operation will be performed
device_ip: [mandatory] [str] The IP of the device that needs to be rediscovered
partition: [optional] [str] The name of the partition in the device that needs to be rediscovered
Returns:
act_id: [str] The activity ID of the rediscovery process
'''
try:
inventory_obj = inventory()
if partition:
device_ip = device_ip + "-" + partition
inventory_obj._device_ipaddress = device_ip
simplelist = inventory.get(client)
print "--------------"
print "Response Came :"
print "--------------"
print("activity id from inventory check: "+simplelist[0].act_id)
print("inventory_check - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
print "here"
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_inventory().main(get_inventory(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.license_file import license_file
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_license_file :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_license_file()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_license_details(client,{"file_name" : "CNS_V8000_SERVER_ENT_Evall.lic"},["file_size","file_last_modified"])
def get_license_details(self, client, license_details, details_to_fetch):
try:
json_filter = "file_name:" + license_details['file_name']
simplelist = license_file.get_filtered(client, json_filter)
if not simplelist:
print("Response is empty")
return False
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail +": " + detail_value)
print("get_license_details - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_license_file().main(get_license_file(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.ns.ns_device_profile import ns_device_profile
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_ns_device_profile :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_ns_device_profile()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_device_profile_details(client,"ns_nsroot_profile",["is_default","id"])
def get_device_profile_details(self, mas_client, profile_name, details_to_fetch):
try:
json_filter = "name:" + profile_name
simplelist = ns_device_profile.get_filtered(mas_client, json_filter)
if not simplelist:
print("Response is empty")
return False
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail +": " + detail_value)
print("get_device_profile_details - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_ns_device_profile().main(get_ns_device_profile(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,104 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.ns.ns_ns_runningconfig import ns_ns_runningconfig
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_ns_ns_running_config :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_ns_ns_running_config()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_ns_running_config(client,"10.106.101.112")
def get_ns_running_config(self, mas_client, device_ip, partition = None):
try:
ns_ns_runningconfig_obj = ns_ns_runningconfig()
if partition:
device_ip = device_ip + "-" + partition
ns_ns_runningconfig_obj.ns_ip_address = device_ip
simplelist = ns_ns_runningconfig.get(mas_client, ns_ns_runningconfig_obj)
print "--------------"
print "Response Came :"
print "--------------"
print(simplelist[0].response)
print("get_ns_running_config - Done")
return simplelist[0].response
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
return False
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_ns_ns_running_config().main(get_ns_ns_running_config(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,100 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.sdx.nssdx import nssdx
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_nssdx :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_nssdx()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_ns_sdx(client)
def get_ns_sdx(self,client) :
try:
simplelist = nssdx.get(client)
print "--------------"
print "Response Came :"
print "--------------"
for item in simplelist:
print("name of the Citrix ADC SDX: " + item.name)
print("id of the Citrix ADC SDX: " + item.id)
print("get_ns_sdx - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_nssdx().main(get_nssdx(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.snmp_manager import snmp_manager
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_snmp_manager :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_snmp_manager()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_snmp_manager_details(client,"<ip_address>",["community","netmask"]) #Replace <ip_address> with IP address of SNMP Manager
def get_snmp_manager_details(self, mas_client, manager_name, details_to_fetch):
try:
json_filter = "ip_address:" + manager_name
simplelist = snmp_manager.get_filtered(mas_client, json_filter)
if not simplelist:
print "Response is empty"
return False
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail + " : " + detail_value)
print("get_snmp_manager_details - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_snmp_manager().main(get_snmp_manager(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.snmp_trap import snmp_trap
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_snmp_trap :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_snmp_trap()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_snmp_trap_details(client,"<ip_address>",["community","version","user_name"]) #Replace <ip_address> wiht valid IP address
def get_snmp_trap_details(self, mas_client, dest_server, details_to_fetch):
try:
json_filter = "dest_server:" + dest_server
simplelist = snmp_trap.get_filtered(mas_client, json_filter)
if not simplelist:
print "Response is empty"
return False
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail + " : " + detail_value)
print("get_snmp_trap_details - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_snmp_trap().main(get_snmp_trap(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,100 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.stylebooks.stylebooks import stylebooks
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_stylebooks :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_stylebooks()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_style_books(client)
def get_style_books(self,client) :
try:
simplelist = stylebooks.get(client)
print "--------------"
print "Response Came :"
print "--------------"
for item in simplelist:
print("Name of the stylebook: "+ item.display_name)
print("Source of the stylebook: "+ str(item.source))
print("get_style_books - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_stylebooks().main(get_stylebooks(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,102 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.system_settings import system_settings
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_system_settings :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_system_settings()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_system_details(client,["svm_ns_comm","session_timeout","id"])
def get_system_details(self, mas_client, details_to_fetch):
try:
simplelist = system_settings.get(mas_client)
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail + " : " + detail_value)
print("get_system_details - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_system_settings().main(get_system_settings(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,108 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.techsupport import techsupport
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_techsupport :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_techsupport()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_techsupport_details(client,"<filename>",["mode","file_size","act_id"]) #Replace <filename> with valid Technical Support file name
def get_techsupport_details(self,mas_client, filename, details_to_fetch):
try:
json_filter = "file_name:" + filename
print json_filter
simplelist = techsupport.get_filtered(mas_client, json_filter)
print simplelist
if not simplelist:
print "Response is empty"
return False
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail + " : " + detail_value)
print("get_techsupport_details - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_techsupport().main(get_techsupport(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,111 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.traceroute import traceroute
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class get_traceroute :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = get_traceroute()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.perform_traceroute(client,"10.106.101.112")
def perform_traceroute(self,client, device_ip, partition = None) :
'''
This function emulates the traceroute function for a device associated with the NetScaler Console.
Args:
client: [mandatory] The nitro service object using which the operation will be performed
device_ip: [mandatory] [str] The IP of the device that needs to be tracerouted
partition: [optional] [str] The name of the partition in the device that needs to be tracerouted
Returns:
traceroute_status: [str] A string containing the status of the traceroute operation
'''
try:
traceroute_obj = traceroute()
if partition:
device_ip = device_ip + "-" + partition
traceroute_obj.device_ipaddress = device_ip
simplelist = traceroute.get(client, traceroute_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("traceroute status: "+simplelist[0].traceroute_status)
print("device ip address: "+simplelist[0].device_ipaddress)
print("perform_traceroute - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
get_traceroute().main(get_traceroute(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,98 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.docker.docker_host import docker_host
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class getcount_docker_host :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = getcount_docker_host()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_count(client)
def get_count(self,client) :
try:
count = docker_host.count(client)
print "--------------"
print "Response Came :"
print "--------------"
print("Count of Docker hosts: "+ str(count))
print("get_count - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
getcount_docker_host().main(getcount_docker_host(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,161 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.managed_device import managed_device
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class add_get_delete_managed_device :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = add_get_delete_managed_device()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_managed_device(client) #Adding managed_device by uploading csv file
self.get_device_id_list(client,{"attrs" : "ip_address,id"})
self.delete_managed_device(client,"5ea1b39d-58b2-41cc-9eb8-65eb9d8ec5f5") #deleting managed_device by its id. Provide valid id here by getting the list of ids first.
def uploadCSV_file(self,client):
obj=managed_device()
obj.file_name="Sample.csv"
obj.file_location_path="C:/Users/Suraj/Desktop/Desktop"
managed_device.upload(client,obj)
def add_managed_device(self,client) :
try:
self.uploadCSV_file(client)
obj=managed_device()
obj.file_name="Sample.csv"
obj.profile_name="ns_nsroot_profile"
managed_device.add_device(client,obj)
print "--------------"
print "Response Came :"
print "--------------"
print("add_managed_device - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def delete_device(self, client, device_id):
'''
This function deletes a device from the NetScaler Console.
Args:
client: [mandatory] The nitro service object using which the operation will be performed
device_id: [mandatory] [str] The ID of the device to be deleted
Returns:
True/False: True if delete is successful, False otherwise
'''
try:
device_obj = managed_device()
device_obj.id = str(device_id)
simplelist = managed_device.delete(mas_client,device_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("delete_managed_device - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def get_device_id_list(self,client,options):
try:
device_obj = managed_device()
# options = urlencode(options)
# simplelist = managed_device.get(mas_client,None,options)
simplelist = managed_device.get(mas_client)
print "--------------"
print "Response Came :"
print "--------------"
for item in simplelist:
print("ip_address: %s",item["ip_address"])
print("id: %s",item["id"])
print("--------------")
print("get_device_id_list - Done\n")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
add_get_delete_managed_device().main(add_get_delete_managed_device(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,102 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.ns.ns_lbvserver import ns_lbvserver
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class modify_ns_lbvserver :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = modify_ns_lbvserver()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.modify_lbvserver_state(client,"<id>","enable") #Replace <id> with valid id of the lbvserver instance that you want to enable/disable
def modify_lbvserver_state(self, mas_client, vserver_id, action):
try:
ns_lbvserver_obj = ns_lbvserver()
ns_lbvserver_obj.id = str(vserver_id)
if action == "enable":
ns_lbvserver.enable(mas_client, ns_lbvserver_obj)
else:
ns_lbvserver.disable(mas_client, ns_lbvserver_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("modify_lbvserver_state - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
modify_ns_lbvserver().main(modify_ns_lbvserver(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,129 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.mps_datacenter import mps_datacenter
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class mps_data_center :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = mps_data_center()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_datacenter(client)
self.delete_datacenter(client)
def add_datacenter(self,client) :
try:
my_datacenter = mps_datacenter()
my_datacenter.name = "new_dc"
my_datacenter.latitude = float(12.9716)
my_datacenter.longitude = float(77.5946)
simplelist = mps_datacenter.add(client,my_datacenter)
print "--------------"
print "Response Came :"
print "--------------"
print("name of the datacenter added: " + simplelist[0].name)
my_datacenter = mps_datacenter()
filter_value = "name:new_dc"
simplelist = mps_datacenter.get_filtered(client,filter_value)
print("id of the datacenter added: " + simplelist[0].id)
print("add_datacenter - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def delete_datacenter(self,client) :
try:
my_datacenter = mps_datacenter()
filter_value = "name:new_dc"
simplelist = mps_datacenter.get_filtered(client,filter_value)
my_datacenter = mps_datacenter()
my_datacenter.id= str(simplelist[0].id)
simplelist = mps_datacenter.delete(client,my_datacenter)
print "--------------"
print "Response Came :"
print "--------------"
print("id of the datacenter deleted: " + simplelist[0].id)
print("delete_datacenter - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
mps_data_center().main(mps_data_center(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,104 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.mpsgroup import mpsgroup
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class mps_group :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = mps_group()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_mpsgroup(client)
def add_mpsgroup(self,client) :
try:
my_mpsgroup = mpsgroup()
my_mpsgroup.name = "mygroup"
my_mpsgroup.permission = "admin"
user_list = []
user_list.append("nsroot")
my_mpsgroup.users = user_list
mpsgroup.add(client, my_mpsgroup)
print "--------------"
print "Response Came :"
print "--------------"
print("add_mpsgroup - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
mps_group().main(mps_group(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,110 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.mpsuser import mpsuser
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class mps_user :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = mps_user()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.set_mpsuser(client)
def set_mpsuser(self,client) :
try:
my_mpsuser = mpsuser()
simplelist = mpsuser.get(client, None)
print "--------------"
print "Response Came :"
print "--------------"
for item in simplelist :
print "Username : "+ item.name+ " | Id : " +item.id
if item.name in ["nsroot"]:
my_mpsuser.id = str(item.id)
my_mpsuser.name = "nsroot"
my_mpsuser.password = "mynsroot"
my_mpsuser.groups = []
my_mpsuser.groups.append("owner")
mpsuser.update(client, my_mpsuser)
print "--------------"
print "Response Came :"
print "--------------"
print("set_mpsuser - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
mps_user().main(mps_user(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,124 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.ntp_server import ntp_server
from massrc.com.citrix.mas.nitro.resource.config.mps.ntp_sync import ntp_sync
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class notifications :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = notifications()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.add_ntp_server(client)
self.enable_ntp_sync(client)
def add_ntp_server(self,client) :
try:
my_ntp_server = ntp_server()
my_ntp_server.server = "204.9.54.119"
my_ntp_server.maxpoll = 10
my_ntp_server.minpoll = 5
my_ntp_server.autokey = True
ntp_server.add(client, my_ntp_server)
print "--------------"
print "Response Came :"
print "--------------"
print("add_ntp_server - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def enable_ntp_sync(self,client) :
try:
my_ntp_sync = ntp_sync()
my_ntp_sync.ntpd_status = True
ntp_sync.update(client, my_ntp_sync)
print "--------------"
print "Response Came :"
print "--------------"
print("enable_ntp_sync - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
notifications().main(notifications(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,122 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.ns.ns_ssl_certkey_policy import ns_ssl_certkey_policy
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class poll_ns_ssl_cert_policy :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = poll_ns_ssl_cert_policy()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.certificate_poll_now(client)
self.update_poll_interval(client,45)
def certificate_poll_now(self, client):
try:
ns_ssl_certkey_policy_obj = ns_ssl_certkey_policy()
simplelist = ns_ssl_certkey_policy.get_filtered(client, "")
polled = ns_ssl_certkey_policy.do_poll(client, simplelist[0])
# print("ns ip address: "+polled[0].ns_ip_address)
print "--------------"
print "Response Came :"
print "--------------"
print("polling interval: "+polled[0].polling_interval)
print("certificate_poll_now - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
def update_poll_interval(self, client, updated_time):
try:
ns_ssl_certkey_policy_obj = ns_ssl_certkey_policy()
ns_ssl_certkey_policy_obj.polling_interval = updated_time
simplelist = ns_ssl_certkey_policy.update(client, ns_ssl_certkey_policy_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("update_poll_interval - Done")
return simplelist[0]
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
return False
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
poll_ns_ssl_cert_policy().main(poll_ns_ssl_cert_policy(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,99 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.ns.ns import ns
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class reboot_ns :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = reboot_ns()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.reboot_operation(client,"6e9e428a-ff8f-4643-bf8a-0057b75add9c")
def reboot_operation(self,client, device_id):
try:
ns_obj = ns()
ns_obj.id = str(device_id)
simplelist = ns.reboot(client, ns_obj)
print "--------------"
print "Response Came :"
print "--------------"
print("reboot_operation - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
reboot_ns().main(reboot_ns(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,32 @@
@echo off
python add_mps_ssl_certkey.py %*
python add_ntp_server.py %*
python add_snmp_view.py %*
python config_job.py %*
python external_auth.py %*
python get_inventory.py %*
python get_license_file.py %*
python get_ns_device_profile.py %*
python get_ns_ns_running_config.py %*
python get_nssdx.py %*
python get_snmp_manager.py %*
python get_snmp_trap.py %*
python get_stylebooks.py %*
python get_system_settings.py %*
python get_techsupport.py %*
python get_traceroute.py %*
python getcount_docker_host.py %*
python managed_device.py %*
python modify_ns_lbvserver.py %*
python mps_data_center.py %*
python mps_group.py %*
python mps_user.py %*
python notifications.py %*
python poll_ns_ssl_certkey_policy.py %*
python reboot_ns.py %*
python system_session.py %*
python system_version.py %*
python track_activity.py %*
python update_prune_policy.py %*
python upload_ns_ssl_cert.py %*

View File

@@ -0,0 +1,107 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.mpssession import mpssession
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class system_session :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = system_session()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_mpssession(client)
def get_mpssession(self,client) :
try:
result = mpssession()
simplelist = mpssession.get(client,result)
print "--------------"
print "Response Came :"
print "--------------"
for item in simplelist :
print "Username : "+ item.username+ " | Session Time Out : " +item.session_timeout
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
system_session().main(system_session(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,107 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.mps import mps
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class system_version :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = system_version()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.get_mps(client)
def get_mps(self,client) :
try:
result = mps()
simplelist = mps.get(client,result)
print "--------------"
print "Response Came :"
print "--------------"
for item in simplelist :
print "Product : "+ item.product+ " | Session Build : " +item.build_number
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
system_version().main(system_version(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,124 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
import operator
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.inventory_status import inventory_status
from massrc.com.citrix.mas.nitro.resource.config.mps.activity_status import activity_status
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class track_activity :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = track_activity()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.track_act(client,"aedbc3fc-5e10-44ae-a8fb-d3e24bc09cb1",["is_last","status"])
def track_act(self,client,act_id,details_to_fetch) :
'''
This function fetches details about a particular activity from the NetScaler Console.
Args:
client: [mandatory] The nitro service object using which the operation will be performed
act_id: [mandatory] [str] The ID of the activity to be tracked
details_to_fetch: [mandatory] [list] A list of attributes about the activity that is needed.
The attributes are attributes of the activity_status.py SDK
Example - ['is_last', 'status']
Returns:
return_dict: A dictionary where the keys are the attributes that need to be fetched, with corresponding values.
Example - {'is_last': False, 'status': 'In Progress'}
'''
json_filter = "act_id:" + act_id
# when you add a vpx, activity status and inventory status table gets populated
# when you add an sdx, only activity status table gets populated but not inventory
simplelist = inventory_status.get_filtered(client, json_filter)
if not simplelist:
#when you rediscover a vpx as well as an sdx, inventory status table gets populated
simplelist = activity_status.get_filtered(client, json_filter)
try:
print "--------------"
print "Response Came :"
print "--------------"
for detail in details_to_fetch:
detail_value = (operator.attrgetter(detail)(simplelist[0]))
print(detail +": " + detail_value)
print("track activity - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
track_activity().main(track_activity(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,102 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.mps.prune_policy import prune_policy
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class update_prune_policy :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = update_prune_policy()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.modify_prune_policy_settings(client,{"policy_name":"mps_policy_prune","days":"20"})
def modify_prune_policy_settings(self, mas_client, prune_policy_details):
try:
prune_policy_obj = prune_policy()
prune_policy_obj.policy_name = str(prune_policy_details["policy_name"])
prune_policy_obj.data_to_keep_in_days = int(prune_policy_details["days"])
simplelist = prune_policy.update(mas_client,prune_policy_obj)
print "--------------"
print "Response Came :"
print "--------------"
print simplelist[0].policy_name
print simplelist[0].data_to_keep_in_days
print("modify_prune_policy_settings - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
update_prune_policy().main(update_prune_policy(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")

View File

@@ -0,0 +1,101 @@
#!/usr/bin/env python
'''
* Copyright (c) 2008-2025 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
'''
import sys
from massrc.com.citrix.mas.nitro.exception.nitro_exception import nitro_exception
from massrc.com.citrix.mas.nitro.resource.config.ns.ns_ssl_cert import ns_ssl_cert
from massrc.com.citrix.mas.nitro.service.nitro_service import nitro_service
class upload_ns_ssl_cert :
def __init__(self):
ipaddress=""
username=""
password=""
@staticmethod
def main(cls, args_):
if(len(args_) < 3):
print("Usage: run.bat <ip> <username> <password>")
return
config = upload_ns_ssl_cert()
config.ip = args_[1]
config.username = args_[2]
config.password = args_[3]
try :
client = nitro_service(config.ip,"http")
#client.isCloud = True #uncomment this line for NetScaler Console
client.set_credential(config.username,config.password) #For Service, username and password are treated as ID and secret
client.timeout = 1800
client.login()
config.run_sample(client)
client.logout()
except nitro_exception as e:
print("Exception::errorcode="+str(e.errorcode)+",message="+ e.message)
except Exception as e:
print("Exception::message="+str(e.args))
return
def run_sample(self, client) :
self.upload_certificate(client)
def upload_certificate(self,client) :
try:
my_ns_ssl_cert = ns_ssl_cert()
my_ns_ssl_cert.file_location_path = "/root/random_scripts/"
my_ns_ssl_cert.file_name = "mydomain29282.com.pem"
ns_ssl_cert.upload(client, my_ns_ssl_cert)
print "--------------"
print "Response Came :"
print "--------------"
print("upload_ns_ssl_cert - Done")
except nitro_exception as e :
print "--------------"
print "Exception :"
print "--------------"
print "ErrorCode : "+ str(e.errorcode)
print "Message : " +e.message
except Exception as e:
raise e
#
# Main thread of execution
#
if __name__ == '__main__':
try:
print len(sys.argv)
if len(sys.argv) < 3:
sys.exit()
else:
ipaddress=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
upload_ns_ssl_cert().main(upload_ns_ssl_cert(),sys.argv)
except SystemExit:
print("Exception::Usage: Sample.py <directory path of Nitro.py> <nsip> <username> <password>")