private SystemInformation CreateSystemInformationInstance(CiscoIOSVersion myVersion, IList<NetworkInterface> myInterfaces)
 {
     var newSystemInformation = new SystemInformation()
     {
         SystemVersion = myVersion.VersionString,
         SystemName = myVersion.OSName,
         Architecture = myVersion.Architecture,
         PrimaryHostName = myVersion.HostName,
         Interfaces = myInterfaces
     };
     return newSystemInformation;
 }
Example #2
0
        private SystemInformation CreateSystemInformationInstance(CiscoIOSVersion myVersion, IList <NetworkInterface> myInterfaces)
        {
            var newSystemInformation = new SystemInformation()
            {
                SystemVersion   = myVersion.VersionString,
                SystemName      = myVersion.OSName,
                Architecture    = myVersion.Architecture,
                PrimaryHostName = myVersion.HostName,
                Interfaces      = myInterfaces
            };

            return(newSystemInformation);
        }
Example #3
0
        public SystemInformation GetSystemInformationFrom(TargetInfo target)
        {
            if (target.ContainsKey("PortNum"))
            {
                target["PortNum"] = "23";
            }
            else
            {
                target.Add("PortNum", "23");
            }

            CiscoIOSConnectionProvider connectionProvider = new CiscoIOSConnectionProvider();

            connectionProvider.Connect(target);
            CiscoIOSVersion          myVersion    = CiscoIOSHelper.CiscoGetVersion(connectionProvider.TelnetConnection);
            IList <NetworkInterface> myInterfaces = CiscoIOSHelper.CiscoGetInterfaces(connectionProvider.TelnetConnection);

            return(this.CreateSystemInformationInstance(myVersion, myInterfaces));
        }
Example #4
0
        public static CiscoIOSVersion CiscoGetVersion(TelnetConnection tc)
        {
            CiscoIOSVersion retVal = null;
            string          output = tc.CiscoCommand("show version");

            string[] lines = output.Split('\r', '\n');
            retVal = new CiscoIOSVersion();
            retVal.VersionString = "0.0";
            retVal.HostName      = retVal.Architecture = "undefined";

            foreach (string line in lines)
            {
                if (line.StartsWith("IOS") || line.StartsWith("Cisco IOS"))
                {
                    string verString = " Version ";
                    int    posVer    = line.IndexOf(verString, StringComparison.OrdinalIgnoreCase);
                    if (posVer >= 0)
                    {
                        posVer   += verString.Length;
                        verString = line.Substring(posVer);
                        string[] verStringCut = verString.Split(' ', '\t', ',');
                        retVal.VersionString = verStringCut[0];
                        retVal.OSName        = "IOS";
                    }
                }

                if (line.IndexOf(" uptime is ", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    int posSpace = line.IndexOfAny(new char[] { ' ', '\t' });
                    retVal.HostName = posSpace != 0 ? line.Substring(0, posSpace) : "unknown";
                }

                if ((line.IndexOf(" bytes of memory", StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    retVal.Architecture = line;
                }
            }

            return(retVal);
        }
Example #5
0
        public static CiscoIOSVersion CiscoGetVersion(TelnetConnection tc)
        {
            CiscoIOSVersion retVal = null;
            string output = tc.CiscoCommand("show version");
            string[] lines = output.Split('\r', '\n');
            retVal = new CiscoIOSVersion();
            retVal.VersionString = "0.0";
            retVal.HostName = retVal.Architecture = "undefined";

            foreach (string line in lines)
            {
                if (line.StartsWith("IOS") || line.StartsWith("Cisco IOS"))
                {
                    string verString = " Version ";
                    int posVer = line.IndexOf(verString, StringComparison.OrdinalIgnoreCase);
                    if (posVer >= 0)
                    {
                        posVer += verString.Length;
                        verString = line.Substring(posVer);
                        string[] verStringCut = verString.Split(' ', '\t', ',');
                        retVal.VersionString = verStringCut[0];
                        retVal.OSName = "IOS";
                    }
                }

                if (line.IndexOf(" uptime is ", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    int posSpace = line.IndexOfAny(new char[] { ' ', '\t' });
                    retVal.HostName = posSpace != 0 ? line.Substring(0, posSpace) : "unknown";
                }

                if ((line.IndexOf(" bytes of memory", StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    retVal.Architecture = line;
                }
            }

            return retVal;
        }
Example #6
0
        public static CiscoIOSVersion CiscoGetVersion(TelnetConnection tc)
        {
            CiscoIOSVersion retVal = null;
            string output = tc.CiscoCommand("show version");
            string[] lines = output.Split('\r', '\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("IOS"))
                {
                    string verString = " Version ";
                    int posVer = line.IndexOf(verString, StringComparison.OrdinalIgnoreCase);
                    if (posVer >= 0)
                    {
                        posVer += verString.Length;
                        verString = line.Substring(posVer);
                        string[] verStringCut = verString.Split(' ', '\t', ',');
                        retVal = new CiscoIOSVersion();
                        retVal.VersionString = verStringCut[0];
                        retVal.OSName = "IOS";
                    }
                }

                if (line.IndexOf(" uptime is ", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    int posSpace = line.IndexOfAny(new char[] { ' ', '\t' });
                    retVal.HostName = line.Substring(0, posSpace);
                }

                if ((line.IndexOf(" processor ", StringComparison.OrdinalIgnoreCase) >= 0) &&
                    String.IsNullOrEmpty(retVal.Architecture))
                {
                    string[] tokens = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        if (String.Equals(tokens[i], "processor", StringComparison.OrdinalIgnoreCase) && (i > 0))
                        {
                            string cpuStr = tokens[i - 1];
                            int lenCpuStr = cpuStr.Length;
                            if ((cpuStr[0] == '(') && (cpuStr[lenCpuStr - 1] == ')'))
                                cpuStr = cpuStr.Substring(1, lenCpuStr - 2);
                            retVal.Architecture = cpuStr;
                            break;
                        }
                    }
                }
            }
            return retVal;
        }