예제 #1
0
        public static string Generate(PluginManager pluginManager, bool isForXenCenter)
        {
            var metadata = new XenCenterMetadata
            {
                System = new SystemInfo
                {
                    Version       = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                    DotNetVersion = Environment.Version.ToString(4),
                    Culture       = Thread.CurrentThread.CurrentUICulture.EnglishName,
                    OsVersion     = Environment.OSVersion.ToString(),
                    OsCulture     = CultureInfo.CurrentUICulture.EnglishName,
                    IpAddress     = GetLocalIPAddress(),
                    Uuid          = Updates.GetUniqueIdHash(),
                    Uptime        = isForXenCenter ? (DateTime.Now - Process.GetCurrentProcess().StartTime).ToString() : string.Empty
                },
                Settings = new XenCenterSettings
                {
                    CFU = new CFU
                    {
                        AllowXenCenterUpdates = Properties.Settings.Default.AllowXenCenterUpdates,
                        AllowPatchesUpdates   = Properties.Settings.Default.AllowPatchesUpdates,
                        AllowXenServerUpdates = Properties.Settings.Default.AllowXenServerUpdates
                    },
                    Proxy = new Proxy
                    {
                        UseProxy                  = (HTTPHelper.ProxyStyle)Properties.Settings.Default.ProxySetting == HTTPHelper.ProxyStyle.SpecifiedProxy,
                        UseIEProxy                = (HTTPHelper.ProxyStyle)Properties.Settings.Default.ProxySetting == HTTPHelper.ProxyStyle.SystemProxy,
                        BypassProxyForServers     = Properties.Settings.Default.BypassProxyForServers,
                        ProxyAuthentication       = Properties.Settings.Default.ProvideProxyAuthentication,
                        ProxyAuthenticationMethod = ((HTTP.ProxyAuthenticationMethod)Properties.Settings.Default.ProxyAuthenticationMethod).ToString()
                    },
                    SaveAndRestore = new SaveAndRestore
                    {
                        SaveSessionCredentials = Properties.Settings.Default.SaveSession,
                        RequireMasterPassword  = Properties.Settings.Default.RequirePass
                    },
                    HelpLastUsed = Properties.Settings.Default.HelpLastUsed
                },
                Infrastructure = new XenCenterInfrastructure
                {
                    TotalConnections = ConnectionsManager.XenConnectionsCopy.Count,
                    Connected        = ConnectionsManager.XenConnectionsCopy.Count(c => c.IsConnected)
                },
                Plugins      = new List <Plugin>(),
                SourceOfData = isForXenCenter ? Messages.XENCENTER : Messages.HEALTH_CHECK,
                Created      = DateTime.UtcNow.ToString("u"),
                Reported     = isForXenCenter ? DateTime.UtcNow.ToString("u") : HealthCheckSettings.REPORT_TIME_PLACEHOLDER
            };

            if (pluginManager != null)
            {
                foreach (var plugin in pluginManager.Plugins)
                {
                    metadata.Plugins.Add(new Plugin
                    {
                        Name         = plugin.Name,
                        Organization = plugin.Organization,
                        Enabled      = plugin.Enabled
                    });
                }
            }

            var obj = new Dictionary <string, object> {
                { Messages.XENCENTER, metadata }
            };

            return(new JavaScriptSerializer().Serialize(obj));
        }
예제 #2
0
        /// <summary>
        /// Dismisses the updates in the given list i.e. they are added in the
        /// other_config list of each pool and removed from the Updates.UpdateAlerts list.
        /// </summary>
        /// <param name="toBeDismissed"></param>
        public static void DismissUpdates(List <Alert> toBeDismissed)
        {
            if (toBeDismissed.Count == 0)
            {
                return;
            }

            foreach (IXenConnection connection in ConnectionsManager.XenConnectionsCopy)
            {
                if (!Alert.AllowedToDismiss(connection))
                {
                    continue;
                }

                XenAPI.Pool pool = Helpers.GetPoolOfOne(connection);
                if (pool == null)
                {
                    continue;
                }

                Dictionary <string, string> other_config = pool.other_config;

                foreach (Alert alert in toBeDismissed)
                {
                    if (alert is XenServerPatchAlert)
                    {
                        if (other_config.ContainsKey(IgnorePatchKey))
                        {
                            List <string> current = new List <string>(other_config[IgnorePatchKey].Split(','));
                            if (current.Contains(((XenServerPatchAlert)alert).Patch.Uuid, StringComparer.OrdinalIgnoreCase))
                            {
                                continue;
                            }
                            current.Add(((XenServerPatchAlert)alert).Patch.Uuid);
                            other_config[IgnorePatchKey] = string.Join(",", current.ToArray());
                        }
                        else
                        {
                            other_config.Add(IgnorePatchKey, ((XenServerPatchAlert)alert).Patch.Uuid);
                        }
                    }
                    if (alert is XenServerVersionAlert)
                    {
                        if (other_config.ContainsKey(LAST_SEEN_SERVER_VERSION_KEY))
                        {
                            List <string> current = new List <string>(other_config[LAST_SEEN_SERVER_VERSION_KEY].Split(','));
                            if (current.Contains(((XenServerVersionAlert)alert).Version.Version.ToString()))
                            {
                                continue;
                            }
                            current.Add(((XenServerVersionAlert)alert).Version.Version.ToString());
                            other_config[LAST_SEEN_SERVER_VERSION_KEY] = string.Join(",", current.ToArray());
                        }
                        else
                        {
                            other_config.Add(LAST_SEEN_SERVER_VERSION_KEY, ((XenServerVersionAlert)alert).Version.Version.ToString());
                        }
                    }
                    Updates.RemoveUpdate(alert);
                }

                XenAPI.Pool.set_other_config(connection.Session, pool.opaque_ref, other_config);
            }
        }
예제 #3
0
 public void RunCheck()
 {
     Updates.CheckForUpdates(actionCompleted);
 }