public CDiscoveredConfig()
 {
     if (Id == null)
     {
         Id = CFunctions.GenerateUID();
     }
 }
Esempio n. 2
0
        public void Export(List <IDiscoveredObject> DiscoveredSites, List <IDiscoveredObject> DiscoveredServers)
        {
            Core._ReportURI = @"http://127.0.0.1:8182/";

            if (_DBConn == null)
            {
                _DBConn = InitializeDB();
            }

            string uid = CFunctions.GenerateUID();

            CSession exporter = new CSession(ref _DBConn, DiscoveredSites, DiscoveredServers, uid);

            SessionInfo.Add(exporter.Progress);
            SessionManager.Add(ref exporter);
        }
        private void _CServer(string name, CServiceType type, string user = "", string password = "")
        {
            // initialize values
            Name = name;     // ip resolution handled by get set function
            Id   = CFunctions.GenerateUID();
            if (user == "")
            {
                UserName = Environment.UserDomainName + "\\" + Environment.UserName;
            }
            else
            {
                UserName = user;
            }

            Type         = type;
            UserPassword = password;
        }
        public void DoWork()
        {
            Completed = false;
            Started   = true;
            string uid       = CFunctions.GenerateUID();
            string starttime = CFunctions.GetDateTime(0);

            Log.Write("[Threading] Starting thread (" + uid + ") to generate database output to " + Outfile.ToLower(), Log.Verbosity.Everything);

            CThread.Types threadtype = new CThread.Types(CThread.Types.Unmanaged);

            CDatabaseExporter de       = new CDatabaseExporter();
            CThread           exporter = new CThread()
            {
                Type = threadtype, Worker = new Thread(delegate() { de.Export(this, ref _DBConn, DiscoveredSites, DiscoveredServers); }), Id = uid
            };

            Core.ThreadManager.Add(exporter);
        }
        private void QueryManager()
        {
            for (int i = 0; i < Session.Queries.Count; i++)
            {
                if (!Session.Queries[i].Started)
                {
                    string tid = CFunctions.GenerateUID();
                    int    id  = i; // using local context variable to allow delegation
                    Log.Write("[Threading] Starting thread (" + tid + ") to run session query " + (i + 1) + "/" + Session.Queries.Count + " (" + Session.Queries[i].Id + ").", Log.Verbosity.Everything);

                    CThread.Types threadtype = new CThread.Types(CThread.Types.Unmanaged);
                    if ((Server.Type == CServiceType.ESXServer) || (Server.Type == CServiceType.VCenterServer))
                    {
                        threadtype = new CThread.Types(CThread.Types.VMware);
                    }
                    if ((Server.Type == CServiceType.SCVMMServer) || (Server.Type == CServiceType.HYVServer))
                    {
                        threadtype = new CThread.Types(CThread.Types.HyperV);
                    }

                    Core.ThreadManager.Add(new CThread()
                    {
                        Type = threadtype, Worker = new Thread(delegate() { DoQuery(id); }), Session = this, Id = tid
                    });
                }
            }
            do
            {
                bool status = true;
                for (int i = 0; i < Session.Queries.Count; i++)
                {
                    if (!Session.Queries[i].Completed)
                    {
                        status = false;
                    }
                }
                Session.Completed = status;
                Thread.Sleep(COptions.Session_Thread_Wait);
            } while (!Session.Completed);
        }
Esempio n. 6
0
        internal void Collect(List <IDiscoveredObject> DiscoveredSites, List <IDiscoveredObject> DiscoveredServers, List <CQuery.Types> queries, CCollectionSchedule schedule)
        {
            string uid;

            //Log.Write(" : RunStatisticsCollector (discoveredsites: " + DiscoveredSites.Count + ", discoveredservers: " + DiscoveredServers.Count + ", queries: " + queries.Count + ", schedule: " + schedule + ")", Log.Verbosity.Everything);

            IEnumerable <CSite> sites    = DiscoveredSites.OfType <CSite>();
            List <CSite>        SiteList = new List <CSite> {
            };

            SiteList.AddRange(sites);

            IEnumerable <CService> servers    = DiscoveredServers.OfType <CService>();
            List <CService>        ServerList = new List <CService> {
            };

            ServerList.AddRange(servers);

            /* string output = " : RunStatisticsCollector(registering sessions for: ";
             * foreach (CService s in ServerList)
             * {
             *  output += s.Name + ", ";
             * }
             * Log.Write(output + ")", Log.Verbosity.Everything); */

            if (schedule == CCollectionSchedule.RunOnce)
            {
                // get information
                for (int i = 0; i < ServerList.Count(); i++)
                {
                    //Log.Write(" : RunStatisticsCollector (looping through servers " + ServerList[i].Name + ")", Log.Verbosity.Everything);
                    uid = CFunctions.GenerateUID();

                    if (!Started)
                    {
                        ServerList[i].Initialize();
                    }

                    foreach (CQuery.Types type in queries)
                    {
                        bool QueryApplicable = false;
                        if (((type == CQuery.Types.Components) || (type == CQuery.Types.Events) || (type == CQuery.Types.Logs)) && (ServerList[i].Type == CServiceType.VBRServer))
                        {
                            QueryApplicable = true;
                        }
                        else if (((type == CQuery.Types.Hosts) || (type == CQuery.Types.Datastores) || (type == CQuery.Types.VMs)) && ((ServerList[i].Type == CServiceType.VCenterServer) || (ServerList[i].Type == CServiceType.ESXServer) || (ServerList[i].Type == CServiceType.HYVServer)))
                        {
                            QueryApplicable = true;
                        }

                        if (QueryApplicable)
                        {
                            CQuery query = new CQuery(ref ServerList[i].Session, type, SiteList, uid);
                            SessionInfo.Add(query.Progress);
                            ServerList[i].Session.AddQuery(query);
                        }
                    }

                    // Log.Write(" : RunStatisticsCollector (registering session " + ServerList[i].Session.Server.Name + ")", Log.Verbosity.Everything);
                    SessionManager.Add(ref ServerList[i].Session);
                }

                Started = true;
                // Log.Write(" : RunStatisticsCollector (completed)", Log.Verbosity.Everything);

                // later
                // get vbr job information
                // get vbr configuration, later get host configuration etc...
                // get physical server and client configuration (discovery by wildcard name, using AD)
                // make get host, datastore and guest work for KVM and then Azure, AWS, GCE
                // ...
                // get information by using network scanning (discovery by ip address, using port scanning)
                // get information from storage systems
            }
        }