// 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); } }