public ConTestAtHome() { string AppName = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName; string AppPath = System.IO.Path.GetDirectoryName(AppName); string AppFileName = System.IO.Path.GetFileNameWithoutExtension(AppName); string[] arrCnfLines = null; LoginStatus LoginResult = LoginStatus.Unknown; if (!AppPath.EndsWith("\\")) { AppPath += "\\"; } ConMain = new TelnetDevice(); ConMain.Debug = 1; //Read Config-File ConMain.Init(AppPath + AppFileName + ".conf"); LoginResult = ConMain.doLogin("192.168.192.240", ""); //10.0.21.254 if ((LoginResult != LoginStatus.Success) && (LoginResult != LoginStatus.UserMode)) { return; } arrCnfLines = ConMain.SendCmd("show ip inter brief"); foreach (string strLine in arrCnfLines) { Console.WriteLine(strLine); } LoginResult = ConMain.Jump2NextDevice("172.19.5.10", ""); //172.18.31.1, 10.229.111.254, 10.229.108.50, 10.24.0.11 if ((LoginResult == LoginStatus.Success) || (LoginResult == LoginStatus.UserMode)) { ConMain.SendCmd("show interface brief"); ConMain.doLogout(); } ConMain.doLogout(); ConMain = null; }
public ConTelnetWLC(bool DoConfig, bool DoShow, string WlanID) { string AppName = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName; string AppPath = System.IO.Path.GetDirectoryName(AppName); string AppFileName = System.IO.Path.GetFileNameWithoutExtension(AppName); LoginStatus loginState = LoginStatus.Unknown; string[] arrCnfLines = null; string[] arrAPConfig = null; Regex reAPName = new Regex(@"([^ ]+) {2,20}[0-9]+ +.*"); Regex WlanVlan = new Regex(@"[\s\t]+wlan ([0-9]+)\s*:\.+ ([0-9]+)", RegexOptions.IgnoreCase); Match mAP = null, mVLAN = null; string APName = ""; bool bFoundFlexVlanMode = false; Regex reVlanNr = new Regex(@".*:\.+ *([0-9]+)"); ConMain = new TelnetDevice(); ConMain.Debug = 1; //Read Config-File ConMain.Init(AppPath + AppFileName + ".conf"); loginState = ConMain.doLogin("10.110.10.3", "", "Cisco"); if ((loginState != LoginStatus.Success) && (loginState != LoginStatus.UserMode)) { return; } ConMain.Debug = 1; arrCnfLines = ConMain.SendCmd("show ap summary"); if (!DoConfig) { ConMain.Debug = 0; } foreach (string strLine in arrCnfLines) { //Console.WriteLine(strLine); APName = ""; mAP = reAPName.Match(strLine); if (mAP.Success) { APName = mAP.Groups[1].Value; //Console.WriteLine("\t" + APName); bFoundFlexVlanMode = false; arrAPConfig = ConMain.SendCmd("show ap config general " + APName); foreach (string strAPCfg in arrAPConfig) { if (bFoundFlexVlanMode) { if (DoShow) { mVLAN = WlanVlan.Match(strAPCfg); if (mVLAN.Success) { Console.WriteLine(APName + ";WlanID-VLAN;" + mVLAN.Groups[1].Value + "=" + mVLAN.Groups[2].Value); } } else if (strAPCfg.ToLower().StartsWith(" wlan 2 :...")) { //Set VLAN for WLAN-ID: 10 mVLAN = reVlanNr.Match(strAPCfg); if (mVLAN.Success) { if (!DoConfig) { Console.WriteLine("config ap disable " + APName); Console.WriteLine("config ap flexconnect vlan wlan 10 " + mVLAN.Groups[1].Value + " " + APName); Console.WriteLine("config ap enable " + APName); } else { ConMain.SendCmd("config ap disable " + APName); ConMain.SendCmd("config ap flexconnect vlan wlan 10 " + mVLAN.Groups[1].Value + " " + APName); ConMain.SendCmd("config ap enable " + APName); } } } } else if ((bFoundFlexVlanMode) && (strAPCfg.ToLower().StartsWith("flexconnect vlan acl mappings"))) { break; } else if (strAPCfg.ToLower().StartsWith("flexconnect vlan mode :.")) { bFoundFlexVlanMode = true; } } } } ConMain.Debug = 1; ConMain.doLogout(); }
public ConWLCAPRestart(string APNameFilter) { string AppName = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName; string AppPath = System.IO.Path.GetDirectoryName(AppName); string AppFileName = System.IO.Path.GetFileNameWithoutExtension(AppName); LoginStatus loginState = LoginStatus.Unknown; string[] arrCnfLines = null; string[] arrAPConfig = null; Regex reAPName = new Regex(@"([^ ]+) {2,20}[0-9]+ +.*"); Match mAP = null; string APName = ""; ConMain = new TelnetDevice(); ConMain.Debug = 1; //Read Config-File ConMain.Init(AppPath + AppFileName + ".conf"); loginState = ConMain.doLogin("10.110.10.3", "", "Cisco"); if ((loginState != LoginStatus.Success) && (loginState != LoginStatus.UserMode)) { return; } //ConMain.Debug = 1; arrCnfLines = ConMain.SendCmd("show ap summary"); foreach (string strLine in arrCnfLines) { //Console.WriteLine(strLine); APName = ""; mAP = reAPName.Match(strLine); if (mAP.Success) { APName = mAP.Groups[1].Value; //Console.WriteLine("\t" + APName); if (APNameFilter.Equals("") || (APName.ToLower().Contains(APNameFilter))) { if (APName.ToLower().StartsWith("loc_1030") || APName.ToLower().StartsWith("loc_2000") || APName.ToLower().StartsWith("loc_1060") || APName.ToLower().StartsWith("loc_1140") || APName.ToLower().StartsWith("loc_1100") || APName.ToLower().StartsWith("loc_2700") || APName.ToLower().StartsWith("loc_6800") || APName.ToLower().StartsWith("loc_2100") || APName.ToLower().StartsWith("loc_2500")) { //Skip this APs } else { Console.WriteLine(APName + " init Reload"); ConMain.DeleteScreen(); ConMain.print("config ap reset " + APName); ConMain.WaitForString("(y/n)"); arrAPConfig = ConMain.SendCmd("y"); Console.WriteLine(APName + " Reloading"); } } else { } } } ConMain.Debug = 1; ConMain.doLogout(); }
public ConTestTelnet() { string AppName = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName; string AppPath = System.IO.Path.GetDirectoryName(AppName); string AppFileName = System.IO.Path.GetFileNameWithoutExtension(AppName); string[] arrCnfLines = null; LoginStatus LoginResult = LoginStatus.Unknown; if (!AppPath.EndsWith("\\")) { AppPath += "\\"; } ConMain = new TelnetDevice(); ConMain.Debug = 1; //Read Config-File ConMain.Init(AppPath + AppFileName + ".conf"); LoginResult = ConMain.doLogin("192.168.192.230", ""); if ((LoginResult != LoginStatus.Success) && (LoginResult != LoginStatus.UserMode)) { return; } ConMain.SetCliLogins(new string[] { "Username" }, new string[] { "Pwd***" }); ConMain.SetCliEnablePwds(new string[] { "EnablePwd***" }); LoginResult = ConMain.Jump2NextDevice("10.116.25.138", ""); if ((LoginResult != LoginStatus.Success) && (LoginResult != LoginStatus.UserMode)) { ConMain.doLogout(); return; } arrCnfLines = ConMain.SendCmd("show ip inter brief"); foreach (string strLine in arrCnfLines) { Console.WriteLine(strLine); } ConMain.doLogout(); ConMain.doLogout(); return; if (ConMain.GetDeviceType.Equals("Cisco WLC")) { arrCnfLines = ConMain.SendCmd("show run-config"); foreach (string strLine in arrCnfLines) { Console.WriteLine(strLine); } ConMain.doLogout(); return; } ConMain.Debug = 0; arrCnfLines = ConMain.SendCmd("show run"); foreach (string strLine in arrCnfLines) { Console.WriteLine(strLine); } ConMain.Debug = 1; if (ConMain.GetDeviceType.Equals("Cisco-IOS-XR")) { ConMain.GetIntoConfigMode(); //arrCnfLines = ConMain.SendCmd("vrf Post"); ConMain.ExitConfigMode(); } else { LoginResult = ConMain.Jump2NextDevice("172.19.5.2", ""); //172.18.31.1, 10.229.111.254, 10.229.108.50, 10.24.0.11 if ((LoginResult == LoginStatus.Success) || (LoginResult == LoginStatus.UserMode)) { if (ConMain.GetDeviceType.Equals("H3C")) { ConMain.SendCmd("display version"); ConMain.GetIntoConfigMode(); ConMain.SendCmd("display clock"); ConMain.SendCmd("interface Vlan-interface 100"); ConMain.SendCmd("description Test Vlan-100"); ConMain.SendCmd("quit"); ConMain.ExitConfigMode(); } else { ConMain.SendCmd("show version"); } ConMain.doLogout(); } } if (ConMain.GetDeviceType.Equals("Cisco") || ConMain.GetDeviceType.Equals("HP")) { ConMain.GetIntoConfigMode(); if (ConMain.GetDeviceType.Equals("HP")) { arrCnfLines = ConMain.SendCmd("show version"); } else { ConMain.SendCmd("ip dhcp pool Test"); ConMain.SendCmd("network 10.10.10.0 255.255.255.0"); ConMain.SendCmd("exit"); ConMain.SendCmd("no ip dhcp pool Test"); arrCnfLines = ConMain.SendCmd("do show version"); } foreach (string strLine in arrCnfLines) { Console.WriteLine(strLine); } ConMain.ExitConfigMode(); } if (ConMain.GetDeviceType.Equals("HP")) { arrCnfLines = ConMain.SendCmd("show time"); } else { arrCnfLines = ConMain.SendCmd("show clock"); } foreach (string strLine in arrCnfLines) { Console.WriteLine(strLine); } ConMain.doLogout(); }