/// <summary>
        ///     Parses background images and colors.
        /// </summary>
        /// <param name="elem"></param>
        /// <returns></returns>
        private static List <IBackground> ParseBackgroundImages(XmlElement elem)
        {
            List <IBackground> list = new ComparableList <IBackground>();

            list.AddRange(from XmlElement e in elem
                          where e.Name == "file"
                          select PowerPraiseFileUtil.ParseBackground(e.InnerText));
            return(list);
        }
예제 #2
0
파일: Common.cs 프로젝트: ywscr/xenadmin
        private static ComparableList <Host> HostProperty(IXenObject o)
        {
            var hosts = new ComparableList <Host>();

            if (o.Connection == null)
            {
                return(hosts);
            }

            // If we're not in a pool then just group everything under the same host
            Pool pool = Helpers.GetPool(o.Connection);

            if (pool == null)
            {
                hosts.AddRange(o.Connection.Cache.Hosts);
            }
            else if (o is VM vm)
            {
                Host host = vm.Home();
                if (host != null)
                {
                    hosts.Add(host);
                }
            }
            else if (o is SR sr)
            {
                Host host = sr.Home();
                if (host != null)
                {
                    hosts.Add(host);
                }
            }
            else if (o is XenAPI.Network network)
            {
                if (network.PIFs.Count == 0)
                {
                    hosts.AddRange(network.Connection.Cache.Hosts);
                }
            }
            else if (o is Host host)
            {
                hosts.Add(host);
            }
            else if (o is VDI vdi)
            {
                SR theSr = vdi.Connection.Resolve(vdi.SR);
                if (theSr != null)
                {
                    hosts.Add(theSr.Home());
                }
            }
            else if (o is DockerContainer container)
            {
                VM   parent   = container.Parent;
                Host homeHost = parent.Home();
                if (homeHost != null)
                {
                    hosts.Add(homeHost);
                }
            }

            return(hosts);
        }
예제 #3
0
파일: Common.cs 프로젝트: ywscr/xenadmin
        private static ComparableList <VM> VMProperty(IXenObject o)
        {
            var vms = new ComparableList <VM>();

            if (o.Connection == null)
            {
                return(vms);
            }

            if (o is Pool)
            {
                vms.AddRange(o.Connection.Cache.VMs);
            }
            else if (o is Host host)
            {
                vms.AddRange(host.Connection.ResolveAll(host.resident_VMs));
            }
            else if (o is SR sr)
            {
                foreach (VDI vdi in sr.Connection.ResolveAll(sr.VDIs))
                {
                    foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
                    {
                        VM vm = vbd.Connection.Resolve(vbd.VM);
                        if (vm == null)
                        {
                            continue;
                        }

                        vms.Add(vm);
                    }
                }
            }
            else if (o is XenAPI.Network network)
            {
                foreach (VIF vif in network.Connection.ResolveAll(network.VIFs))
                {
                    VM vm = vif.Connection.Resolve(vif.VM);
                    if (vm == null)
                    {
                        continue;
                    }

                    vms.Add(vm);
                }
            }
            else if (o is VDI vdi)
            {
                foreach (VBD vbd in vdi.Connection.ResolveAll(vdi.VBDs))
                {
                    VM vm = vbd.Connection.Resolve(vbd.VM);
                    if (vm == null)
                    {
                        continue;
                    }

                    vms.Add(vm);
                }
            }
            else if (o is VM vm)
            {
                if (vm.is_a_snapshot)
                {
                    VM from = vm.Connection.Resolve(vm.snapshot_of);
                    if (from != null)  // Can be null if VM has been deleted: CA-29249
                    {
                        vms.Add(from);
                    }
                }
                else
                {
                    vms.Add(vm);
                }
            }
            else if (o is DockerContainer container)
            {
                vms.Add(container.Parent);
            }

            vms.RemoveAll(vm => !vm.is_a_real_vm());
            return(vms);
        }
예제 #4
0
 public Selection(params IXenObject[] objects)
 {
     Objects.AddRange(objects);
     Objects.Sort();
 }