Example #1
0
        public void SetXenObjects(IXenObject[] objects)
        {
            InvokeHelper.AssertOnEventThread();

            // The QueryPanel can trigger this too often (sometimes more than once when we switch to it).
            // So we do a preliminary check of whether any changes will be needed to the data structures.
            // Without this, we wipe out the stats, and can sometimes then display them before they've been
            // repopulated. This check used to be at the end of this function, just before _hosts = hosts,
            // but it's cheaper to do it up front, at the expense of some code duplication.

            if (!AnyNewObjects(objects))
            {
                return;
            }

            var hosts = new ConcurrentDictionary <Host, HostMetric>();

            // Create HostMetric's for all the hosts
            foreach (IXenObject obj in objects)
            {
                Host host = obj as Host;
                if (host != null)
                {
                    hosts[host] = new HostMetric();
                }
            }

            // Create VmMetric's for all the VMs, and put them under their hosts, indexed by uuid
            foreach (IXenObject obj in objects)
            {
                VM vm = obj as VM;
                if (vm != null)
                {
                    Host host = GetHost(vm);
                    if (host != null)
                    {
                        var    hm   = hosts.GetOrAdd(host, new HostMetric());
                        string uuid = Helpers.GetUuid(vm);
                        hm.VMs[uuid] = new VmMetric();
                    }
                }
            }

            lock (_hostsLock)
            {
                _hosts = hosts;
            }

            _skip_sleep = true;
            lock (_sleepMonitor)
                Monitor.PulseAll(_sleepMonitor);
        }
Example #2
0
        private static void RemoveObject(IXenObject ixmo)
        {
            InvokeHelper.AssertOnEventThread();

            XenRef <Folder> path   = new XenRef <Folder>(ixmo.Path);
            Folder          folder = ixmo.Connection.Resolve(path);

            if (folder != null)
            {
                folder.RemoveObject(ixmo);
                PotentiallyRemoveFolder(folder);
            }
        }
Example #3
0
        private static void UpdateDockerContainer(VM vm)
        {
            InvokeHelper.AssertOnEventThread();

            if (vm == null)
            {
                return;
            }

            IXenConnection connection = vm.Connection;

            var dockerVMs = GetDockerVMs(vm);

            connection.Cache.UpdateDockerContainersForVM(dockerVMs, vm);
        }
Example #4
0
        private static void UpdateEmptyFolders(IXenConnection connection)
        {
            InvokeHelper.AssertOnEventThread();

            String[] emptyFolders = GetEmptyFolders(connection);

            Folder root = connection.Resolve(new XenRef <Folder>(PATH_SEPARATOR));

            if (root != null)
            {
                PurgeEmptyFolders(emptyFolders, root);
            }

            foreach (String path in emptyFolders)
            {
                GetOrCreateFolder(connection, path);
            }
        }