/// <summary> /// Attempts to set the LastPowerOnSucceeded flag in the WLB Host configuration /// </summary> private void UpdateHostLastPowerOnSucceeded(bool succeeded, XenAPI.Host host) { try { //Helpers.SetOtherConfig(this.Host.Connection.Session, this.Host, "LastPowerOnsucceeded", successful.ToString()); WlbHostConfiguration hostConfig = new WlbHostConfiguration(host.uuid); hostConfig.LastPowerOnSucceeded = succeeded; if (!succeeded) { hostConfig.ParticipatesInPowerManagement = false; } XenAPI.Pool pool = Helpers.GetPoolOfOne(host.Connection); if (null != pool) { SendWlbConfigurationAction action = new SendWlbConfigurationAction(pool, hostConfig.ToDictionary(), SendWlbConfigurationKind.SetHostConfiguration); action.RunExternal(Session); } else { throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_GONE); } } catch (Exception ex) { log.Error("Unable to set the host's LastPowerOnSucceeded status.", ex); } }
public AsyncAction SaveSettings() { _poolConfiguration.AutoBalanceEnabled = checkBoxUseAutomation.Checked; if (checkBoxUseAutomation.Checked) { _poolConfiguration.PowerManagementEnabled = checkBoxEnablePowerManagement.Checked; } else { _poolConfiguration.PowerManagementEnabled = false; } foreach (ListViewItem listItem in listViewExPowerManagementHosts.Items) { Host host = (Host)listItem.Tag; WlbHostConfiguration hostConfiguration; if (!_poolConfiguration.HostConfigurations.TryGetValue(host.uuid, out hostConfiguration)) { hostConfiguration = new WlbHostConfiguration(host.uuid); _poolConfiguration.HostConfigurations.Add(hostConfiguration.Uuid, hostConfiguration); } if ((listItem.Checked == true) && (!host.IsMaster())) { hostConfiguration.ParticipatesInPowerManagement = true; } else { hostConfiguration.ParticipatesInPowerManagement = false; } } return(null); }
public AsyncAction SaveSettings() { foreach (ListViewItem listItem in listViewExExcludedHosts.Items) { Host host = (Host)listItem.Tag; WlbHostConfiguration hostConfiguration; if (!_poolConfiguration.HostConfigurations.TryGetValue(host.uuid, out hostConfiguration)) { hostConfiguration = new WlbHostConfiguration(host.uuid); _poolConfiguration.HostConfigurations.Add(hostConfiguration.Uuid, hostConfiguration); } hostConfiguration.Excluded = listItem.Checked; } return(null); }
public AsyncAction SaveSettings() { _poolConfiguration.AutoBalanceEnabled = checkBoxUseAutomation.Checked; if (checkBoxUseAutomation.Checked) { _poolConfiguration.PowerManagementEnabled = checkBoxEnablePowerManagement.Checked; } else { _poolConfiguration.PowerManagementEnabled = false; } foreach (ListViewItem listItem in listViewExPowerManagementHosts.Items) { Host host = (Host)listItem.Tag; WlbHostConfiguration hostConfiguration; if (!_poolConfiguration.HostConfigurations.TryGetValue(host.uuid, out hostConfiguration)) { hostConfiguration = new WlbHostConfiguration(host.uuid); _poolConfiguration.HostConfigurations.Add(hostConfiguration.Uuid, hostConfiguration); } if ((listItem.Checked == true) && (!host.IsMaster())) { hostConfiguration.ParticipatesInPowerManagement = true; } else { hostConfiguration.ParticipatesInPowerManagement = false; } } return null; }
private void SaveConfig(Host host, Host.PowerOnMode mode) { var newMode = mode.ToString(); var config = mode.Config; string secretuuid = ""; if (newMode == "iLO" && Helpers.StockholmOrGreater(Connection)) { //the UI should have already prevented us from getting here, but be defensive newMode = ""; config = new Dictionary <string, string>(); } try { if (newMode == "DRAC" || newMode == "iLO" || newMode != "wake-on-lan" && newMode != "") { if (config.ContainsKey("power_on_password_secret")) { secretuuid = Secret.CreateSecret(Session, config["power_on_password_secret"]); config["power_on_password_secret"] = secretuuid; } } else if (string.IsNullOrEmpty(newMode)) { //if WLB is on, we need to exclude the host from WLB power management, //since we cannot turn it back on if it is powered down automatically try { Pool pool = Helpers.GetPool(Connection); if (pool != null && WlbServerState.GetState(pool) == WlbServerState.ServerState.Enabled) { var hostConfig = new WlbHostConfiguration(host.uuid) { ParticipatesInPowerManagement = false }; var wlbAction = new SendWlbConfigurationAction(pool, hostConfig.ToDictionary(), SendWlbConfigurationKind.SetHostConfiguration); wlbAction.RunExternal(Session); } } catch { //Do nothing on failure. } } Host.set_power_on_mode(Session, host.opaque_ref, newMode, config); } catch { if (!string.IsNullOrEmpty(secretuuid)) { string secretRef = Secret.get_by_uuid(Session, secretuuid); Secret.destroy(Session, secretRef); } throw; } }
protected void SaveConfig(Host host) { string secretuuid = ""; try { Dictionary<string, string> powerONConfig = new Dictionary<string, string>(); if (newMode == "DRAC" || newMode == "iLO") { powerONConfig.Add("power_on_ip", ip); powerONConfig.Add("power_on_user", user); secretuuid = Secret.CreateSecret(Session, password); powerONConfig.Add("power_on_password_secret", secretuuid); } else if (newMode != "wake-on-lan" && newMode != "") { foreach (KeyValuePair<string, string> pair in customConfig) { if (pair.Key == "power_on_password_secret") { secretuuid = Secret.CreateSecret(Session, pair.Value); powerONConfig.Add(pair.Key, secretuuid); } else powerONConfig.Add(pair.Key, pair.Value); } } else if (string.IsNullOrEmpty(newMode)) { // We don't want this bit to alter the function of the main action so... try { Pool pool = Core.Helpers.GetPool(this.Connection); if (null != pool) { if (WlbServerState.GetState(pool) == XenAdmin.Wlb.WlbServerState.ServerState.Enabled) { //Tell WLB to not allow this host to be powered down automatically, since we cannot turn it back on WlbHostConfiguration hostConfig = new WlbHostConfiguration(host.uuid); hostConfig.ParticipatesInPowerManagement = false; //Use the existing SendWlbConfig action, as it wraps the config functionality // as well as the RBAC checks. SendWlbConfigurationAction wlbAction = new SendWlbConfigurationAction(pool, hostConfig.ToDictionary(), SendWlbConfigurationKind.SetHostConfiguration); wlbAction.RunExternal(Session); } } } catch (Exception) { //Do nothing on failure. } } Host.set_power_on_mode(Session, host.opaque_ref, newMode, powerONConfig); } catch (Exception e) { if (!string.IsNullOrEmpty(secretuuid)) { string secretRef = Secret.get_by_uuid(Session, secretuuid); Secret.destroy(Session, secretRef); } throw e; } }
protected void SaveConfig(Host host) { string secretuuid = ""; try { Dictionary <string, string> powerONConfig = new Dictionary <string, string>(); if (newMode == "DRAC" || newMode == "iLO") { powerONConfig.Add("power_on_ip", ip); powerONConfig.Add("power_on_user", user); secretuuid = Secret.CreateSecret(Session, password); powerONConfig.Add("power_on_password_secret", secretuuid); } else if (newMode != "wake-on-lan" && newMode != "") { foreach (KeyValuePair <string, string> pair in customConfig) { if (pair.Key == "power_on_password_secret") { secretuuid = Secret.CreateSecret(Session, pair.Value); powerONConfig.Add(pair.Key, secretuuid); } else { powerONConfig.Add(pair.Key, pair.Value); } } } else if (string.IsNullOrEmpty(newMode)) { // We don't want this bit to alter the function of the main action so... try { Pool pool = Core.Helpers.GetPool(this.Connection); if (null != pool) { if (WlbServerState.GetState(pool) == XenAdmin.Wlb.WlbServerState.ServerState.Enabled) { //Tell WLB to not allow this host to be powered down automatically, since we cannot turn it back on WlbHostConfiguration hostConfig = new WlbHostConfiguration(host.uuid); hostConfig.ParticipatesInPowerManagement = false; //Use the existing SendWlbConfig action, as it wraps the config functionality // as well as the RBAC checks. SendWlbConfigurationAction wlbAction = new SendWlbConfigurationAction(pool, hostConfig.ToDictionary(), SendWlbConfigurationKind.SetHostConfiguration); wlbAction.RunExternal(Session); } } } catch (Exception) { //Do nothing on failure. } } Host.set_power_on_mode(Session, host.opaque_ref, newMode, powerONConfig); } catch (Exception e) { if (!string.IsNullOrEmpty(secretuuid)) { string secretRef = Secret.get_by_uuid(Session, secretuuid); Secret.destroy(Session, secretRef); } throw e; } }
public AsyncAction SaveSettings() { foreach (ListViewItem listItem in listViewExExcludedHosts.Items) { Host host = (Host)listItem.Tag; WlbHostConfiguration hostConfiguration; if (!_poolConfiguration.HostConfigurations.TryGetValue(host.uuid, out hostConfiguration)) { hostConfiguration = new WlbHostConfiguration(host.uuid); _poolConfiguration.HostConfigurations.Add(hostConfiguration.Uuid, hostConfiguration); } hostConfiguration.Excluded = listItem.Checked; } return null; }
/// <summary> /// Attempts to set the LastPowerOnSucceeded flag in the WLB Host configuration /// </summary> /// <param name="successful">bool </param> private void UpdateHostLastPowerOnSucceeded(bool succeeded, XenAPI.Host host) { try { //Helpers.SetOtherConfig(this.Host.Connection.Session, this.Host, "LastPowerOnsucceeded", successful.ToString()); WlbHostConfiguration hostConfig = new WlbHostConfiguration(host.uuid); hostConfig.LastPowerOnSucceeded = succeeded; if (!succeeded) { hostConfig.ParticipatesInPowerManagement = false; } XenAPI.Pool pool = Helpers.GetPoolOfOne(host.Connection); if (null != pool) { SendWlbConfigurationAction action = new SendWlbConfigurationAction(pool, hostConfig.ToDictionary(), SendWlbConfigurationKind.SetHostConfiguration); action.RunExternal(Session); } else { throw new Exception("Could not find host's pool."); } } catch (Exception ex) { log.Error("Unable to set the host's LastPowerOnSucceeded status.", ex); } }