protected override void Run()
        {
            if (!AllowedToRestoreDismissedUpdates())
            {
                return;
            }

            XenAPI.Pool pool = Helpers.GetPoolOfOne(Connection);
            if (pool == null)
            {
                return;
            }

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

            if (other_config.ContainsKey(Updates.IgnorePatchKey))
            {
                other_config.Remove(Updates.IgnorePatchKey);
            }

            if (other_config.ContainsKey(Updates.LAST_SEEN_SERVER_VERSION_KEY))
            {
                other_config.Remove(Updates.LAST_SEEN_SERVER_VERSION_KEY);
            }


            XenAPI.Pool.set_other_config(Connection.Session, pool.opaque_ref, other_config);
        }
Esempio n. 2
0
 public PoolMetadata(XenAPI.Pool pool, VDI vdi)
 {
     Pool         = pool;
     Vdi          = vdi;
     VmAppliances = new Dictionary <XenRef <VM_appliance>, VM_appliance>();
     Vms          = new Dictionary <XenRef <VM>, VM>();
 }
Esempio n. 3
0
 /// <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);
     }
 }
Esempio n. 4
0
 public DestroyPoolAction(XenAPI.Pool pool)
     : base(pool.Connection, string.Format(Messages.DESTROYING_POOL, pool.Name()))
 {
     System.Diagnostics.Trace.Assert(pool != null);
     Pool             = pool;
     this.Description = Messages.WAITING;
 }
Esempio n. 5
0
        public static void RestoreDismissedUpdates()
        {
            foreach (IXenConnection _connection in ConnectionsManager.XenConnectionsCopy)
            {
                XenAPI.Pool pool = Helpers.GetPoolOfOne(_connection);
                if (pool == null)
                {
                    continue;
                }

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

                if (other_config.ContainsKey(IgnorePatchAction.IgnorePatchKey))
                {
                    other_config.Remove(IgnorePatchAction.IgnorePatchKey);
                }
                if (other_config.ContainsKey(IgnoreServerAction.LAST_SEEN_SERVER_VERSION_KEY))
                {
                    other_config.Remove(IgnoreServerAction.LAST_SEEN_SERVER_VERSION_KEY);
                }

                XenAPI.Pool.set_other_config(_connection.Session, pool.opaque_ref, other_config);
            }

            Properties.Settings.Default.LatestXenCenterSeen = "";
            Settings.TrySaveSettings();

            Updates.CheckForUpdates(true);
        }
Esempio n. 6
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)
        {
            foreach (IXenConnection connection in ConnectionsManager.XenConnectionsCopy)
            {
                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(IgnorePatchAction.IgnorePatchKey))
                        {
                            List <string> current = new List <string>(other_config[IgnorePatchAction.IgnorePatchKey].Split(','));
                            if (current.Contains(((XenServerPatchAlert)alert).Patch.Uuid))
                            {
                                continue;
                            }
                            current.Add(((XenServerPatchAlert)alert).Patch.Uuid);
                            other_config[IgnorePatchAction.IgnorePatchKey] = string.Join(",", current.ToArray());
                        }
                        else
                        {
                            other_config.Add(IgnorePatchAction.IgnorePatchKey, ((XenServerPatchAlert)alert).Patch.Uuid);
                        }
                    }
                    if (alert is XenServerVersionAlert)
                    {
                        if (other_config.ContainsKey(IgnoreServerAction.LAST_SEEN_SERVER_VERSION_KEY))
                        {
                            List <string> current = new List <string>(other_config[IgnoreServerAction.LAST_SEEN_SERVER_VERSION_KEY].Split(','));
                            if (current.Contains(((XenServerVersionAlert)alert).Version.VersionAndOEM))
                            {
                                continue;
                            }
                            current.Add(((XenServerVersionAlert)alert).Version.VersionAndOEM);
                            other_config[IgnoreServerAction.LAST_SEEN_SERVER_VERSION_KEY] = string.Join(",", current.ToArray());
                        }
                        else
                        {
                            other_config.Add(IgnoreServerAction.LAST_SEEN_SERVER_VERSION_KEY, ((XenServerVersionAlert)alert).Version.VersionAndOEM);
                        }
                    }
                    Updates.RemoveUpdate(alert);
                }

                XenAPI.Pool.set_other_config(connection.Session, pool.opaque_ref, other_config);
            }
        }
