Пример #1
0
 internal void AddQuery(CQuery query)
 {
     Session.Queries.Add(query);
     if (Session.Completed)
     {
         Session.Completed = false;
     }                                                     // mark session as incomplete as new query is added to the stack
 }
Пример #2
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
            }
        }