Пример #1
0
        private static ComparableList <VDI> DisksProperty(IXenObject o)
        {
            var vdis = new ComparableList <VDI>();

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

            if (o is VDI theVdi)
            {
                vdis.Add(theVdi);
            }
            else if (o is VM vm)
            {
                if (vm.is_a_real_vm())
                {
                    foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs))
                    {
                        VDI vdi = vbd.Connection.Resolve(vbd.VDI);
                        if (vdi != null && !vdis.Contains(vdi))
                        {
                            vdis.Add(vdi);
                        }
                    }
                }
            }

            return(vdis);
        }
Пример #2
0
        private static ComparableList <SR> StorageProperty(IXenObject o)
        {
            var srs = new ComparableList <SR>();

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

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

                        SR sr = vdi.Connection.Resolve(vdi.SR);
                        if (sr != null && !srs.Contains(sr))
                        {
                            srs.Add(sr);
                        }
                    }
                }
            }
            else if (o is SR sr)
            {
                srs.Add(sr);
            }
            else if (o is VDI vdi)
            {
                SR theSr = vdi.Connection.Resolve(vdi.SR);
                if (theSr == null)
                {
                    return(null);
                }

                srs.Add(theSr);
            }

            return(srs);
        }