static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"s1","10.102.3.84",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : " + result.message); result = client.addserver("s2","10.102.3.83",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : " + result.message); result = client.addservice("src1",null,"s1",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice src1 : " + result.message); result = client.addservice("src2",null,"s2",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice src2 : " + result.message); result = client.addlbvserver("sslbase",vservicetypeEnum.SSL,"10.102.3.100",443,0xFFFFFFFF,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addlbvserver sslbase : " + result.message); result = client.bindlbvserver_service("sslbase","src1",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service sslbase : " + result.message); result = client.bindlbvserver_service("sslbase","src2",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service sslbase : " + result.message); result = client.addsslcertkey("server_cert","/nsconfig/ssl/certs/cert1.pem","/nsconfig/ssl/certs/cert1ky.pem",false,null,informatsEnum.VALNOTSET,enabledisabledEnum.VALNOTSET,0xFFFFFFFF); Console.WriteLine("addsslcertkey server_cert : " + result.message); result = client.bindsslcertkey_vserver("server_cert","sslbase",false); Console.WriteLine("bindsslcertkey_vserver server_cert : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
// API to run the script. void run_commands(string servername,string username,string password) { simpleResult result; getlbvserverResult getlbvserverresult; getserviceResult getserviceresult; // Initialized the soap client Console.WriteLine("\nConnecting to server "+servername+" ............\n"); client = new ClientService(servername); client.CookieContainer = new System.Net.CookieContainer(); // Login request result = client.login(username,password) ; Console.WriteLine("login : "******""); Console.WriteLine("getlbvserver : "+ getlbvserverresult.message); if (getlbvserverresult.rc.ToString() == "0") { for(int i =0 ; i < getlbvserverresult.List.Length;i++) { lbvserver obj; obj = (lbvserver)getlbvserverresult.List[i]; Console.WriteLine(obj.name+" :\t"+obj.ipaddress+":"+obj.port +"("+obj.servicetype+")"+ "\t" + obj.state); } } // Get lb vserver vip_1 getlbvserverresult = client.getlbvserver("vip_1"); Console.WriteLine("getlbvserver vip_1 : "+ getlbvserverresult.message); if (getlbvserverresult.rc.ToString() == "0") { lbvserver obj; obj = (lbvserver)getlbvserverresult.List[0]; Console.WriteLine("Services bound to vip_1 :"); for(int i =0 ; i < obj.servicename.Length;i++) { // get the bind service in formation. getserviceresult = client.getservice(obj.servicename[i],true,true); if (getserviceresult.rc.ToString() == "0") { service objsvc = (service)getserviceresult.List[0]; Console.WriteLine("\t"+objsvc.name+" :\t "+objsvc.ipaddress+":"+objsvc.port+"("+objsvc.servicetype+")" + "\t" + objsvc.svrstate); } } } getlbvserverresult = client.getlbvserver("nonesuch"); Console.WriteLine("getlbvserver(nonesuch) : "+ getlbvserverresult.message); result = client.logout(); Console.WriteLine("logout : " + result.message); }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"enablensfeature LB : "+ result.message); result = client.enablensfeature(featureEnum.CS); Console.WriteLine("enablensfeature CS : "+ result.message); result = client.addserver("s1", "10.102.3.91", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : "+ result.message); result = client.addserver("s2", "10.102.3.92", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : "+ result.message); result = client.addserver("s3", "10.102.3.93", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s3 : "+ result.message); result = client.addservice("srv1", null, "s1", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv1 : "+ result.message); result = client.addservice("srv2", null, "s2", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv2 : "+ result.message); result = client.addservice("srv3", null, "s3", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv3 : "+ result.message); result = client.addlbvserver("lbvip1", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip1 : " + result.message); result = client.addlbvserver("lbvip2", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip2 : " + result.message); result = client.addlbvserver("lbvip3", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip3 : " + result.message); result = client.bindlbvserver_service("lbvip1", "srv1", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip1 : "+ result.message); result = client.bindlbvserver_service("lbvip2", "srv2", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip2 : "+ result.message); result = client.bindlbvserver_service("lbvip3", "srv3", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip3 : "+ result.message); result = client.addcspolicy("contains_html", null, "REQ.HTTP.URL CONTAINS html", null); Console.WriteLine("addcspolicy contains_html : "+ result.message); result = client.addcspolicy("contains_txt", null, "REQ.HTTP.URL CONTAINS gif", null); Console.WriteLine("addcspolicy contains_txt : "+ result.message); result = client.addcspolicy("contains_gif", null, "REQ.HTTP.URL CONTAINS asp", null); Console.WriteLine("addcspolicy contains_gif : "+ result.message); result = client.addcsvserver("csvip", csvservicetypeEnum.HTTP, "10.102.3.54", 0xFFFFFFFF, 80, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addcsvserver csvip : " + result.message); result = client.bindcsvserver_targetvserver("csvip", "lbvip1", "contains_html", 5, null, vserverbindpointEnum.VALNOTSET, false, policylabelinvoketypeEnum.VALNOTSET, null); Console.WriteLine("bindcsvserver_targetvserver csvip : "+ result.message); result = client.bindcsvserver_targetvserver("csvip", "lbvip2", "contains_txt", 5, null, vserverbindpointEnum.VALNOTSET, false, policylabelinvoketypeEnum.VALNOTSET, null); Console.WriteLine("bindcsvserver_targetvserver csvip : "+ result.message); result = client.bindcsvserver_targetvserver("csvip", "lbvip3", "contains_gif", 5, null, vserverbindpointEnum.VALNOTSET, false, policylabelinvoketypeEnum.VALNOTSET, null); Console.WriteLine("bindcsvserver_targetvserver csvip : "+ result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"allow_sip",extaclactionEnum.ALLOW,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl allow_sip : " + result.message); result = client.setnsacl_srcip("allow_sip",true,xacloperatorEnum.VALNOTSET,"10.102.3.84"); Console.WriteLine("setnsacl_srcip allow_sip : " + result.message); result = client.addnsacl("allow_sip_range",extaclactionEnum.ALLOW,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl allow_sip_range : " + result.message); result = client.setnsacl_srcip("allow_sip_range",true,xacloperatorEnum.VALNOTSET,"10.102.3.1-10.102.3.255"); Console.WriteLine("setnsacl_srcip allow_sip_range : " + result.message); result = client.addnsacl("Deny_sipr",extaclactionEnum.DENY,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl Deny_sipr : " + result.message); result = client.setnsacl_srcip("Deny_sipr",true,xacloperatorEnum.VALNOTSET,"10.10.0.1-10.102.7.152"); Console.WriteLine("setnsacl_srcip Deny_sipr : " + result.message); result = client.addnsacl("allow_dip",extaclactionEnum.ALLOW,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl allow_dip : " + result.message); result = client.setnsacl_destip("allow_dip",true,xacloperatorEnum.VALNOTSET,"192.168.17.11"); Console.WriteLine("setnsacl_destip allow_dip : " + result.message); result = client.addnsacl("allow_dip_rng",extaclactionEnum.ALLOW,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl allow_dip_rng : " + result.message); result = client.setnsacl_destip("allow_dip_rng",true,xacloperatorEnum.VALNOTSET,"192.168.17.1-192.168.17.250"); Console.WriteLine("setnsacl_destip allow_dip_rng : " + result.message); result = client.addnsacl("deny_src_mac",extaclactionEnum.DENY,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl deny_src_mac : " + result.message); result = client.setnsacl_srcmac("deny_src_mac","00:0d:9d:54:64:6a"); Console.WriteLine("setnsacl_srcmac deny_src_mac : " + result.message); result = client.addnsacl("acl_user_priority",extaclactionEnum.ALLOW,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl acl_user_priority : " + result.message); result = client.setnsacl_priority("acl_user_priority",1); Console.WriteLine("setnsacl_priority acl_user_priority : " + result.message); result = client.addnsacl("Deny_dip_intf",extaclactionEnum.DENY,0xFFFFFFFF,extaclprotoenumEnum.VALNOTSET,false,0xFFFFFFFF,0xFFFFFFFF); Console.WriteLine("addnsacl Deny_dip_intf : " + result.message); result = client.disablensacl("allow_sip"); Console.WriteLine("disablensacl allow_sip : " + result.message); result = client.rmnsacl("allow_sip"); Console.WriteLine("rmnsacl allow_sip : " + result.message); result = client.clearnsacls(); Console.WriteLine("clearnsacls Deny_sip_dip_dport : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"ca_cert","/nsconfig/ssl/certs/ca_cert.pem",null,false,null,informatsEnum.VALNOTSET,enabledisabledEnum.VALNOTSET,0xFFFFFFFF); Console.WriteLine("addsslcertkey ca_cert : " + result.message); result = client.addsslcertkey("root_cert","/nsconfig/ssl/certs/root_cert.pem",null,false,null,informatsEnum.VALNOTSET,enabledisabledEnum.VALNOTSET,0xFFFFFFFF); Console.WriteLine("addsslcertkey root_cert : " + result.message); result = client.addsslcrl("crl1","/var/netscaler/ssl/crl.pem",informatsEnum.VALNOTSET); Console.WriteLine("addsslcrl crl1 : " + result.message); result = client.setsslcrl_cacert("crl1","ca_cert"); Console.WriteLine("setsslcrl_cacert crl1 : " + result.message); result = client.addsslcrl("crl1","/var/netscaler/ssl/crl.pem",informatsEnum.VALNOTSET); Console.WriteLine("addsslcrl crl1 : " + result.message); result = client.setsslcrl_refresh("crl1",enabledisabledEnum.ENABLED); Console.WriteLine("setsslcrl_refresh crl1 : " + result.message); result = client.setsslcrl_cacert("crl1","ca_cert"); Console.WriteLine("setsslcrl_cacert crl1 : " + result.message); result = client.setsslcrl_server("crl1","10.102.3.120"); Console.WriteLine("setsslcrl_server crl1 : " + result.message); result = client.setsslcrl_method("crl1",refreshmethodEnum.HTTP,null); Console.WriteLine("setsslcrl_method crl1 : " + result.message); result = client.setsslcrl_port("crl1",80); Console.WriteLine("setsslcrl_port crl1 : " + result.message); result = client.setsslcrl_interval("crl1",refreshintervlEnum.WEEKLY); Console.WriteLine("setsslcrl_interval crl1 : " + result.message); result = client.addsslcrl("crl1","/var/netscaler/ssl/crl.pem",informatsEnum.VALNOTSET); Console.WriteLine("addsslcrl crl1 : " + result.message); result = client.setsslcrl_refresh("crl1",enabledisabledEnum.ENABLED); Console.WriteLine("setsslcrl_refresh crl1 : " + result.message); result = client.setsslcrl_cacert("crl1","ca_cert"); Console.WriteLine("setsslcrl_cacert crl1 : " + result.message); result = client.setsslcrl_server("crl1","10.102.3.120"); Console.WriteLine("setsslcrl_server crl1 : " + result.message); result = client.setsslcrl_method("crl1",refreshmethodEnum.LDAP,null); Console.WriteLine("setsslcrl_method crl1 : " + result.message); result = client.setsslcrl_port("crl1",389); Console.WriteLine("setsslcrl_port crl1 : " + result.message); result = client.setsslcrl_basedn("crl1","cn=Manager,dc=my-domain,dc=com"); Console.WriteLine("setsslcrl_basedn crl1 : " + result.message); result = client.setsslcrl_interval("crl1",refreshintervlEnum.WEEKLY); Console.WriteLine("setsslcrl_interval crl1 : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"enablensfeature REWRITE : "+ result.message); result = client.addrewriteaction("rewrite_act1", actionrewritetypeEnum.DELETE, "HTTP.RES.HEADER(\"Server\").VALUE(0)", null, yesnoEnum.VALNOTSET); Console.WriteLine("addrewriteaction rewrite_act1 : " + result.message); result = client.addrewritepolicy("rewrite_pol1", "HTTP.RES.HEADER(\"Server\").CONTAINS(\"IIS\")", "rewrite_act1", null); Console.WriteLine("addrewritepolicy rewrite_pol1 : " + result.message); result = client.bindrewriteglobal_policy("rewrite_pol1", 1, "END", rwglobalbindpointEnum.VALNOTSET, false, policylabelinvoketypeEnum.VALNOTSET, null); Console.WriteLine("bindrewriteglobal_policy rewrite_pol1 : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"user1", "passwd1"); Console.WriteLine("addsystemuser user1 : "+ result.message); result = client.addsystemuser("user2", "passwd2"); Console.WriteLine("addsystemuser user2 : "+ result.message); result = client.bindsystemuser_policy("user1", "read-only", 1); Console.WriteLine("bindsystemuser_policy user1 : "+ result.message); result = client.bindsystemuser_policy("user1", "operator", 2); Console.WriteLine("bindsystemuser_policy user1 : "+ result.message); result = client.addsystemgroup("group1"); Console.WriteLine("addsystemgroup group1 : "+ result.message); result = client.bindsystemgroup_user("group1", "user2"); Console.WriteLine("bindsystemgroup_user group1 : " + result.message); result = client.bindsystemgroup_policy("group1", "read-only", 1); Console.WriteLine("bindsystemgroup_policy group1 : "+ result.message); result = client.addsystemcmdpolicy("add_pol1", allowdenyEnum.ALLOW, "^add.*"); Console.WriteLine("addsystemcmdpolicy add_pol1 : "+ result.message); result = client.bindsystemuser_policy("user1", "add_pol1", 3); Console.WriteLine("bindsystemuser_policy user1 : "+ result.message); getsystemuserResult getsystemuserresult1 = client.getsystemuser(null); Console.WriteLine("getsystemuser null : "+ getsystemuserresult1.message); if ((getsystemuserresult1.List != null) && (getsystemuserresult1.List.Length > 0)) { for (int i = 0; i < getsystemuserresult1.List.Length; i++) { systemuser obj; obj = (systemuser)getsystemuserresult1.List[i]; Console.WriteLine(obj.username + "\t" + obj.groupname + "\t" + obj.policyname + "\t" + obj.priority + "\t"); } } getsystemgroupResult getsystemgroupresult2 = client.getsystemgroup(null); Console.WriteLine("getsystemgroup null : "+ getsystemgroupresult2.message); if ((getsystemgroupresult2.List != null) && (getsystemgroupresult2.List.Length > 0)) { for (int i = 0; i < getsystemgroupresult2.List.Length; i++) { systemgroup obj; obj = (systemgroup)getsystemgroupresult2.List[i]; Console.WriteLine(obj.groupname + "\t" + obj.username + "\t" + obj.policyname + "\t" + obj.priority + "\t"); } } result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"enablensfeature LB : " + result.message); result = client.addserver("s1","10.102.3.81",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : " + result.message); result = client.addserver("s2","10.102.3.82",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : " + result.message); result = client.addservice("svc1",null,"s1",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice svc1 : " + result.message); result = client.addservice("svc2",null,"s2",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice svc2 : " + result.message); getserverResult getserverresult1 = client.getserver(null,false); Console.WriteLine("getserver null : " + getserverresult1.message); if ( (getserverresult1.List != null) && (getserverresult1.List.Length > 0)) { for(int i =0 ; i < getserverresult1.List.Length;i++) { server obj; obj = (server) getserverresult1.List[i]; Console.WriteLine( obj.name + "\t" + obj.internaL + "\t" + obj.ipaddress + "\t" + obj.state + "\t" + obj.domain + "\t" + obj.domainresolveretry + "\t" + obj.servicename + "\t" + obj.servicegroupname + "\t" + obj.translationip + "\t" + obj.translationmask + "\t" ); } } getserviceResult getserviceresult2 = client.getservice(null,false,false); Console.WriteLine("getservice null : " + getserviceresult2.message); if ( (getserviceresult2.List != null) && (getserviceresult2.List.Length > 0)) { for(int i =0 ; i < getserviceresult2.List.Length;i++) { service obj; obj = (service) getserviceresult2.List[i]; Console.WriteLine( obj.name + "\t" + obj.all + "\t" + obj.internaL + "\t" + obj.servername + "\t" + obj.servicetype + "\t" + obj.serviceconftype + "\t" + obj.port + "\t" + obj.value + "\t" + obj.cleartextport + "\t" + obj.gslb + "\t" + obj.cachetype + "\t" + obj.maxclient + "\t" + obj.maxreq + "\t" + obj.cacheable + "\t" + obj.cip + "\t" + obj.cipheader + "\t" + obj.usip + "\t" + obj.useproxyport + "\t" + obj.sc + "\t" + obj.weight + "\t" + obj.sp + "\t" + obj.rtspsessionidremap + "\t" + obj.failedprobes + "\t" + obj.clttimeout + "\t" + obj.totalprobes + "\t" + obj.svrtimeout + "\t" + obj.serverid + "\t" + obj.cka + "\t" + obj.tcpb + "\t" + obj.cmp + "\t" + obj.maxbandwidth + "\t" + obj.accessdown + "\t" + obj.svrstate + "\t" + obj.delay + "\t" + obj.ipaddress + "\t" + obj.monitorname + "\t" + obj.monthreshold + "\t" + obj.monstate + "\t" + obj.monstatcode + "\t" + obj.responsetime + "\t" + obj.downstateflush + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.timesincelaststatechange + "\t" + obj.tickssincelaststatechange + "\t" + obj.stateupdatereason + "\t" + obj.runningmonstate + "\t" + obj.scpolicyname + "\t" + obj.dospolicyname + "\t" ); } } result = client.addlbvserver("vlb1",vservicetypeEnum.HTTP,"10.102.3.101",80,0xFFFFFFFF,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addlbvserver vlb1 : " + result.message); result = client.addlbvserver("vlb2",vservicetypeEnum.SSL,"10.102.3.102",443,0xFFFFFFFF,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addlbvserver vlb2 : " + result.message); getlbvserverResult getlbvserverresult3 = client.getlbvserver("vlb1"); Console.WriteLine("getlbvserver vlb1 : " + getlbvserverresult3.message); if ( (getlbvserverresult3.List != null) && (getlbvserverresult3.List.Length > 0)) { for(int i =0 ; i < getlbvserverresult3.List.Length;i++) { lbvserver obj; obj = (lbvserver) getlbvserverresult3.List[i]; Console.WriteLine( obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.value + "\t" + obj.ipaddress + "\t" + obj.ipmapping + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.lbrrreason + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.policyname + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.dynamicweight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sopersistencetimeout + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.health + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.rule + "\t" + obj.resrule + "\t" + obj.gotopriorityexpression + "\t" + obj.ruletype + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.timeout + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.rtspnat + "\t" + obj.sessionless + "\t" + obj.map + "\t" + obj.connfailover + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.disableprimaryondown + "\t" + obj.thresholdvalue + "\t" + obj.invoke + "\t" + obj.labeltype + "\t" + obj.labelname + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.tickssincelaststatechange + "\t" + obj.hits + "\t" + obj.svcipaddress + "\t" + obj.svcport + "\t" + obj.svctype + "\t" + obj.svcstate + "\t" + obj.servicegroupname + "\t" + obj.scpolicyname + "\t" + obj.scpolicypriority + "\t" + obj.dospolicyname + "\t" + obj.dospolicypriority + "\t" + obj.rwpolicyname + "\t" + obj.rwpolicypriority + "\t" + obj.rwpolicygotoprioexpression + "\t" + obj.rwpolicybindpoint + "\t" + obj.rwinvoke + "\t" + obj.rwpolicyinvokelabeltype + "\t" + obj.rwpolicyinvokelabelname + "\t" + obj.cachepolicyname + "\t" + obj.cachepolicypriority + "\t" + obj.cachepolicygotoprioexpression + "\t" + obj.cachepolicybindpoint + "\t" + obj.cacheinvoke + "\t" + obj.cachepolicyinvokelabeltype + "\t" + obj.cachepolicyinvokelabelname + "\t" + obj.rsppolicyname + "\t" + obj.rsppolicypriority + "\t" + obj.rsppolicygotoprioexpression + "\t" + obj.rspinvoke + "\t" + obj.rsppolicyinvokelabeltype + "\t" + obj.rsppolicyinvokelabelname + "\t" + obj.csvserver + "\t" + obj.cswpolicyname + "\t" + obj.priority + "\t" ); } } getlbvserverResult getlbvserverresult4 = client.getlbvserver("vlb2"); Console.WriteLine("getlbvserver vlb2 : " + getlbvserverresult4.message); if ( (getlbvserverresult4.List != null) && (getlbvserverresult4.List.Length > 0)) { for(int i =0 ; i < getlbvserverresult4.List.Length;i++) { lbvserver obj; obj = (lbvserver) getlbvserverresult4.List[i]; Console.WriteLine( obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.value + "\t" + obj.ipaddress + "\t" + obj.ipmapping + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.lbrrreason + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.policyname + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.dynamicweight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sopersistencetimeout + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.health + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.rule + "\t" + obj.resrule + "\t" + obj.gotopriorityexpression + "\t" + obj.ruletype + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.timeout + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.rtspnat + "\t" + obj.sessionless + "\t" + obj.map + "\t" + obj.connfailover + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.disableprimaryondown + "\t" + obj.thresholdvalue + "\t" + obj.invoke + "\t" + obj.labeltype + "\t" + obj.labelname + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.tickssincelaststatechange + "\t" + obj.hits + "\t" + obj.svcipaddress + "\t" + obj.svcport + "\t" + obj.svctype + "\t" + obj.svcstate + "\t" + obj.servicegroupname + "\t" + obj.scpolicyname + "\t" + obj.scpolicypriority + "\t" + obj.dospolicyname + "\t" + obj.dospolicypriority + "\t" + obj.rwpolicyname + "\t" + obj.rwpolicypriority + "\t" + obj.rwpolicygotoprioexpression + "\t" + obj.rwpolicybindpoint + "\t" + obj.rwinvoke + "\t" + obj.rwpolicyinvokelabeltype + "\t" + obj.rwpolicyinvokelabelname + "\t" + obj.cachepolicyname + "\t" + obj.cachepolicypriority + "\t" + obj.cachepolicygotoprioexpression + "\t" + obj.cachepolicybindpoint + "\t" + obj.cacheinvoke + "\t" + obj.cachepolicyinvokelabeltype + "\t" + obj.cachepolicyinvokelabelname + "\t" + obj.rsppolicyname + "\t" + obj.rsppolicypriority + "\t" + obj.rsppolicygotoprioexpression + "\t" + obj.rspinvoke + "\t" + obj.rsppolicyinvokelabeltype + "\t" + obj.rsppolicyinvokelabelname + "\t" + obj.csvserver + "\t" + obj.cswpolicyname + "\t" + obj.priority + "\t" ); } } result = client.bindlbvserver_service("vlb1","svc1",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb1 : " + result.message); result = client.bindlbvserver_service("vlb1","svc2",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb1 : " + result.message); result = client.bindlbvserver_service("vlb2","svc1",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb2 : " + result.message); result = client.bindlbvserver_service("vlb2","svc2",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb2 : " + result.message); getvserverResult getvserverresult5 = client.getvserver("vlb1"); Console.WriteLine("getvserver vlb1 : " + getvserverresult5.message); if ( (getvserverresult5.List != null) && (getvserverresult5.List.Length > 0)) { for(int i =0 ; i < getvserverresult5.List.Length;i++) { vserver obj; obj = (vserver) getvserverresult5.List[i]; Console.WriteLine( obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.ipaddress + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.value + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.rule + "\t" + obj.policyname + "\t" + obj.hits + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.timeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.sessionless + "\t" + obj.url + "\t" + obj.reuse + "\t" + obj.destinationvserver + "\t" + obj.via + "\t" + obj.flags + "\t" + obj.connfailover + "\t" + obj.casesensitive + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" ); } } getvserverResult getvserverresult6 = client.getvserver("vlb2"); Console.WriteLine("getvserver vlb2 : " + getvserverresult6.message); if ( (getvserverresult6.List != null) && (getvserverresult6.List.Length > 0)) { for(int i =0 ; i < getvserverresult6.List.Length;i++) { vserver obj; obj = (vserver) getvserverresult6.List[i]; Console.WriteLine( obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.ipaddress + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.value + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.rule + "\t" + obj.policyname + "\t" + obj.hits + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.timeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.sessionless + "\t" + obj.url + "\t" + obj.reuse + "\t" + obj.destinationvserver + "\t" + obj.via + "\t" + obj.flags + "\t" + obj.connfailover + "\t" + obj.casesensitive + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" ); } } result = client.bindlbgroup_vserver("grp1","vlb1,vlb2"); Console.WriteLine("bindlbgroup_vserver grp1 : " + result.message); getlbgroupResult getlbgroupresult7 = client.getlbgroup("grp1"); Console.WriteLine("getlbgroup grp1 : " + getlbgroupresult7.message); if ( (getlbgroupresult7.List != null) && (getlbgroupresult7.List.Length > 0)) { for(int i =0 ; i < getlbgroupresult7.List.Length;i++) { lbgroup obj; obj = (lbgroup) getlbgroupresult7.List[i]; Console.WriteLine( obj.name + "\t" + obj.vservername + "\t" + obj.persistencetype + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.persistmask + "\t" + obj.cookiedomain + "\t" + obj.timeout + "\t" ); } } result = client.setlbgroup_persistencetype("grp1",grppersisttypeEnum.COOKIEINSERT); Console.WriteLine("setlbgroup_persistencetype grp1 : " + result.message); result = client.setlbgroup_timeout("grp1",10); Console.WriteLine("setlbgroup_timeout grp1 : " + result.message); getlbgroupResult getlbgroupresult8 = client.getlbgroup("grp1"); Console.WriteLine("getlbgroup grp1 : " + getlbgroupresult8.message); if ( (getlbgroupresult8.List != null) && (getlbgroupresult8.List.Length > 0)) { for(int i =0 ; i < getlbgroupresult8.List.Length;i++) { lbgroup obj; obj = (lbgroup) getlbgroupresult8.List[i]; Console.WriteLine( obj.name + "\t" + obj.vservername + "\t" + obj.persistencetype + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.persistmask + "\t" + obj.cookiedomain + "\t" + obj.timeout + "\t" ); } } getvserverResult getvserverresult9 = client.getvserver(null); Console.WriteLine("getvserver null : " + getvserverresult9.message); if ( (getvserverresult9.List != null) && (getvserverresult9.List.Length > 0)) { for(int i =0 ; i < getvserverresult9.List.Length;i++) { vserver obj; obj = (vserver) getvserverresult9.List[i]; Console.WriteLine( obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.ipaddress + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.value + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.rule + "\t" + obj.policyname + "\t" + obj.hits + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.timeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.sessionless + "\t" + obj.url + "\t" + obj.reuse + "\t" + obj.destinationvserver + "\t" + obj.via + "\t" + obj.flags + "\t" + obj.connfailover + "\t" + obj.casesensitive + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" ); } } result = client.addsslcertkey("test_cert","/nsconfig/ssl/1024cert.pem","/nsconfig/ssl/1024key.pem",false,null,informatsEnum.VALNOTSET,enabledisabledEnum.VALNOTSET,0xFFFFFFFF); Console.WriteLine("addsslcertkey test_cert : " + result.message); result = client.bindsslcertkey_vserver("test_cert","vlb2",false); Console.WriteLine("bindsslcertkey_vserver test_cert : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
// API to run the script. void run_commands(string servername,string username,string password) { simpleResult result; statlbvserverResult statlbvserverresult; Console.WriteLine("\nConnecting to server "+servername+" ............\n"); client = new ClientService(servername); client.CookieContainer = new System.Net.CookieContainer(); // Login request result = client.login(username,password) ; Console.WriteLine("login : "******"vip_1"); Console.WriteLine("stat lb vserver vip_1 : "+ statlbvserverresult.message); if (statlbvserverresult.rc.ToString() == "0") { lbvserverstats obj; obj = (lbvserverstats) statlbvserverresult.List[0]; Console.WriteLine("\t Name : "+ obj.name+" ("+obj.primaryipaddress+":"+obj.primaryport+")"); Console.WriteLine("\t State : "+ obj.state+" Total Request : "+obj.totalrequests+" Total Response"+obj.totalresponses+")"); } // log out result = client.logout(); Console.WriteLine("logout : " + result.message); }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"user1","passwd1"); Console.WriteLine("addsystemuser user1 : " + result.message); result = client.addsystemuser("user2","passwd2"); Console.WriteLine("addsystemuser user2 : " + result.message); result = client.bindsystemuser_policy("user1","read-only",1); Console.WriteLine("bindsystemuser_policy user1 : " + result.message); result = client.bindsystemuser_policy("user1","operator",2); Console.WriteLine("bindsystemuser_policy user1 : " + result.message); result = client.addsystemgroup("group1"); Console.WriteLine("addsystemgroup group1 : " + result.message); result = client.bindsystemgroup_user("group1","user2"); Console.WriteLine("bindsystemgroup_user group1 : " + result.message); result = client.bindsystemgroup_policy("group1","read-only",1); Console.WriteLine("bindsystemgroup_policy group1 : " + result.message); result = client.addsystemcmdpolicy("add_pol1",allowdenyEnum.ALLOW,"^add.*"); Console.WriteLine("addsystemcmdpolicy add_pol1 : " + result.message); result = client.bindsystemuser_policy("user1","add_pol1",3); Console.WriteLine("bindsystemuser_policy user1 : " + result.message); getsystemuserResult getsystemuserresult1 = client.getsystemuser(null); Console.WriteLine("getsystemuser null : " + getsystemuserresult1.message); if ( (getsystemuserresult1.List != null) && (getsystemuserresult1.List.Length > 0)) { for(int i =0 ; i < getsystemuserresult1.List.Length;i++) { systemuser obj; obj = (systemuser) getsystemuserresult1.List[i]; Console.WriteLine( obj.username + "\t" + obj.groupname + "\t" + obj.policyname + "\t" + obj.priority + "\t" ); } } getsystemgroupResult getsystemgroupresult2 = client.getsystemgroup(null); Console.WriteLine("getsystemgroup null : " + getsystemgroupresult2.message); if ( (getsystemgroupresult2.List != null) && (getsystemgroupresult2.List.Length > 0)) { for(int i =0 ; i < getsystemgroupresult2.List.Length;i++) { systemgroup obj; obj = (systemgroup) getsystemgroupresult2.List[i]; Console.WriteLine( obj.groupname + "\t" + obj.username + "\t" + obj.policyname + "\t" + obj.priority + "\t" ); } } result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"enablensfeature LB : " + result.message); result = client.enablensfeature(featureEnum.CS); Console.WriteLine("enablensfeature CS : " + result.message); result = client.addserver("s1","10.102.3.91",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : " + result.message); result = client.addserver("s2","10.102.3.92",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : " + result.message); result = client.addserver("s3","10.102.3.93",null,enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s3 : " + result.message); result = client.addservice("srv1",null,"s1",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv1 : " + result.message); result = client.addservice("srv2",null,"s2",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv2 : " + result.message); result = client.addservice("srv3",null,"s3",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv3 : " + result.message); result = client.addlbvserver("lbvip1",vservicetypeEnum.HTTP,null,0xFFFFFFFF,0xFFFFFFFF,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addlbvserver lbvip1 : " + result.message); result = client.addlbvserver("lbvip2",vservicetypeEnum.HTTP,null,0xFFFFFFFF,0xFFFFFFFF,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addlbvserver lbvip2 : " + result.message); result = client.addlbvserver("lbvip3",vservicetypeEnum.HTTP,null,0xFFFFFFFF,0xFFFFFFFF,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addlbvserver lbvip3 : " + result.message); result = client.bindlbvserver_service("lbvip1","srv1",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip1 : " + result.message); result = client.bindlbvserver_service("lbvip2","srv2",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip2 : " + result.message); result = client.bindlbvserver_service("lbvip3","srv3",0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip3 : " + result.message); result = client.addcspolicy("contains_html",null,"REQ.HTTP.URL CONTAINS html",null); Console.WriteLine("addcspolicy contains_html : " + result.message); result = client.addcspolicy("contains_txt",null,"REQ.HTTP.URL CONTAINS gif",null); Console.WriteLine("addcspolicy contains_txt : " + result.message); result = client.addcspolicy("contains_gif",null,"REQ.HTTP.URL CONTAINS asp",null); Console.WriteLine("addcspolicy contains_gif : " + result.message); result = client.addcsvserver("csvip",csvservicetypeEnum.HTTP,"10.102.3.54",0xFFFFFFFF,80,enabledisabledEnum.VALNOTSET,null); Console.WriteLine("addcsvserver csvip : " + result.message); result = client.bindcsvserver_targetvserver("csvip","lbvip1","contains_html",5,null,vserverbindpointEnum.VALNOTSET,false,policylabelinvoketypeEnum.VALNOTSET,null); Console.WriteLine("bindcsvserver_targetvserver csvip : " + result.message); result = client.bindcsvserver_targetvserver("csvip","lbvip2","contains_txt",5,null,vserverbindpointEnum.VALNOTSET,false,policylabelinvoketypeEnum.VALNOTSET,null); Console.WriteLine("bindcsvserver_targetvserver csvip : " + result.message); result = client.bindcsvserver_targetvserver("csvip","lbvip3","contains_gif",5,null,vserverbindpointEnum.VALNOTSET,false,policylabelinvoketypeEnum.VALNOTSET,null); Console.WriteLine("bindcsvserver_targetvserver csvip : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"allow_sip", extaclactionEnum.ALLOW, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl allow_sip : " + result.message); result = client.setnsacl_srcip("allow_sip", true, xacloperatorEnum.VALNOTSET, "10.102.3.84"); Console.WriteLine("setnsacl_srcip allow_sip : "+ result.message); result = client.addnsacl("allow_sip_range", extaclactionEnum.ALLOW, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl allow_sip_range : " + result.message); result = client.setnsacl_srcip("allow_sip_range", true, xacloperatorEnum.VALNOTSET, "10.102.3.1-10.102.3.255"); Console.WriteLine("setnsacl_srcip allow_sip_range : "+ result.message); result = client.addnsacl("Deny_sipr", extaclactionEnum.DENY, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl Deny_sipr : " + result.message); result = client.setnsacl_srcip("Deny_sipr", true, xacloperatorEnum.VALNOTSET, "10.10.0.1-10.102.7.152"); Console.WriteLine("setnsacl_srcip Deny_sipr : "+ result.message); result = client.addnsacl("allow_dip", extaclactionEnum.ALLOW, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl allow_dip : " + result.message); result = client.setnsacl_destip("allow_dip", true, xacloperatorEnum.VALNOTSET, "192.168.17.11"); Console.WriteLine("setnsacl_destip allow_dip : "+ result.message); result = client.addnsacl("allow_dip_rng", extaclactionEnum.ALLOW, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl allow_dip_rng : " + result.message); result = client.setnsacl_destip("allow_dip_rng", true, xacloperatorEnum.VALNOTSET, "192.168.17.1-192.168.17.250"); Console.WriteLine("setnsacl_destip allow_dip_rng : "+ result.message); result = client.addnsacl("deny_src_mac", extaclactionEnum.DENY, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl deny_src_mac : " + result.message); result = client.setnsacl_srcmac("deny_src_mac", "00:0d:9d:54:64:6a"); Console.WriteLine("setnsacl_srcmac deny_src_mac : "+ result.message); result = client.addnsacl("acl_user_priority", extaclactionEnum.ALLOW, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl acl_user_priority : " + result.message); result = client.setnsacl_priority("acl_user_priority", 1); Console.WriteLine("setnsacl_priority acl_user_priority : "+ result.message); result = client.addnsacl("Deny_dip_intf", extaclactionEnum.DENY, 0xFFFFFFFF, extaclprotoenumEnum.VALNOTSET, false, 0xFFFFFFFF, 0xFFFFFFFF); Console.WriteLine("addnsacl Deny_dip_intf : " + result.message); result = client.disablensacl("allow_sip"); Console.WriteLine("disablensacl allow_sip : " + result.message); result = client.rmnsacl("allow_sip"); Console.WriteLine("rmnsacl allow_sip : "+ result.message); result = client.clearnsacls(); Console.WriteLine("clearnsacls Deny_sip_dip_dport : "+ result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"enablensfeature REWRITE : " + result.message); result = client.addrewriteaction("rewrite_act1",actionrewritetypeEnum.DELETE,"HTTP.RES.HEADER(\"Server\").VALUE(0)",null,yesnoEnum.VALNOTSET); Console.WriteLine("addrewriteaction rewrite_act1 : " + result.message); result = client.addrewritepolicy("rewrite_pol1","HTTP.RES.HEADER(\"Server\").CONTAINS(\"IIS\")","rewrite_act1",null); Console.WriteLine("addrewritepolicy rewrite_pol1 : " + result.message); result = client.bindrewriteglobal_policy("rewrite_pol1",1,"END",rwglobalbindpointEnum.VALNOTSET,false,policylabelinvoketypeEnum.VALNOTSET,null); Console.WriteLine("bindrewriteglobal_policy rewrite_pol1 : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"enablensfeature CMP : "+ result.message); result = client.addserver("s1", "10.102.3.91", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : "+ result.message); result = client.addserver("s2", "10.102.3.92", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : "+ result.message); result = client.addservice("srv1", null, "s1", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv1 : "+ result.message); result = client.addservice("srv2", null, "s2", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv2 : "+ result.message); result = client.addlbvserver("lbvip1", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip1 : " + result.message); result = client.addlbvserver("lbvip2", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip2 : " + result.message); result = client.bindlbvserver_service("lbvip1", "srv1", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip1 : "+ result.message); result = client.bindlbvserver_service("lbvip2", "srv2", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip2 : "+ result.message); result = client.setservice_cmp("srv1", yesnoEnum.YES); Console.WriteLine("setservice_cmp srv1 : "+ result.message); result = client.setservice_cmp("srv2", yesnoEnum.NO); Console.WriteLine("setservice_cmp srv2 : "+ result.message); result = client.addcmppolicy("cmp1", "url == /testsite/file5.html", "nocompress"); Console.WriteLine("addcmppolicy cmp1 : " + result.message); result = client.bindcmpglobal_policy("cmp1", 0xFFFFFFFF, enabledisabledEnum.VALNOTSET); Console.WriteLine("bindcmpglobal_policy cmp1 : " + result.message); result = client.addpolicyexpression("ex1", "RES.HTTP.HEADER Content-Type CONTAINS application/msword"); Console.WriteLine("addpolicyexpression ex1 : "+ result.message); result = client.addcmppolicy("cmp2", "ex1", "deflate"); Console.WriteLine("addcmppolicy cmp2 : " + result.message); result = client.bindcmpglobal_policy("cmp2", 0xFFFFFFFF, enabledisabledEnum.VALNOTSET); Console.WriteLine("bindcmpglobal_policy cmp2 : " + result.message); result = client.addcmppolicy("cmp3", "url contains file50 || RES.HTTP.HEADER Content-Type CONTAINS text/css", "deflate"); Console.WriteLine("addcmppolicy cmp3 : " + result.message); result = client.addpolicyexpression("ex2", "HEADER User-Agent CONTAINS MSIE"); Console.WriteLine("addpolicyexpression ex2 : "+ result.message); result = client.addpolicyexpression("ex3", "RES.HTTP.HEADER Content-Type CONTAINS application/vnd.ms-excel"); Console.WriteLine("addpolicyexpression ex3 : "+ result.message); result = client.addcmppolicy("cmp4", "ex2&&ex3", "gzip"); Console.WriteLine("addcmppolicy cmp4 : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
// API to run the script. void run_commands(string servername,string username,string password) { simpleResult result; // Initialized the soap client Console.WriteLine("\nConnecting to server "+servername+" ............\n"); client = new ClientService(servername); client.CookieContainer = new System.Net.CookieContainer(); // Login request result = client.login(username,password) ; Console.WriteLine("login : "******"0") { // Remove vserver result = client.rmlbvserver("vip_1"); Console.WriteLine("rm lb vserver vip_1 : " + result.message); // Remove service s1 result = client.rmservice("s1"); Console.WriteLine("rm service s1 : " + result.message); // Remove service s2 result = client.rmservice("s2"); Console.WriteLine("rm service s2 : " + result.message); // Save config result = client.savensconfig(); Console.WriteLine("save config : " + result.message); // Logout result = client.logout(); Console.WriteLine("logout : " + result.message); } }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"ca_cert", "/nsconfig/ssl/certs/ca_cert.pem", null, false, null, informatsEnum.VALNOTSET, enabledisabledEnum.VALNOTSET, 0xFFFFFFFF); Console.WriteLine("addsslcertkey ca_cert : "+ result.message); result = client.addsslcertkey("root_cert", "/nsconfig/ssl/certs/root_cert.pem", null, false, null, informatsEnum.VALNOTSET, enabledisabledEnum.VALNOTSET, 0xFFFFFFFF); Console.WriteLine("addsslcertkey root_cert : "+ result.message); result = client.addsslcrl("crl1", "/var/netscaler/ssl/crl.pem", informatsEnum.VALNOTSET); Console.WriteLine("addsslcrl crl1 : "+ result.message); result = client.setsslcrl_cacert("crl1", "ca_cert"); Console.WriteLine("setsslcrl_cacert crl1 : " + result.message); result = client.addsslcrl("crl1", "/var/netscaler/ssl/crl.pem", informatsEnum.VALNOTSET); Console.WriteLine("addsslcrl crl1 : "+ result.message); result = client.setsslcrl_refresh("crl1", enabledisabledEnum.ENABLED); Console.WriteLine("setsslcrl_refresh crl1 : "+ result.message); result = client.setsslcrl_cacert("crl1", "ca_cert"); Console.WriteLine("setsslcrl_cacert crl1 : " + result.message); result = client.setsslcrl_server("crl1", "10.102.3.120"); Console.WriteLine("setsslcrl_server crl1 : " + result.message); result = client.setsslcrl_method("crl1", refreshmethodEnum.HTTP, null); Console.WriteLine("setsslcrl_method crl1 : " + result.message); result = client.setsslcrl_port("crl1", 80); Console.WriteLine("setsslcrl_port crl1 : "+ result.message); result = client.setsslcrl_interval("crl1", refreshintervlEnum.WEEKLY); Console.WriteLine("setsslcrl_interval crl1 : "+ result.message); result = client.addsslcrl("crl1", "/var/netscaler/ssl/crl.pem", informatsEnum.VALNOTSET); Console.WriteLine("addsslcrl crl1 : "+ result.message); result = client.setsslcrl_refresh("crl1", enabledisabledEnum.ENABLED); Console.WriteLine("setsslcrl_refresh crl1 : "+ result.message); result = client.setsslcrl_cacert("crl1", "ca_cert"); Console.WriteLine("setsslcrl_cacert crl1 : " + result.message); result = client.setsslcrl_server("crl1", "10.102.3.120"); Console.WriteLine("setsslcrl_server crl1 : " + result.message); result = client.setsslcrl_method("crl1", refreshmethodEnum.LDAP, null); Console.WriteLine("setsslcrl_method crl1 : " + result.message); result = client.setsslcrl_port("crl1", 389); Console.WriteLine("setsslcrl_port crl1 : "+ result.message); result = client.setsslcrl_basedn("crl1", "cn=Manager,dc=my-domain,dc=com"); Console.WriteLine("setsslcrl_basedn crl1 : " + result.message); result = client.setsslcrl_interval("crl1", refreshintervlEnum.WEEKLY); Console.WriteLine("setsslcrl_interval crl1 : "+ result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server " + serverip + " ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username, password); Console.WriteLine("login : "******"enablensfeature LB : "+ result.message); result = client.addserver("s1", "10.102.3.81", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : "+ result.message); result = client.addserver("s2", "10.102.3.82", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : "+ result.message); result = client.addservice("svc1", null, "s1", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice svc1 : "+ result.message); result = client.addservice("svc2", null, "s2", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice svc2 : "+ result.message); getserverResult getserverresult1 = client.getserver(null, false); Console.WriteLine("getserver null : "+ getserverresult1.message); if ((getserverresult1.List != null) && (getserverresult1.List.Length > 0)) { for (int i = 0; i < getserverresult1.List.Length; i++) { server obj; obj = (server)getserverresult1.List[i]; Console.WriteLine(obj.name + "\t" + obj.internaL + "\t" + obj.ipaddress + "\t" + obj.state + "\t" + obj.domain + "\t" + obj.domainresolveretry + "\t" + obj.servicename + "\t" + obj.servicegroupname + "\t" + obj.translationip + "\t" + obj.translationmask + "\t"); } } getserviceResult getserviceresult2 = client.getservice(null, false, false); Console.WriteLine("getservice null : "+ getserviceresult2.message); if ((getserviceresult2.List != null) && (getserviceresult2.List.Length > 0)) { for (int i = 0; i < getserviceresult2.List.Length; i++) { service obj; obj = (service)getserviceresult2.List[i]; Console.WriteLine(obj.name + "\t" + obj.all + "\t" + obj.internaL + "\t" + obj.servername + "\t" + obj.servicetype + "\t" + obj.serviceconftype + "\t" + obj.port + "\t" + obj.value + "\t" + obj.cleartextport + "\t" + obj.gslb + "\t" + obj.cachetype + "\t" + obj.maxclient + "\t" + obj.maxreq + "\t" + obj.cacheable + "\t" + obj.cip + "\t" + obj.cipheader + "\t" + obj.usip + "\t" + obj.useproxyport + "\t" + obj.sc + "\t" + obj.weight + "\t" + obj.sp + "\t" + obj.rtspsessionidremap + "\t" + obj.failedprobes + "\t" + obj.clttimeout + "\t" + obj.totalprobes + "\t" + obj.svrtimeout + "\t" + obj.serverid + "\t" + obj.cka + "\t" + obj.tcpb + "\t" + obj.cmp + "\t" + obj.maxbandwidth + "\t" + obj.accessdown + "\t" + obj.svrstate + "\t" + obj.delay + "\t" + obj.ipaddress + "\t" + obj.monitorname + "\t" + obj.monthreshold + "\t" + obj.monstate + "\t" + obj.monstatcode + "\t" + obj.responsetime + "\t" + obj.downstateflush + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.timesincelaststatechange + "\t" + obj.tickssincelaststatechange + "\t" + obj.stateupdatereason + "\t" + obj.runningmonstate + "\t" + obj.scpolicyname + "\t" + obj.dospolicyname + "\t"); } } result = client.addlbvserver("vlb1", vservicetypeEnum.HTTP, "10.102.3.101", 80, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver vlb1 : " + result.message); result = client.addlbvserver("vlb2", vservicetypeEnum.SSL, "10.102.3.102", 443, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver vlb2 : " + result.message); getlbvserverResult getlbvserverresult3 = client.getlbvserver("vlb1"); Console.WriteLine("getlbvserver vlb1 : " + getlbvserverresult3.message); if ((getlbvserverresult3.List != null) && (getlbvserverresult3.List.Length > 0)) { for (int i = 0; i < getlbvserverresult3.List.Length; i++) { lbvserver obj; obj = (lbvserver)getlbvserverresult3.List[i]; Console.WriteLine(obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.value + "\t" + obj.ipaddress + "\t" + obj.ipmapping + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.lbrrreason + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.policyname + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.dynamicweight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sopersistencetimeout + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.health + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.rule + "\t" + obj.resrule + "\t" + obj.gotopriorityexpression + "\t" + obj.ruletype + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.timeout + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.rtspnat + "\t" + obj.sessionless + "\t" + obj.map + "\t" + obj.connfailover + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.disableprimaryondown + "\t" + obj.thresholdvalue + "\t" + obj.invoke + "\t" + obj.labeltype + "\t" + obj.labelname + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.tickssincelaststatechange + "\t" + obj.hits + "\t" + obj.svcipaddress + "\t" + obj.svcport + "\t" + obj.svctype + "\t" + obj.svcstate + "\t" + obj.servicegroupname + "\t" + obj.scpolicyname + "\t" + obj.scpolicypriority + "\t" + obj.dospolicyname + "\t" + obj.dospolicypriority + "\t" + obj.rwpolicyname + "\t" + obj.rwpolicypriority + "\t" + obj.rwpolicygotoprioexpression + "\t" + obj.rwpolicybindpoint + "\t" + obj.rwinvoke + "\t" + obj.rwpolicyinvokelabeltype + "\t" + obj.rwpolicyinvokelabelname + "\t" + obj.cachepolicyname + "\t" + obj.cachepolicypriority + "\t" + obj.cachepolicygotoprioexpression + "\t" + obj.cachepolicybindpoint + "\t" + obj.cacheinvoke + "\t" + obj.cachepolicyinvokelabeltype + "\t" + obj.cachepolicyinvokelabelname + "\t" + obj.rsppolicyname + "\t" + obj.rsppolicypriority + "\t" + obj.rsppolicygotoprioexpression + "\t" + obj.rspinvoke + "\t" + obj.rsppolicyinvokelabeltype + "\t" + obj.rsppolicyinvokelabelname + "\t" + obj.csvserver + "\t" + obj.cswpolicyname + "\t" + obj.priority + "\t"); } } getlbvserverResult getlbvserverresult4 = client.getlbvserver("vlb2"); Console.WriteLine("getlbvserver vlb2 : " + getlbvserverresult4.message); if ((getlbvserverresult4.List != null) && (getlbvserverresult4.List.Length > 0)) { for (int i = 0; i < getlbvserverresult4.List.Length; i++) { lbvserver obj; obj = (lbvserver)getlbvserverresult4.List[i]; Console.WriteLine(obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.value + "\t" + obj.ipaddress + "\t" + obj.ipmapping + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.lbrrreason + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.policyname + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.dynamicweight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sopersistencetimeout + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.health + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.rule + "\t" + obj.resrule + "\t" + obj.gotopriorityexpression + "\t" + obj.ruletype + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.timeout + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.rtspnat + "\t" + obj.sessionless + "\t" + obj.map + "\t" + obj.connfailover + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.disableprimaryondown + "\t" + obj.thresholdvalue + "\t" + obj.invoke + "\t" + obj.labeltype + "\t" + obj.labelname + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.tickssincelaststatechange + "\t" + obj.hits + "\t" + obj.svcipaddress + "\t" + obj.svcport + "\t" + obj.svctype + "\t" + obj.svcstate + "\t" + obj.servicegroupname + "\t" + obj.scpolicyname + "\t" + obj.scpolicypriority + "\t" + obj.dospolicyname + "\t" + obj.dospolicypriority + "\t" + obj.rwpolicyname + "\t" + obj.rwpolicypriority + "\t" + obj.rwpolicygotoprioexpression + "\t" + obj.rwpolicybindpoint + "\t" + obj.rwinvoke + "\t" + obj.rwpolicyinvokelabeltype + "\t" + obj.rwpolicyinvokelabelname + "\t" + obj.cachepolicyname + "\t" + obj.cachepolicypriority + "\t" + obj.cachepolicygotoprioexpression + "\t" + obj.cachepolicybindpoint + "\t" + obj.cacheinvoke + "\t" + obj.cachepolicyinvokelabeltype + "\t" + obj.cachepolicyinvokelabelname + "\t" + obj.rsppolicyname + "\t" + obj.rsppolicypriority + "\t" + obj.rsppolicygotoprioexpression + "\t" + obj.rspinvoke + "\t" + obj.rsppolicyinvokelabeltype + "\t" + obj.rsppolicyinvokelabelname + "\t" + obj.csvserver + "\t" + obj.cswpolicyname + "\t" + obj.priority + "\t"); } } result = client.bindlbvserver_service("vlb1", "svc1", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb1 : "+ result.message); result = client.bindlbvserver_service("vlb1", "svc2", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb1 : "+ result.message); result = client.bindlbvserver_service("vlb2", "svc1", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb2 : "+ result.message); result = client.bindlbvserver_service("vlb2", "svc2", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service vlb2 : "+ result.message); getvserverResult getvserverresult5 = client.getvserver("vlb1"); Console.WriteLine("getvserver vlb1 : "+ getvserverresult5.message); if ((getvserverresult5.List != null) && (getvserverresult5.List.Length > 0)) { for (int i = 0; i < getvserverresult5.List.Length; i++) { vserver obj; obj = (vserver)getvserverresult5.List[i]; Console.WriteLine(obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.ipaddress + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.value + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.rule + "\t" + obj.policyname + "\t" + obj.hits + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.timeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.sessionless + "\t" + obj.url + "\t" + obj.reuse + "\t" + obj.destinationvserver + "\t" + obj.via + "\t" + obj.flags + "\t" + obj.connfailover + "\t" + obj.casesensitive + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t"); } } getvserverResult getvserverresult6 = client.getvserver("vlb2"); Console.WriteLine("getvserver vlb2 : "+ getvserverresult6.message); if ((getvserverresult6.List != null) && (getvserverresult6.List.Length > 0)) { for (int i = 0; i < getvserverresult6.List.Length; i++) { vserver obj; obj = (vserver)getvserverresult6.List[i]; Console.WriteLine(obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.ipaddress + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.value + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.rule + "\t" + obj.policyname + "\t" + obj.hits + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.timeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.sessionless + "\t" + obj.url + "\t" + obj.reuse + "\t" + obj.destinationvserver + "\t" + obj.via + "\t" + obj.flags + "\t" + obj.connfailover + "\t" + obj.casesensitive + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t"); } } result = client.bindlbgroup_vserver("grp1", "vlb1,vlb2"); Console.WriteLine("bindlbgroup_vserver grp1 : "+ result.message); getlbgroupResult getlbgroupresult7 = client.getlbgroup("grp1"); Console.WriteLine("getlbgroup grp1 : "+ getlbgroupresult7.message); if ((getlbgroupresult7.List != null) && (getlbgroupresult7.List.Length > 0)) { for (int i = 0; i < getlbgroupresult7.List.Length; i++) { lbgroup obj; obj = (lbgroup)getlbgroupresult7.List[i]; Console.WriteLine(obj.name + "\t" + obj.vservername + "\t" + obj.persistencetype + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.persistmask + "\t" + obj.cookiedomain + "\t" + obj.timeout + "\t"); } } result = client.setlbgroup_persistencetype("grp1", grppersisttypeEnum.COOKIEINSERT); Console.WriteLine("setlbgroup_persistencetype grp1 : "+ result.message); result = client.setlbgroup_timeout("grp1", 10); Console.WriteLine("setlbgroup_timeout grp1 : "+ result.message); getlbgroupResult getlbgroupresult8 = client.getlbgroup("grp1"); Console.WriteLine("getlbgroup grp1 : "+ getlbgroupresult8.message); if ((getlbgroupresult8.List != null) && (getlbgroupresult8.List.Length > 0)) { for (int i = 0; i < getlbgroupresult8.List.Length; i++) { lbgroup obj; obj = (lbgroup)getlbgroupresult8.List[i]; Console.WriteLine(obj.name + "\t" + obj.vservername + "\t" + obj.persistencetype + "\t" + obj.persistencebackup + "\t" + obj.backuppersistencetimeout + "\t" + obj.persistmask + "\t" + obj.cookiedomain + "\t" + obj.timeout + "\t"); } } getvserverResult getvserverresult9 = client.getvserver(null); Console.WriteLine("getvserver null : "+ getvserverresult9.message); if ((getvserverresult9.List != null) && (getvserverresult9.List.Length > 0)) { for (int i = 0; i < getvserverresult9.List.Length; i++) { vserver obj; obj = (vserver)getvserverresult9.List[i]; Console.WriteLine(obj.name + "\t" + obj.insertvserveripport + "\t" + obj.vipheader + "\t" + obj.ipaddress + "\t" + obj.port + "\t" + obj.range + "\t" + obj.servicetype + "\t" + obj.value + "\t" + obj.type + "\t" + obj.state + "\t" + obj.effectivestate + "\t" + obj.status + "\t" + obj.cachetype + "\t" + obj.redirect + "\t" + obj.precedence + "\t" + obj.redirecturl + "\t" + obj.authentication + "\t" + obj.homepage + "\t" + obj.dnsvservername + "\t" + obj.domain + "\t" + obj.rule + "\t" + obj.policyname + "\t" + obj.hits + "\t" + obj.servicename + "\t" + obj.weight + "\t" + obj.cachevserver + "\t" + obj.backupvserver + "\t" + obj.priority + "\t" + obj.clttimeout + "\t" + obj.somethod + "\t" + obj.sopersistence + "\t" + obj.sothreshold + "\t" + obj.lbmethod + "\t" + obj.hashlength + "\t" + obj.dataoffset + "\t" + obj.datalength + "\t" + obj.netmask + "\t" + obj.groupname + "\t" + obj.m + "\t" + obj.persistencetype + "\t" + obj.cookiedomain + "\t" + obj.persistmask + "\t" + obj.persistencebackup + "\t" + obj.timeout + "\t" + obj.cacheable + "\t" + obj.pq + "\t" + obj.sc + "\t" + obj.sessionless + "\t" + obj.url + "\t" + obj.reuse + "\t" + obj.destinationvserver + "\t" + obj.via + "\t" + obj.flags + "\t" + obj.connfailover + "\t" + obj.casesensitive + "\t" + obj.redirectportrewrite + "\t" + obj.downstateflush + "\t" + obj.cookieipport + "\t" + obj.vserverid + "\t" + obj.version + "\t" + obj.totalservices + "\t" + obj.activeservices + "\t"); } } result = client.addsslcertkey("test_cert", "/nsconfig/ssl/1024cert.pem", "/nsconfig/ssl/1024key.pem", false, null, informatsEnum.VALNOTSET, enabledisabledEnum.VALNOTSET, 0xFFFFFFFF); Console.WriteLine("addsslcertkey test_cert : "+ result.message); result = client.bindsslcertkey_vserver("test_cert", "vlb2", false); Console.WriteLine("bindsslcertkey_vserver test_cert : "+ result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } }
// API to run the script. void run_commands(string servername, string username, string password) { simpleResult result; service svc = new service(); // Initialized the soap client Console.WriteLine("\nConnecting to server " + servername + " ............\n"); client = new ClientService(servername); client.CookieContainer = new System.Net.CookieContainer(); // Login request result = client.login(username, password); Console.WriteLine("login : "******"0") { //add service s1 result = client.addservice("s1", "10.101.0.1", null, servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("add service s1 : " + result.message); // add service s2 result = client.addservice("s2", "10.101.0.2", null, servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("add service s2 : " + result.message); // Modify service s1 result = client.setservice_maxreq("s1", 50); Console.WriteLine("set service maxReq : " + result.message); result = client.setservice_cip("s1", enabledisabledEnum.ENABLED, "abc"); Console.WriteLine("set service cip : " + result.message); // bind monitor s1 result = client.bindlbmonitor_service("http", "s1", enabledisabledEnum.ENABLED, 80); Console.WriteLine("bind monitor s1 : " + result.message); // bind monitor s2 result = client.bindlbmonitor_service("http", "s2", enabledisabledEnum.ENABLED, 80); Console.WriteLine("bind monitor s1 : " + result.message); // add lb vserver result = client.addlbvserver("vip_1", vservicetypeEnum.HTTP, "10.100.0.100", 80, 0xFFFFFFFF, enabledisabledEnum.ENABLED, null); Console.WriteLine("add lb vserver newv1 : " + result.message); Console.WriteLine("add lb vserver vip_1 : " + result.message); // bind lb vserver s1 result = client.bindlbvserver_service("vip_1", "s1", 10); Console.WriteLine("bind lb vserver s1 : " + result.message); // bind lb vserver s2 result = client.bindlbvserver_service("vip_1", "s2", 10); Console.WriteLine("bind lb vserver s2 : " + result.message); // Save config result = client.savensconfig(); Console.WriteLine("save config : " + result.message); // Logout result = client.logout(); Console.WriteLine("logout : " + result.message); } }
// API to run the script. void run_commands(string servername,string username,string password) { simpleResult result; service svc = new service(); // Initialized the soap client Console.WriteLine("\nConnecting to server "+servername+" ............\n"); client = new ClientService(servername); client.CookieContainer = new System.Net.CookieContainer(); // Login request result = client.login(username,password) ; Console.WriteLine("login : "******"0") { //add service s1 result = client.addservice("s1","10.101.0.1",null,servicetypeEnum.HTTP,80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("add service s1 : " + result.message); // add service s2 result = client.addservice("s2","10.101.0.2",null,servicetypeEnum.HTTP,80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET); Console.WriteLine("add service s2 : " + result.message); // Modify service s1 result = client.setservice_maxreq("s1",50); Console.WriteLine("set service maxReq : " + result.message); result = client.setservice_cip("s1",enabledisabledEnum.ENABLED,"abc"); Console.WriteLine("set service cip : " + result.message); // bind monitor s1 result = client.bindlbmonitor_service("http","s1",enabledisabledEnum.ENABLED,80); Console.WriteLine("bind monitor s1 : "+ result.message); // bind monitor s2 result = client.bindlbmonitor_service("http","s2",enabledisabledEnum.ENABLED,80); Console.WriteLine("bind monitor s1 : "+ result.message); // add lb vserver result = client.addlbvserver("vip_1", vservicetypeEnum.HTTP, "10.100.0.100",80,0xFFFFFFFF,enabledisabledEnum.ENABLED,null); Console.WriteLine("add lb vserver newv1 : " + result.message); Console.WriteLine("add lb vserver vip_1 : " + result.message); // bind lb vserver s1 result = client.bindlbvserver_service("vip_1","s1",10); Console.WriteLine("bind lb vserver s1 : "+ result.message); // bind lb vserver s2 result = client.bindlbvserver_service("vip_1","s2",10); Console.WriteLine("bind lb vserver s2 : "+ result.message); // Save config result = client.savensconfig(); Console.WriteLine("save config : " + result.message); // Logout result = client.logout(); Console.WriteLine("logout : " + result.message); } }
static void Main(string[] args) { if ( args.Length < 3) { Console.WriteLine("Usage: getConfig <NS IP> username password"); return; } string serverip = args[0]; string username = args[1]; string password = args[2]; try { Console.WriteLine("\nConnecting to server "+serverip+" ............\n"); client = new ClientService(serverip); client.CookieContainer = new System.Net.CookieContainer(); simpleResult result = client.login(username,password) ; Console.WriteLine("login : "******"enablensfeature CMP : " + result.message); result = client.addserver("s1", "10.102.3.91", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s1 : " + result.message); result = client.addserver("s2", "10.102.3.92", null, enabledisabledEnum.VALNOTSET); Console.WriteLine("addserver s2 : " + result.message); result = client.addservice("srv1", null, "s1", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv1 : " + result.message); result = client.addservice("srv2", null, "s2", servicetypeEnum.HTTP, 80, 0xFFFFFFFF, cachtypeEnum.VALNOTSET, enabledisabledEnum.VALNOTSET); Console.WriteLine("addservice srv2 : " + result.message); result = client.addlbvserver("lbvip1", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip1 : " + result.message); result = client.addlbvserver("lbvip2", vservicetypeEnum.HTTP, null, 0xFFFFFFFF, 0xFFFFFFFF, enabledisabledEnum.VALNOTSET, null); Console.WriteLine("addlbvserver lbvip2 : " + result.message); result = client.bindlbvserver_service("lbvip1", "srv1", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip1 : " + result.message); result = client.bindlbvserver_service("lbvip2", "srv2", 0xFFFFFFFF); Console.WriteLine("bindlbvserver_service lbvip2 : " + result.message); result = client.setservice_cmp("srv1",yesnoEnum.YES); Console.WriteLine("setservice_cmp srv1 : " + result.message); result = client.setservice_cmp("srv2",yesnoEnum.NO); Console.WriteLine("setservice_cmp srv2 : " + result.message); result = client.addcmppolicy("cmp1","url == /testsite/file5.html","nocompress"); Console.WriteLine("addcmppolicy cmp1 : " + result.message); result = client.bindcmpglobal_policy("cmp1",0xFFFFFFFF,enabledisabledEnum.VALNOTSET); Console.WriteLine("bindcmpglobal_policy cmp1 : " + result.message); result = client.addpolicyexpression("ex1","RES.HTTP.HEADER Content-Type CONTAINS application/msword"); Console.WriteLine("addpolicyexpression ex1 : " + result.message); result = client.addcmppolicy("cmp2","ex1","deflate"); Console.WriteLine("addcmppolicy cmp2 : " + result.message); result = client.bindcmpglobal_policy("cmp2",0xFFFFFFFF,enabledisabledEnum.VALNOTSET); Console.WriteLine("bindcmpglobal_policy cmp2 : " + result.message); result = client.addcmppolicy("cmp3","url contains file50 || RES.HTTP.HEADER Content-Type CONTAINS text/css","deflate"); Console.WriteLine("addcmppolicy cmp3 : " + result.message); result = client.addpolicyexpression("ex2","HEADER User-Agent CONTAINS MSIE"); Console.WriteLine("addpolicyexpression ex2 : " + result.message); result = client.addpolicyexpression("ex3","RES.HTTP.HEADER Content-Type CONTAINS application/vnd.ms-excel"); Console.WriteLine("addpolicyexpression ex3 : " + result.message); result = client.addcmppolicy("cmp4","ex2&&ex3","gzip"); Console.WriteLine("addcmppolicy cmp4 : " + result.message); result = client.logout(); Console.WriteLine("logout : " + result.message); } catch (Exception ex) { Console.WriteLine( "Exception: "+ex.ToString()); } }