def perform_operation_bulk_request(cls, service, resources, action ): """ Use this method to perform a clear/sync/link/unlink/save ...etc operation on netscaler resources. Parameters: service - nitro_service object. resources - Array of Nitro resources on which the specified action to be performed. opt - options object with action that is to be performed set. Returns: status of the operation performed. Throws: Exception of the type nitro_exception is thrown. """ try: if (not service.isLogin()): service.login() opt = options() opt.action = action request = service.payload_formatter.resource_to_string_bulk(resources) result = cls.post_bulk_data(service, request, opt) return result except Exception as e: raise e
def perform_operation(self, service, action="", opt=""): """ Use this method to perform a clear/sync/link/unlink/save ...etc operation on netscaler resource. Parameters: service - nitro_service object. action - action needs to be taken on resource. opt - options object with action that is to be performed set. Returns: status of the operation performed. Throws: Exception of the type nitro_exception is thrown. """ try: if (not service.isLogin() and self.__class__.get_object_type()!="login"): service.login() if not opt and not action: return self.post_request(service, None) elif not opt : opt = options() opt.action = action response = self.post_request(service, opt) return response except Exception as e: raise e
def delete_bulk_request(cls, service, resources, opt=""): """ Use this method to perform a delete operation on netscaler resources. Parameters: service - nitro_service object. resources - Nitro resources to be deleted on netscaler. opt - options class object. Returns: status of the performed operation. Throws: Exception Nitro exception is thrown. """ try: if (not service.isLogin()): service.login() opt = options() opt.action = "rm" type_ = resources[0].__class__.get_object_type() if (type_.find("_binding") > 0): opt.action = "unbind" request = service.payload_formatter.resource_to_string_bulk(resources) result = cls.post_bulk_data(service, request, opt) return result except Exception as e: raise e
def rename_resource(self, service, newname): """ Use this method to perform a rename operation on netscaler resource. Parameters: service - nitro_service object. newname - new name to be set to the specified resource. Returns: status of the operation performed. Throws: Exception of the type nitro_exception is thrown. """ try: if not service.isLogin(): service.login() if '_newname' in self.__dict__ : self.newname = newname else : raise nitro_exception(-1,str("Rename is not supported for this resource"),) opt = options() opt.action = "rename" response = self.post_request(service, opt) return response except Exception as e: raise e
def get(self, service, obj) : ur""" Use this API to fetch a snmptrap_binding resource. """ try : if type(obj) is not list : option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(obj) response = obj.get_resource(service, option_) else : if obj and len(obj) > 0 : for i in range(len(obj)) : option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(obj[i]) response[i] = obj[i].get_resource(service, option_) return response except Exception as e: raise e
def get(cls, service, obj) : ur""" Use this API to fetch a snmptrap_snmpuser_binding resources. """ try : option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(obj) response = obj.get_resources(service,option_) return response except Exception as e: raise e
def get(cls, client, name="", option_="") : """ Use this API to fetch all the snmpoid resources that are configured on netscaler. """ try : if type(name) == cls : if type(name) is not list : option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(name) response = name.get_resource(client, option_) else : if name and len(name) > 0 : response = [snmpoid() for _ in range(len(name))] for i in range(len(name)) : option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(name[i]) response[i] = name[i].get_resource(client, option_) return response except Exception as e : raise e
def unset_bulk_request(cls, service, resources, args): try: if (not service.isLogin()): service.login() opt = options() opt.action = "unset" request = service.payload_formatter.unset_string_bulk(resources, args) return cls.post_bulk_data(service, request, opt) except Exception as e: raise e
def get(cls, service, name="", option_="") : ur""" Use this API to fetch the statistics of all servicegroupmember_stats resources that are configured on netscaler. """ try : obj = servicegroupmember_stats() option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(name) response = obj.stat_resource(service, option_) return response except Exception as e: raise e
def get(cls, client, name="", option_="") : """ Use this API to fetch all the systementity resources that are configured on netscaler. """ try : if type(name) == cls : if type(name) is not list : option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(name) response = name.get_resource(client, option_) return response except Exception as e : raise e
def get_filtered(cls, service, filter_) : ur""" Use this API to fetch filtered set of appfwglobal_auditnslogpolicy_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = appfwglobal_auditnslogpolicy_binding() option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, client, filter_, obj) : """ Use this API to fetch filtered set of snmpoid resources. filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : option_ = options() option_.filter = filter_ option_.args = nitro_util.object_to_string_withoutquotes(obj) response = obj.getfiltered(client, option_) return response except Exception as e : raise e
def get_args(cls, client, args): ur""" Use this API to fetch all the dnsnaptrrec resources that are configured on netscaler. # This uses dnsnaptrrec_args which is a way to provide additional arguments while fetching the resources. """ try: obj = dnsnaptrrec() option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(args) response = obj.get_resources(client, option_) return response except Exception as e: raise e
def get_filtered(cls, client, filter_): ur""" Use this API to fetch filtered set of dnsnaptrrec resources. filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = dnsnaptrrec() option_ = options() option_.filter = filter_ response = obj.getfiltered(client, option_) return response except Exception as e: raise e
def get_filtered(cls, service, filter_) : """ Use this API to fetch filtered set of vpnglobal_intranetip_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = vpnglobal_intranetip_binding() option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, client, filter_) : """ Use this API to fetch filtered set of aaapreauthenticationpolicy resources. filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = aaapreauthenticationpolicy() option_ = options() option_.filter = filter_ response = obj.getfiltered(client, option_) return response except Exception as e : raise e
def get_filtered(cls, service, filter_) : """ Use this API to fetch filtered set of aaaglobal_authenticationnegotiateaction_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = aaaglobal_authenticationnegotiateaction_binding() option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, service, obj, filter_) : """ Use this API to fetch filtered set of clusternodegroup_service_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : option_ = options() option_.filter = filter_ option_.args = nitro_util.object_to_string_withoutquotes(obj) response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def count(cls, client) : """ Use this API to count the aaapreauthenticationpolicy resources configured on NetScaler. """ try : obj = aaapreauthenticationpolicy() option_ = options() option_.count = True response = obj.get_resources(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e
def get_filtered(cls, service, name, filter_) : """ Use this API to fetch filtered set of appfwprofile_fieldconsistency_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = appfwprofile_fieldconsistency_binding() obj.name = name option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def count(cls, client) : ur""" Use this API to count the csaction resources configured on NetScaler. """ try : obj = csaction() option_ = options() option_.count = True response = obj.get_resources(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e
def count(cls, service) : ur""" Use this API to count appfwglobal_auditnslogpolicy_binding resources configued on NetScaler. """ try : obj = appfwglobal_auditnslogpolicy_binding() option_ = options() option_.count = True response = obj.get_resources(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def get_filtered(cls, service, labelname, filter_): """ Use this API to fetch filtered set of dnspolicylabel_policybinding_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = dnspolicylabel_policybinding_binding() obj.labelname = labelname option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, service, clid, filter_) : ur""" Use this API to fetch filtered set of clusterinstance_clusternode_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = clusterinstance_clusternode_binding() obj.clid = clid option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, service, id, filter_) : """ Use this API to fetch filtered set of vxlan_iptunnel_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = vxlan_iptunnel_binding() obj.id = id option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, service, name, filter_) : ur""" Use this API to fetch filtered set of authenticationlocalpolicy_vpnglobal_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = authenticationlocalpolicy_vpnglobal_binding() obj.name = name option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def get_filtered(cls, service, username, filter_) : """ Use this API to fetch filtered set of systemuser_nspartition_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = systemuser_nspartition_binding() obj.username = username option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def count(cls, service) : """ Use this API to count vpnglobal_intranetip_binding resources configued on NetScaler. """ try : obj = vpnglobal_intranetip_binding() option_ = options() option_.count = True response = obj.get_resources(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count(cls, client, obj) : """ Use this API to count the snmpoid resources configured on NetScaler. """ try : option_ = options() option_.count = True option_.args = nitro_util.object_to_string_withoutquotes(obj) response = obj.get_resources(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e
def get_filtered(cls, service, name, filter_) : """ Use this API to fetch filtered set of tmtrafficpolicy_lbvserver_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = tmtrafficpolicy_lbvserver_binding() obj.name = name option_ = options() option_.filter = filter_ response = obj.getfiltered(service, option_) return response except Exception as e: raise e
def count_filtered(cls, service, groupname, filter_): r""" Use this API to count the filtered set of lsngroup_lsnhttphdrlogprofile_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = lsngroup_lsnhttphdrlogprofile_binding() obj.groupname = groupname option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, name, filter_): ur""" Use this API to count the filtered set of appfwprofile_cookieconsistency_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = appfwprofile_cookieconsistency_binding() obj.name = name option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, name, filter_) : r""" Use this API to count the filtered set of gslbdomain_gslbservicegroupmember_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = gslbdomain_gslbservicegroupmember_binding() obj.name = name option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def get(cls, service, name="", option_=""): r""" Use this API to fetch the statistics of all inatsession_stats resources that are configured on netscaler. set statbindings=True in options to retrieve bindings. """ try: obj = inatsession_stats() if name: obj.name = name response = obj.stat_resource(service, option_) if not option_: option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(name) response = obj.stat_resource(service, option_) return response except Exception as e: raise e
def count_filtered(cls, service, id, filter_): r""" Use this API to count the filtered set of vrid6_trackinterface_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = vrid6_trackinterface_binding() obj.id = id option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, callid, filter_): r""" Use this API to count the filtered set of lsnsipalgcall_controlchannel_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = lsnsipalgcall_controlchannel_binding() obj.callid = callid option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, certkey, filter_): ur""" Use this API to count the filtered set of sslcertkey_crldistribution_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = sslcertkey_crldistribution_binding() obj.certkey = certkey option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, policyname, filter_) : r""" Use this API to count the filtered set of cachepolicy_csvserver_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = cachepolicy_csvserver_binding() obj.policyname = policyname option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, name, filter_): r""" Use this API to count the filtered set of authenticationnegotiatepolicy_vpnglobal_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = authenticationnegotiatepolicy_vpnglobal_binding() obj.name = name option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, vlan, filter_): r""" Use this API to count the filtered set of nd6ravariables_onlinkipv6prefix_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = nd6ravariables_onlinkipv6prefix_binding() obj.vlan = vlan option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, metrictable, filter_): r""" Use this API to count the filtered set of lbmetrictable_metric_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = lbmetrictable_metric_binding() obj.metrictable = metrictable option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, nodeid, filter_): r""" Use this API to count the filtered set of clusternode_routemonitor_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = clusternode_routemonitor_binding() obj.nodeid = nodeid option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, username, filter_) : r""" Use this API to count the filtered set of aaauser_vpnintranetapplication_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = aaauser_vpnintranetapplication_binding() obj.username = username option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, sitepath, filter_): r""" Use this API to count the filtered set of wisite_translationinternalip_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = wisite_translationinternalip_binding() obj.sitepath = sitepath option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def count_filtered(cls, service, limitidentifier, filter_) : r""" Use this API to count the filtered set of nslimitidentifier_nslimitsessions_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = nslimitidentifier_nslimitsessions_binding() obj.limitidentifier = limitidentifier option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def clear_config(self, force="", level=""): """ Use self API to clear configuration. @param force clear confirmation without prompting. @param level clear config according to the level. eg: basic, extended, full @return status of the operation performed. """ try: if level and force: resource = nsconfig() if (force): resource.force = force resource.level = level option = options() option.action = "clear" result = resource.perform_operation(self, "", option) return result elif force: return self.clear_config(force, "basic") else: return self.clear_config(True, "basic") except Exception as e: raise e
def count_filtered(cls, service, labelname, filter_): r""" Use this API to count the filtered set of videooptimizationdetectionpolicylabel_videooptimizationdetectionpolicy_binding resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try: obj = videooptimizationdetectionpolicylabel_videooptimizationdetectionpolicy_binding( ) obj.labelname = labelname option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(service, option_) if response: return response[0].__dict__['___count'] return 0 except Exception as e: raise e
def forcehasync(self, force, save): """ Use self API to force the sync in secondary Netscaler. @param force set self to true for forcesync @param save set self to YES,if want to save the configuration after sync. @return status of the operation performed. """ try: resource = hasync() resource.force = force resource.save = save option = options() option.action = "force" result = resource.perform_operation(self, "", option) return result except Exception as e: raise e
def enable_features(self, features): """ Use self API to enable the feature on Netscaler. @param features features to be enabled. @return status of the operation performed. @throws Exception Nitro exception. """ try: resource = nsfeature() resource.feature = features option = options() option.action = "enable" result = resource.perform_operation(self, "", option) return result except Exception as e: raise e
def disable_modes(self, modes): """ Use self API to disable the mode on Netscaler. @param modes modes to be disabled. @return status of the operation performed. @throws Exception Nitro exception. """ try: resource = nsmode() resource.mode = modes option = options() option.action = "disable" result = resource.perform_operation(self, "", option) return result except Exception as e: raise e
def perform_operationEx(self, service): """ Use this method to perform a POST operation with out any action like ping, that returns a resource ...etc operation on netscaler resource. Parameters: service - nitro_service object. Returns: requested resource Throws: Exception of the type nitro_exception is thrown. """ try: if (not service.isLogin() and self.__class__.get_object_type() != "login"): service.login() opt = options() response = self.post_requestEx(service, opt) return response except Exception as e: raise e
def unset_resource(self, service, args): """ Use this method to perform an Unset operation on netscaler resource. Parameters: service - nitro_service object. args - Array of args that are to be unset. Returns: status of the operation performed. Throws: Exception of the type nitro_exception is thrown. """ try: if not service.isLogin(): service.login() opt = options() opt.action = "unset" response = self.unset_request(service, opt, args) return response except Exception as e: raise e
def save_config(self): """ Use self API to save configuration on Netscaler. @return status of the operation performed. """ try: resource = nsconfig() option = options() option.action = "save" result = resource.perform_operation(self, "", option) return result except Exception as e: raise e