Ejemplo n.º 1
0
        public XenGuestAgentLib.XenVmInfo GetVmObject(uint i)
        {
            var vm = new XenGuestAgentLib.XenVmInfo();

            //  vm.
            return(vm);
        }
Ejemplo n.º 2
0
        private static IEnumerable <XenVM> GetVMs()
        {
            uint count, i, j;

            XenGuestAgentLib.XenVmInfo xvic = null;

            try
            {
                count = xgsc.QueryVms();
                if (count > 20)
                {
                    throw new Exception("hack hack hack");
                }
            }
            catch (Exception e)
            {
                log.Debug("Exception reading VMS information from XenGuestServices", e);
                yield break;
            }

            for (i = 0; i < count; i++)
            {
                XenVM        xenvm = new XenVM();
                MemoryStream ms;
                Array        arr;
                Bitmap       blueImage;

                try
                {
                    xvic = xgsc.GetVmObject(i);
                }
                catch (Exception e)
                {
                    log.Debug("Exception reading VMS information at index: " + i, e);
                    yield break;
                }
                if (xvic == null)
                {
                    log.Debug("No VM object returned for index: " + i);
                    yield break;
                }
                xenvm.UUID   = xvic.GetUuid();
                xenvm.Name   = xvic.GetName();
                xenvm.Slot   = (int)xvic.GetSlot();
                xenvm.Hidden = xvic.IsHidden() || xvic.IsUivm();

                if (xvic.HasImage())
                {
                    ms  = new MemoryStream();
                    arr = xvic.GetImage();

                    for (j = 0; j < (uint)arr.GetLength(0); j++)
                    {
                        ms.WriteByte((byte)arr.GetValue(j));
                    }
                    xenvm.Image = Image.FromStream(ms);
                }
                else
                {
                    blueImage   = (Bitmap)Properties.Resources.Blue_VM.Clone();
                    xenvm.Image = blueImage;
                }

                Marshal.ReleaseComObject(xvic);
                xvic = null;

                yield return(xenvm);
            }
        }
Ejemplo n.º 3
0
 public XenGuestAgentLib.XenVmInfo GetVmObject(uint i)
 {
     var vm = new XenGuestAgentLib.XenVmInfo();
       //  vm.
     return vm;
 }