def basic_lbv(self, client, lbv_name, svc_name) : try : #Create an instance of the virtual server class new_lbvserver_obj = lbvserver() #Create a new virtual server new_lbvserver_obj.name = lbv_name new_lbvserver_obj.ipv46 = "10.217.242.76" new_lbvserver_obj.servicetype = "HTTP" new_lbvserver_obj.port = 80 new_lbvserver_obj.lbmethod = "ROUNDROBIN" #get all lbvservers and shove them into a list #FIXME this is not working as expected it. it sets all list members to the same lbv object resources = lbvserver.get(client) for resource in resources: if resource.name == lbv_name: print("lbvserver resource::name="+resource.name+" exists.") lbvserver.delete(client, new_lbvserver_obj) break lbvserver.add(client, new_lbvserver_obj) #bind service to lbv bindObj = lbvserver_service_binding() bindObj.name = lbv_name bindObj.servicename = svc_name bindObj.weight = 20 lbvserver_service_binding.add(client, bindObj) print("basic_lbv - Done") except nitro_exception as e : print("Exception::basic_lbv::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::basic_lbv::message="+str(e.args))
def main(cls, args_): if (len(args_) < 3): print("Usage: run.bat <ip> <username> <password>") return config = MyFirstNitroApplication() config.ip = args_[1] config.username = args_[2] config.password = args_[3] try: #Create an instance of the nitro_service class to connect to the appliance ns_session = nitro_service(config.ip, "HTTP") ns_session.set_credential( config.username, config.password) #to make arguments more generic ns_session.timeout = 310 #Log on to the appliance using your credentials ns_session.login() #Enable the load balancing feature. features_to_be_enabled = "lb" ns_session.enable_features(features_to_be_enabled) #Create an instance of the virtual server class new_lbvserver_obj = lbvserver() #Create a new virtual server new_lbvserver_obj.name = "MyFirstLbVServer" new_lbvserver_obj.ipv46 = "10.102.29.88" new_lbvserver_obj.servicetype = "HTTP" new_lbvserver_obj.port = 80 new_lbvserver_obj.lbmethod = "ROUNDROBIN" lbvserver.add(ns_session, new_lbvserver_obj) #Retrieve the details of the virtual server new_lbvserver_obj = lbvserver.get(ns_session, new_lbvserver_obj.name) print("Name : " + new_lbvserver_obj.name + "\n" + "Protocol : " + new_lbvserver_obj.servicetype) #Delete the virtual server lbvserver.delete(ns_session, new_lbvserver_obj.name) #Save the configurations ns_session.save_config() #Logout from the NetScaler appliance ns_session.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 Create(self): sslv = lbvserver.lbvserver() sslv.name = self.name sslv.servicetype = self.type sslv.port = self.port sslv.ipv46 = self.ip self.entity = lbvserver.lbvserver.add(self.sess, l) return self, entity
def rename_lbvserver(self, client, name, newname) : try : obj = lbvserver() obj.name = name lbvserver.rename(client, obj, newname) print("rename_lbvserver - Done") except nitro_exception as e : print("Exception::rename_lbvserver::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::rename_lbvserver::message="+str(e.args))
def add_lbvserver_post(self, client) : try : obj = lbvserver() obj.name = "lb_vip_post" obj.servicetype = lbvserver.Servicetype.HTTP lbvserver.add(client,obj) print("add_lbvserver_post - Done") except nitro_exception as e : print("Exception::add_lbvserver_post::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::add_lbvserver_post::message="+str(e.args))
def update_lbvserver(self, client) : try : obj = lbvserver() obj.name = "lb_vip" obj.comment = "Modified the comments. update resources works fine." obj.lbmethod = lbvserver.Lbmethod.LEASTBANDWIDTH lbvserver.update(client, obj) print("update_lbvserver - Done") except nitro_exception as e : print("Exception::update_lbvserver::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::update_lbvserver::message="+str(e.args))
def call_nitro_commands(ns_session): try: ns_session.clear_config(force=True, level='full') logging.debug('Clear config executed') needed_features = [ nsfeature.Feature.CS, nsfeature.Feature.LB, nsfeature.Feature.SSL, nsfeature.Feature.RESPONDER, nsfeature.Feature.REWRITE ] ns_session.enable_features(needed_features) logging.debug('Adding CS vserver') csvserver_instance = csvserver() csvserver_instance.name = 'drinks_sample' csvserver_instance.ipv46 = '127.0.0.1' csvserver_instance.servicetype = 'http' csvserver_instance.port = '443' csvserver_instance.add(ns_session, csvserver_instance) logging.debug('Adding LB vserver') lbvserver_instance = lbvserver() lbvserver_instance.name = 'lbvs_hotdrink_http_example' lbvserver_instance.ipv46 = '0.0.0.0' lbvserver_instance.port = 0 lbvserver_instance.servicetype = 'http' lbvserver_instance.add(ns_session, lbvserver_instance) logging.debug('Adding servicegroup') servicegroup_instance = servicegroup() servicegroup_instance.servicegroupname = 'sg_hotdrink_http_example' servicegroup_instance.servicetype = 'http' servicegroup_instance.add(ns_session, servicegroup_instance) logging.debug('Adding servieegroup binding') servicegroup_servicegroupmember_binding_instance = servicegroup_servicegroupmember_binding( ) servicegroup_servicegroupmember_binding_instance.servicegroupname = 'sg_hotdrink_http_example' servicegroup_servicegroupmember_binding_instance.ip = '172.100.100.3' servicegroup_servicegroupmember_binding_instance.port = 80 servicegroup_servicegroupmember_binding_instance.add( ns_session, servicegroup_servicegroupmember_binding_instance) logging.debug('Adding servicegroup lb vserver binding') lbvserver_servicegroup_binding_instance = lbvserver_servicegroup_binding( ) lbvserver_servicegroup_binding_instance.name = 'lbvs_hotdrink_http_example' lbvserver_servicegroup_binding_instance.servicegroupname = 'sg_hotdrink_http_example' lbvserver_servicegroup_binding_instance.add( ns_session, lbvserver_servicegroup_binding_instance) logging.debug('SUCCESS: Configuration completed') except Exception as e: logging.error('FAILURE: Error during configuration: {}'.format( e.message))
def unset_lbvserver(self, client): try: lb1 = [lbvserver() for _ in range(2)] lb1[0].name = "lb2" lb1[1].name = "lb1" args = ["comment", "lbmethod"] lbvserver.unset(client, lb1, args) print("unset_lbvserver - Done") except nitro_exception as e: print("Exception::unset_lbvserver::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::unset_lbvserver::message=" + str(e.args))
def main(cls, args_): if(len(args_) < 3): print("Usage: run.bat <ip> <username> <password>") return config = MyFirstNitroApplication() config.ip = args_[1] config.username = args_[2] config.password = args_[3] try : #Create an instance of the nitro_service class to connect to the appliance ns_session = nitro_service(config.ip,"HTTP") ns_session.set_credential("nsroot", "nsroot") ns_session.timeout = 310 #Log on to the appliance using your credentials ns_session.login() #Enable the load balancing feature. features_to_be_enabled = "lb" ns_session.enable_features(features_to_be_enabled) #Create an instance of the virtual server class new_lbvserver_obj = lbvserver() #Create a new virtual server new_lbvserver_obj.name = "MyFirstLbVServer" new_lbvserver_obj.ipv46 = "10.102.29.88" new_lbvserver_obj.servicetype = "HTTP" new_lbvserver_obj.port = 80 new_lbvserver_obj.lbmethod = "ROUNDROBIN" lbvserver.add(ns_session, new_lbvserver_obj) #Retrieve the details of the virtual server new_lbvserver_obj = lbvserver.get(ns_session,new_lbvserver_obj.name) print("Name : " +new_lbvserver_obj.name +"\n" +"Protocol : " +new_lbvserver_obj.servicetype) #Delete the virtual server lbvserver.delete(ns_session, new_lbvserver_obj.name) #Save the configurations ns_session.save_config() #Logout from the NetScaler appliance ns_session.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 add_lbvserver(self, client,lb_vserver_name) : try : obj = lbvserver() obj.name = lb_vserver_name obj.servicetype = lbvserver.Servicetype.HTTP response = lbvserver.add(client, obj) print("add_lbvserver - Done\n") if response.severity and response.severity =="WARNING" : print("\tWarning : " + response.message) except nitro_exception as e : print("Exception::add_lbvserver::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::add_lbvserver::message="+str(e.args))
def _create_lb(self, lbname): try: lb = lbvserver.get(self.ns_session, lbname) if (lb.name == lbname): logger.info("LB %s is already configured " % lbname) return except nitro_exception: pass lb = lbvserver() lb.name = lbname lb.servicetype = "HTTP" lbvserver.add(self.ns_session, lb)
def addLBVServers(self): """Configure the lbvservers for the NetScaler""" if "lbvs" in self.cfg.keys(): #Lets loop through all lbvservers for lbvs in self.cfg['lbvs']: try: #Setup a new lbvserver newLBVS = lbvserver() newLBVS.name = lbvs['name'] newLBVS.servicetype = lbvs['servicetype'] newLBVS.ipv46 = lbvs['ipv46'] #check these optional values if "port" in lbvs.keys(): newLBVS.port = lbvs['port'] if "persistencetype" in lbvs.keys(): newLBVS.persistencetype = lbvs['persistencetype'] if "lbmethod" in lbvs.keys(): newLBVS.lbmethod = lbvs['lbmethod'] #Add the lbvs response = lbvserver.add(self.ns_session, newLBVS) if response.severity and response.severity == "WARNING": print("\tWarning : " + response.message) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) #If we have services to bind, lets do it. if "services" in lbvs.keys(): for svc in lbvs['services']: #Create a new binding newSVCBinding = lbvserver_service_binding() newSVCBinding.name = lbvs['name'] newSVCBinding.servicename = svc['servicename'] newSVCBinding.weight = svc['weight'] #Add the binding! try: lbvserver_service_binding.add(self.ns_session, newSVCBinding) 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 addLBVServers(self): """Configure the lbvservers for the NetScaler""" if "lbvs" in self.cfg.keys(): #Lets loop through all lbvservers for lbvs in self.cfg['lbvs']: try: #Setup a new lbvserver newLBVS = lbvserver() newLBVS.name = lbvs['name'] newLBVS.servicetype = lbvs['servicetype'] newLBVS.ipv46 = lbvs['ipv46'] #check these optional values if "port" in lbvs.keys(): newLBVS.port = lbvs['port'] if "persistencetype" in lbvs.keys(): newLBVS.persistencetype = lbvs['persistencetype'] if "lbmethod" in lbvs.keys(): newLBVS.lbmethod = lbvs['lbmethod'] #Add the lbvs response = lbvserver.add(self.ns_session, newLBVS) if response.severity and response.severity == "WARNING": print("\tWarning : " + response.message) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) #If we have services to bind, lets do it. if "services" in lbvs.keys(): for svc in lbvs['services']: #Create a new binding newSVCBinding = lbvserver_service_binding() newSVCBinding.name = lbvs['name'] newSVCBinding.servicename = svc['servicename'] newSVCBinding.weight = svc['weight'] #Add the binding! try: lbvserver_service_binding.add( self.ns_session, newSVCBinding) 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 Delete(self): httpv = LBVSERVER.lbvserver() httpv.name = self.name httpv.servicetype = self.type httpv.port = self.port httpv.ipv46 = self.ip try: LBVSERVER.lbvserver.delete(self.sess, httpv) except NITROEXCEPTION as e: self.lb = None print '{}'.format(e.message) except Exception as e: self.lb = None print '{}'.format(e.message)
def rmlbvserver_bulk(self, client): try: lbvs = [] lbvs = [lbvserver() for _ in range(2)] for i in range(2): lbvs[i].name = "lb" + str(i + 3) lbvserver.delete(client, lbvs) lbvs = ["lb5", "lb6"] lbvserver.delete(client, lbvs) print("rmlbvserver_bulk::rc= done") except nitro_exception as e: print("Exception::rmlbvserver_bulk::rc=" + str(e.errorcode) + " , Message =" + e.message) except Exception as e: print("Exception::rmlbvserver_bulk::message=" + str(e.args))
def AddDelVserverX(session,vsrvrlist,isdel=0) : l = [] for tup in vsrvrlist : sslv = LBVSERVER.lbvserver() sslv.name = tup[0] sslv.servicetype = tup[1] sslv.port = tup[2] sslv.ipv46 = DUT.VIP if (isdel == 0) : LBVSERVER.lbvserver.add(session,sslv) l.append(sslv) else : LBVSERVER.lbvserver.delete(session,sslv) return l
def add_lbvs_bulk(self, client) : try : lb = [lbvserver() for _ in range(2)] lb[0].name = "lb1" lb[0].servicetype = lbvserver.Servicetype.HTTP lb[1].name = "lb2" lb[1].servicetype = lbvserver.Servicetype.SSL lbvserver.add(client, lb) print("add_lbvs_bulk - Done") lbvserver.enable(client, lb) print("enable bulk resources - Done") except nitro_exception as e : print("Exception::add_lbvs_bulk::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::add_lbvs_bulk::message="+str(e.args))
def Delete(self): sslv = LBVSERVER.lbvserver() sslv.name = self.name sslv.servicetype = self.type sslv.port = self.port sslv.ipv46 = self.ip #self.sess.relogin() try: LBVSERVER.lbvserver.delete(self.sess, sslv) except NITROEXCEPTION as e: self.lb = None self.ssl = None print '{}'.format(e.message) except Exception as e: self.lb = None self.ssl = None print '{}'.format(e.message)
def lbvserver(self, action, name, ipv46, servicetype, port, lbmethod): '''This function is interactive and will allow one to add a load-balancing virtual server. param @action string add or delete (delete only requires the name) param @name string specifying the name of the virtual server param @ipv46 string representation of an IPv4 or IPv6 address param @servicetype string: HTTP, FTP, TCP, UDP, SSL, SSL_BRIDGE, SSL_TCP, NNTP, DNS, DHCPRA, ANY, SIP_UDP, DNS_TCP, RTSP. param @port - integer representing port for this service. param @lbmethod string: ROUNDROBIN, LEASTCONNECTION, LEASTRESPONSETIME, URLHASH, DOMAINHASH, DESTINATIONIPHASH, SOURCEIPHASH, SRCIPDESTIPHASH, LEASTBANDWIDTH, LEASTPACKETS, TOKEN, SRCIPDESTIPHASH, CUSTOMLOAD ''' # Enable the load balancing feature. try: features_to_be_enabled = "lb" self._sess.enable_features( features_to_be_enabled) # Check into this @@@ # Create an instance of the virtual server class obj = lbvserver() # Prepare the variables obj.name = name obj.ipv46 = ipv46 obj.servicetype = servicetype obj.port = port obj.lbmethod = lbmethod if action == 'add': lbvserver.add(self._sess, obj) elif action == 'delete': lbvserver.delete(self._sess, obj) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) else: return True return False
def bindsslvs_cert (self, client) : try : lbvs = lbvserver() lbvs.name = "ssl_vs" lbvs.servicetype = lbvserver.Servicetype.SSL lbvs.ipv46 = "1.1.1.1" lbvs.port = 443 lbvserver.add(client, lbvs) obj = [sslvserver_sslcertkey_binding() for _ in range(2)] obj[0].vservername = "ssl_vs" obj[0].certkeyname = "xx" obj[1].vservername = "ssl_vs" obj[1].certkeyname = "yy" sslvserver_sslcertkey_binding.add(client, obj) print("bindsslvs_cert - Done") except nitro_exception as e : print("Exception::bindsslvs_cert::errorcode="+str(e.errorcode)+",message="+ e.message) except Exception as e: print("Exception::bindsslvs_cert::message="+str(e.args))
def AddDelVserver(session,vsrvrlist,isdel=0) : l = [] print 'AddDelVserver: num of vservers {}'.format(len(vsrvrlist)) for tup in vsrvrlist : sslv = LBVSERVER.lbvserver() sslv.name = tup[0] sslv.servicetype = tup[1] sslv.port = tup[2] sslv.ipv46 = tup[3] l.append(sslv) if (isdel == 0) : try : LBVSERVER.lbvserver.add(session,l) except NITROEXCEPTION as e : print 'AddDelVserver: {}'.format(e.message) else : LBVSERVER.lbvserver.delete(session,l) return l
def _create_lb(self, lbname, lbmethod, vip, port): try: lb = lbvserver.get(self.ns_session, lbname) if (lb.name == lbname) and \ (lb.ipv46 == vip) and \ (str(lb.port) == port): logger.info("LB %s is already configured " % lbname) return else: logger.info("LB %s is already configured with a different \ VIP/port : %s:%s\n" % (lb.name, lb.ipv46, lb.port)) raise Exception("LB %s already configured with different VIP/\ port : %s:%s\n" % (lbname, lb.ipv46, lb.port)) except nitro_exception as e: pass lb = lbvserver() lb.name = lbname lb.ipv46 = vip lb.servicetype = "HTTP" lb.port = port lb.lbmethod = lbmethod lbvserver.add(self.ns_session, lb)
def Create(self): sslv = LBVSERVER.lbvserver() sslv.name = self.name sslv.servicetype = self.type sslv.port = self.port sslv.ipv46 = self.ip try: self.lb = LBVSERVER.lbvserver.add(self.sess, sslv) if self.lb: self.ssl = SSLVSERVER.sslvserver.get(self.sess, sslv.name) if not self.ssl: self.lb = None except NITROEXCEPTION as e: self.lb = None self.ssl = None print '{}'.format(e.message) except Exception as e: self.lb = None self.ssl = None print '{}'.format(e.message) self.boundciphers.append('DEFAULT') return self.ssl
def main(cls, args_): if(len(args_) < 3): print("Usage: run.bat <ip> <username> <password>") return config = basic_lbvServer() config.ip = args_[1] config.username = args_[2] config.password = args_[3] try : #Create an instance of the nitro_service class to connect to the appliance ns_session = nitro_service("10.217.242.90","HTTP") ns_session.set_credential("nsroot", config.password) ns_session.timeout = 310 #Log on to the appliance using your credentials ns_session.login() #Enable the load balancing feature. features_to_be_enabled = "lb" ns_session.enable_features(features_to_be_enabled) #Create an instance of the server class server_obj = server() #Create an instance of the service class service_obj = service() #Create an instance of the virtual server class new_lbvserver_obj = lbvserver() #Create a new virtual server new_lbvserver_obj.name = "MyFirstLbVServer" new_lbvserver_obj.ipv46 = "10.102.29.88" new_lbvserver_obj.servicetype = "HTTP" new_lbvserver_obj.port = 80 new_lbvserver_obj.lbmethod = "ROUNDROBIN" #lbvserver.delete(ns_session, new_lbvserver_obj.name) #lbvserver.add(ns_session, new_lbvserver_obj) #Retrieve the details of the virtual server new_lbvserver_obj = lbvserver.get(ns_session,new_lbvserver_obj.name) print("Name : " +new_lbvserver_obj.name +"\n" +"Protocol : " +new_lbvserver_obj.servicetype) #Retrieve state of a lbvserver obj_lbv = lbvserver_stats.get(ns_session, "MyFirstLbVServer") print("statlbvserver_byname result::name="+obj_lbv.name+", servicetype="+obj_lbv.type +",state="+obj_lbv.state) #Retrieve state of a servicegroup obj_svcg = servicegroup.get(ns_session, "http_svcg") print("statsvcg_byname result::name="+obj_svcg.servicegroupname+", servicetype="+obj_svcg.servicetype +",state="+obj_svcg.servicegroupeffectivestate) #Delete the virtual server #lbvserver.delete(ns_session, new_lbvserver_obj.name) #Save the configurations ns_session.save_config() #Logout from the NetScaler appliance ns_session.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 main(cls, args_): if (len(args_) < 3): print("Usage: run.bat <ip> <username> <password>") return config = MyFirstNitroApplication() config.ip = args_[1] config.username = args_[2] config.password = args_[3] try: #Create an instance of the nitro_service class to connect to the appliance ns_session = nitro_service(config.ip, "HTTP") ns_session.set_credential( config.username, config.password) #to make arguments more generic ns_session.timeout = 310 # To skip invalid arguments for Add/Update/Delete Operations (HTTP POST/PUT/DELETE Request) # Set this argument to True when newer version of SDK is used with older version of Netscaler ns_session.skipinvalidarg = True # By setting this argument to True, add operation will take care of adding or updating the entity without throwing any error ns_session.idempotent = True # By setting this argument to True HTTP Basic Auth will be used and there is no need for login() and logout() calls ns_session.basic_auth = False #Log on to the appliance using your credentials ns_session.login() #Enable the load balancing feature. features_to_be_enabled = "lb" ns_session.enable_features(features_to_be_enabled) #Create an instance of the virtual server class new_lbvserver_obj = lbvserver() #Create a new virtual server new_lbvserver_obj.name = "MyFirstLbVServer" new_lbvserver_obj.ipv46 = "10.102.29.88" new_lbvserver_obj.servicetype = "HTTP" new_lbvserver_obj.port = 80 new_lbvserver_obj.lbmethod = "ROUNDROBIN" lbvserver.add(ns_session, new_lbvserver_obj) #Retrieve the details of the virtual server new_lbvserver_obj = lbvserver.get(ns_session, new_lbvserver_obj.name) print("Name : " + new_lbvserver_obj.name + "\n" + "Protocol : " + new_lbvserver_obj.servicetype) #Delete the virtual server lbvserver.delete(ns_session, new_lbvserver_obj.name) #Save the configurations ns_session.save_config() #Logout from the NetScaler appliance ns_session.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 addLBVServers(self): """Configure the lbvservers for the NetScaler""" #Setup a new lbvserver1 newLBVS = lbvserver() newLBVS.name = self.vserver1 newLBVS.servicetype = "ssl" newLBVS.ipv46 = self.vip1 newLBVS.port = "443" newLBVS.persistencetype = "COOKIEINSERT" newLBVS.lbmethod = "ROUNDROBIN" try: #Add the lbvs response = lbvserver.add(self.ns_session, newLBVS) if response.severity and response.severity == "WARNING": print("\tWarning : " + response.message) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) newSVCBinding = lbvserver_service_binding() newSVCBinding.name = self.vserver1 newSVCBinding.servicename = self.service1 #newSVCBinding.weight = "1" #Add the binding! try: lbvserver_service_binding.add(self.ns_session, newSVCBinding) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) #Setup a new lbvserver2 newLBVS = lbvserver() newLBVS.name = self.vserver2 newLBVS.servicetype = "http" newLBVS.ipv46 = self.vip2 newLBVS.port = "80" newLBVS.persistencetype = "COOKIEINSERT" newLBVS.lbmethod = "ROUNDROBIN" try: #Add the lbvs response = lbvserver.add(self.ns_session, newLBVS) if response.severity and response.severity == "WARNING": print("\tWarning : " + response.message) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) newSVCBinding = lbvserver_service_binding() newSVCBinding.name = self.vserver2 newSVCBinding.servicename = self.service1 #newSVCBinding.weight = "1" #Add the binding! try: lbvserver_service_binding.add(self.ns_session, newSVCBinding) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) #Setup a new lbvserver3 newLBVS = lbvserver() newLBVS.name = self.vserver3 newLBVS.servicetype = "http" newLBVS.ipv46 = self.vip3 newLBVS.port = "80" newLBVS.persistencetype = "COOKIEINSERT" newLBVS.lbmethod = "ROUNDROBIN" try: #Add the lbvs response = lbvserver.add(self.ns_session, newLBVS) if response.severity and response.severity == "WARNING": print("\tWarning : " + response.message) except nitro_exception as e: print("Exception::errorcode=" + str(e.errorcode) + ",message=" + e.message) except Exception as e: print("Exception::message=" + str(e.args)) newSVCBinding = lbvserver_service_binding() newSVCBinding.name = self.vserver3 newSVCBinding.servicename = self.service1 #newSVCBinding.weight = "1" #Add the binding! try: lbvserver_service_binding.add(self.ns_session, newSVCBinding) 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