Esempio n. 7
0
        private bool IsDismissed(IXenConnection connection)
        {
            XenAPI.Pool pool = Helpers.GetPoolOfOne(connection);
            if (pool == null)
                return false;

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

            if (other_config.ContainsKey(IgnorePatchAction.IgnorePatchKey))
            {
                List<string> current = new List<string>(other_config[IgnorePatchAction.IgnorePatchKey].Split(','));
                if (current.Contains(Patch.Uuid))
                    return true;
            }
            return false;
        }
        private void ProcessRecordMetadataOfPool(string vdi)
        {
            RunApiCall(() =>
            {
                string objRef = XenAPI.VDI.get_metadata_of_pool(session, vdi);

                XenAPI.Pool obj = null;

                if (objRef != "OpaqueRef:NULL")
                {
                    obj            = XenAPI.Pool.get_record(session, objRef);
                    obj.opaque_ref = objRef;
                }

                WriteObject(obj, true);
            });
        }
Esempio n. 9
0
        private bool IsDismissed(IXenConnection connection)
        {
            XenAPI.Pool pool = Helpers.GetPoolOfOne(connection);
            if (pool == null)
            {
                return(false);
            }

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

            if (other_config.ContainsKey(IgnorePatchAction.IgnorePatchKey))
            {
                List <string> current = new List <string>(other_config[IgnorePatchAction.IgnorePatchKey].Split(','));
                if (current.Contains(Patch.Uuid, StringComparer.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 10
0
        /// <summary>
        /// If we're joining a pool that has a non-shared default/crash/suspend SR, then clear that
        /// pool's default SRs, since a pool with default SRs set to local storage is a confusing
        /// configuration that we do not allow to be set through the GUI (only shared SRs can be set
        /// as the default in pools, even though xapi allows otherwise).
        /// </summary>
        /// <param name="pool"></param>
        protected void ClearNonSharedSrs(Pool pool)
        {
            SR defSR = pool.Connection.Resolve <SR>(pool.default_SR);

            if (defSR != null && !defSR.shared)
            {
                XenAPI.Pool poolCopy = (Pool)pool.Clone();
                poolCopy.default_SR       = new XenRef <SR>(Helper.NullOpaqueRef);
                poolCopy.crash_dump_SR    = new XenRef <SR>(Helper.NullOpaqueRef);
                poolCopy.suspend_image_SR = new XenRef <SR>(Helper.NullOpaqueRef);
                pool.Locked = true;
                try
                {
                    poolCopy.SaveChanges(Session);
                }
                finally
                {
                    pool.Locked = false;
                }
            }
        }
        public SetCslgCredentialsToPoolAction(IXenConnection connection, string host, string username, string password)
            : base(connection,
                   string.Format(Messages.SET_STORAGELINK_CREDS_TO_POOL_ACTION_TITLE, Helpers.GetPoolOfOne(connection)),
                   string.Format(Messages.SET_STORAGELINK_CREDS_TO_POOL_ACTION_DESCRIPTION, Helpers.GetPoolOfOne(connection)))
        {
            Util.ThrowIfParameterNull(connection, "connection");

            _host     = host;
            _username = username;
            _password = password;

            if (Helpers.FeatureForbidden(connection, Host.RestrictStorageChoices))
            {
                throw new ArgumentException("Pool not licensed.", "host");
            }

            if (!Helpers.MidnightRideOrGreater(connection))
            {
                throw new ArgumentException("Pool must by Midnight Ride or later.", "host");
            }

            XenAPI.Pool pool = Helpers.GetPool(Connection);

            if (pool != null)
            {
                AppliesTo.Add(pool.opaque_ref);
            }
            else
            {
                XenAPI.Host master = Helpers.GetMaster(Connection);

                if (master != null)
                {
                    AppliesTo.Add(master.opaque_ref);
                }
            }
        }
Esempio n. 12
0
        public static bool IsDefaultSr(SR sr)
        {
            Pool pool = Helpers.GetPoolOfOne(sr.Connection);

            return(pool != null && pool.default_SR != null && pool.default_SR.opaque_ref == sr.opaque_ref);
        }
Esempio n. 13
0
 protected override void ProcessRecord()
 {
     XenAPI.Session session = XenObject as XenAPI.Session;
     if (session != null)
     {
         WriteObject(new XenRef <XenAPI.Session>(session));
         return;
     }
     XenAPI.Auth auth = XenObject as XenAPI.Auth;
     if (auth != null)
     {
         WriteObject(new XenRef <XenAPI.Auth>(auth));
         return;
     }
     XenAPI.Subject subject = XenObject as XenAPI.Subject;
     if (subject != null)
     {
         WriteObject(new XenRef <XenAPI.Subject>(subject));
         return;
     }
     XenAPI.Role role = XenObject as XenAPI.Role;
     if (role != null)
     {
         WriteObject(new XenRef <XenAPI.Role>(role));
         return;
     }
     XenAPI.Task task = XenObject as XenAPI.Task;
     if (task != null)
     {
         WriteObject(new XenRef <XenAPI.Task>(task));
         return;
     }
     XenAPI.Event evt = XenObject as XenAPI.Event;
     if (evt != null)
     {
         WriteObject(new XenRef <XenAPI.Event>(evt));
         return;
     }
     XenAPI.Pool pool = XenObject as XenAPI.Pool;
     if (pool != null)
     {
         WriteObject(new XenRef <XenAPI.Pool>(pool));
         return;
     }
     XenAPI.Pool_patch pool_patch = XenObject as XenAPI.Pool_patch;
     if (pool_patch != null)
     {
         WriteObject(new XenRef <XenAPI.Pool_patch>(pool_patch));
         return;
     }
     XenAPI.Pool_update pool_update = XenObject as XenAPI.Pool_update;
     if (pool_update != null)
     {
         WriteObject(new XenRef <XenAPI.Pool_update>(pool_update));
         return;
     }
     XenAPI.VM vm = XenObject as XenAPI.VM;
     if (vm != null)
     {
         WriteObject(new XenRef <XenAPI.VM>(vm));
         return;
     }
     XenAPI.VM_metrics vm_metrics = XenObject as XenAPI.VM_metrics;
     if (vm_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VM_metrics>(vm_metrics));
         return;
     }
     XenAPI.VM_guest_metrics vm_guest_metrics = XenObject as XenAPI.VM_guest_metrics;
     if (vm_guest_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VM_guest_metrics>(vm_guest_metrics));
         return;
     }
     XenAPI.VMPP vmpp = XenObject as XenAPI.VMPP;
     if (vmpp != null)
     {
         WriteObject(new XenRef <XenAPI.VMPP>(vmpp));
         return;
     }
     XenAPI.VMSS vmss = XenObject as XenAPI.VMSS;
     if (vmss != null)
     {
         WriteObject(new XenRef <XenAPI.VMSS>(vmss));
         return;
     }
     XenAPI.VM_appliance vm_appliance = XenObject as XenAPI.VM_appliance;
     if (vm_appliance != null)
     {
         WriteObject(new XenRef <XenAPI.VM_appliance>(vm_appliance));
         return;
     }
     XenAPI.DR_task dr_task = XenObject as XenAPI.DR_task;
     if (dr_task != null)
     {
         WriteObject(new XenRef <XenAPI.DR_task>(dr_task));
         return;
     }
     XenAPI.Host host = XenObject as XenAPI.Host;
     if (host != null)
     {
         WriteObject(new XenRef <XenAPI.Host>(host));
         return;
     }
     XenAPI.Host_crashdump host_crashdump = XenObject as XenAPI.Host_crashdump;
     if (host_crashdump != null)
     {
         WriteObject(new XenRef <XenAPI.Host_crashdump>(host_crashdump));
         return;
     }
     XenAPI.Host_patch host_patch = XenObject as XenAPI.Host_patch;
     if (host_patch != null)
     {
         WriteObject(new XenRef <XenAPI.Host_patch>(host_patch));
         return;
     }
     XenAPI.Host_metrics host_metrics = XenObject as XenAPI.Host_metrics;
     if (host_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.Host_metrics>(host_metrics));
         return;
     }
     XenAPI.Host_cpu host_cpu = XenObject as XenAPI.Host_cpu;
     if (host_cpu != null)
     {
         WriteObject(new XenRef <XenAPI.Host_cpu>(host_cpu));
         return;
     }
     XenAPI.Network network = XenObject as XenAPI.Network;
     if (network != null)
     {
         WriteObject(new XenRef <XenAPI.Network>(network));
         return;
     }
     XenAPI.VIF vif = XenObject as XenAPI.VIF;
     if (vif != null)
     {
         WriteObject(new XenRef <XenAPI.VIF>(vif));
         return;
     }
     XenAPI.VIF_metrics vif_metrics = XenObject as XenAPI.VIF_metrics;
     if (vif_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VIF_metrics>(vif_metrics));
         return;
     }
     XenAPI.PIF pif = XenObject as XenAPI.PIF;
     if (pif != null)
     {
         WriteObject(new XenRef <XenAPI.PIF>(pif));
         return;
     }
     XenAPI.PIF_metrics pif_metrics = XenObject as XenAPI.PIF_metrics;
     if (pif_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.PIF_metrics>(pif_metrics));
         return;
     }
     XenAPI.Bond bond = XenObject as XenAPI.Bond;
     if (bond != null)
     {
         WriteObject(new XenRef <XenAPI.Bond>(bond));
         return;
     }
     XenAPI.VLAN vlan = XenObject as XenAPI.VLAN;
     if (vlan != null)
     {
         WriteObject(new XenRef <XenAPI.VLAN>(vlan));
         return;
     }
     XenAPI.SM sm = XenObject as XenAPI.SM;
     if (sm != null)
     {
         WriteObject(new XenRef <XenAPI.SM>(sm));
         return;
     }
     XenAPI.SR sr = XenObject as XenAPI.SR;
     if (sr != null)
     {
         WriteObject(new XenRef <XenAPI.SR>(sr));
         return;
     }
     XenAPI.LVHD lvhd = XenObject as XenAPI.LVHD;
     if (lvhd != null)
     {
         WriteObject(new XenRef <XenAPI.LVHD>(lvhd));
         return;
     }
     XenAPI.VDI vdi = XenObject as XenAPI.VDI;
     if (vdi != null)
     {
         WriteObject(new XenRef <XenAPI.VDI>(vdi));
         return;
     }
     XenAPI.VBD vbd = XenObject as XenAPI.VBD;
     if (vbd != null)
     {
         WriteObject(new XenRef <XenAPI.VBD>(vbd));
         return;
     }
     XenAPI.VBD_metrics vbd_metrics = XenObject as XenAPI.VBD_metrics;
     if (vbd_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VBD_metrics>(vbd_metrics));
         return;
     }
     XenAPI.PBD pbd = XenObject as XenAPI.PBD;
     if (pbd != null)
     {
         WriteObject(new XenRef <XenAPI.PBD>(pbd));
         return;
     }
     XenAPI.Crashdump crashdump = XenObject as XenAPI.Crashdump;
     if (crashdump != null)
     {
         WriteObject(new XenRef <XenAPI.Crashdump>(crashdump));
         return;
     }
     XenAPI.VTPM vtpm = XenObject as XenAPI.VTPM;
     if (vtpm != null)
     {
         WriteObject(new XenRef <XenAPI.VTPM>(vtpm));
         return;
     }
     XenAPI.Console console = XenObject as XenAPI.Console;
     if (console != null)
     {
         WriteObject(new XenRef <XenAPI.Console>(console));
         return;
     }
     XenAPI.User user = XenObject as XenAPI.User;
     if (user != null)
     {
         WriteObject(new XenRef <XenAPI.User>(user));
         return;
     }
     XenAPI.Data_source data_source = XenObject as XenAPI.Data_source;
     if (data_source != null)
     {
         WriteObject(new XenRef <XenAPI.Data_source>(data_source));
         return;
     }
     XenAPI.Blob blob = XenObject as XenAPI.Blob;
     if (blob != null)
     {
         WriteObject(new XenRef <XenAPI.Blob>(blob));
         return;
     }
     XenAPI.Message message = XenObject as XenAPI.Message;
     if (message != null)
     {
         WriteObject(new XenRef <XenAPI.Message>(message));
         return;
     }
     XenAPI.Secret secret = XenObject as XenAPI.Secret;
     if (secret != null)
     {
         WriteObject(new XenRef <XenAPI.Secret>(secret));
         return;
     }
     XenAPI.Tunnel tunnel = XenObject as XenAPI.Tunnel;
     if (tunnel != null)
     {
         WriteObject(new XenRef <XenAPI.Tunnel>(tunnel));
         return;
     }
     XenAPI.PCI pci = XenObject as XenAPI.PCI;
     if (pci != null)
     {
         WriteObject(new XenRef <XenAPI.PCI>(pci));
         return;
     }
     XenAPI.PGPU pgpu = XenObject as XenAPI.PGPU;
     if (pgpu != null)
     {
         WriteObject(new XenRef <XenAPI.PGPU>(pgpu));
         return;
     }
     XenAPI.GPU_group gpu_group = XenObject as XenAPI.GPU_group;
     if (gpu_group != null)
     {
         WriteObject(new XenRef <XenAPI.GPU_group>(gpu_group));
         return;
     }
     XenAPI.VGPU vgpu = XenObject as XenAPI.VGPU;
     if (vgpu != null)
     {
         WriteObject(new XenRef <XenAPI.VGPU>(vgpu));
         return;
     }
     XenAPI.VGPU_type vgpu_type = XenObject as XenAPI.VGPU_type;
     if (vgpu_type != null)
     {
         WriteObject(new XenRef <XenAPI.VGPU_type>(vgpu_type));
         return;
     }
     XenAPI.PVS_site pvs_site = XenObject as XenAPI.PVS_site;
     if (pvs_site != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_site>(pvs_site));
         return;
     }
     XenAPI.PVS_server pvs_server = XenObject as XenAPI.PVS_server;
     if (pvs_server != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_server>(pvs_server));
         return;
     }
     XenAPI.PVS_proxy pvs_proxy = XenObject as XenAPI.PVS_proxy;
     if (pvs_proxy != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_proxy>(pvs_proxy));
         return;
     }
     XenAPI.PVS_cache_storage pvs_cache_storage = XenObject as XenAPI.PVS_cache_storage;
     if (pvs_cache_storage != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_cache_storage>(pvs_cache_storage));
         return;
     }
     XenAPI.Feature feature = XenObject as XenAPI.Feature;
     if (feature != null)
     {
         WriteObject(new XenRef <XenAPI.Feature>(feature));
         return;
     }
     XenAPI.SDN_controller sdn_controller = XenObject as XenAPI.SDN_controller;
     if (sdn_controller != null)
     {
         WriteObject(new XenRef <XenAPI.SDN_controller>(sdn_controller));
         return;
     }
     XenAPI.Vdi_nbd_server_info vdi_nbd_server_info = XenObject as XenAPI.Vdi_nbd_server_info;
     if (vdi_nbd_server_info != null)
     {
         WriteObject(new XenRef <XenAPI.Vdi_nbd_server_info>(vdi_nbd_server_info));
         return;
     }
     XenAPI.PUSB pusb = XenObject as XenAPI.PUSB;
     if (pusb != null)
     {
         WriteObject(new XenRef <XenAPI.PUSB>(pusb));
         return;
     }
     XenAPI.USB_group usb_group = XenObject as XenAPI.USB_group;
     if (usb_group != null)
     {
         WriteObject(new XenRef <XenAPI.USB_group>(usb_group));
         return;
     }
     XenAPI.VUSB vusb = XenObject as XenAPI.VUSB;
     if (vusb != null)
     {
         WriteObject(new XenRef <XenAPI.VUSB>(vusb));
         return;
     }
 }