public void Switch(XenVM vm)
 {
     OnAlert("com.citrix.xenclient.xenmgr.host", "storage_space_low", new string[] { "69" });
 }
 public void Switch(XenVM vm)
 {
     xgsc.SwitchToVm((uint)vm.Slot);
 }
 public void Switch(XenVM vm)
 {
     // Don't allow this VM to switch if it does not have focus.
     if (CheckVmFocus()) // If this vm has focus
     {
         com.citrix.xenclient.xenmgr.vm.wcf.Contracts.Clients.VmProxy switchVm;
         ProxyBuilder.Create(out switchVm, DbusEndpointUriComponents.Create(EndpointBuilder, "com.citrix.xenclient.xenmgr", vm.Path.Path));
         try
         {
             switchVm.ProxyInterface.@switch();
         }
         finally
         {
             switchVm.Close();
         }
     } // Ends if this vm has focus
 }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
        private void RefreshButtons()
        {
            Program.AssertOnEventThread();
            var VMs = hostService.GetVMs();

            while (buttons.Count > 0)
            {
                VmButton button = buttons[0];
                buttons.RemoveAt(0);
                button.Dispose();
            }

            int totalWidth = 0;

            foreach (XenVM vm in VMs.Values)
            {
                if (vm.Slot == 0) // If uivm
                {
                    // Stash it, and skip.
                    this.uivm = vm;
                    continue;

                } // Ends if uivm

                if (vm.Hidden)
                {
                    continue;
                }
                VmButton button = new VmButton(vm, vm.Image, vm.UUID == hostService.UUID);
                //button.Cursor = Cursors.Hand;

                Controls.Add(button);
                buttons.Add(button);

                totalWidth += button.Width + BUTTON_PADDING;
            }

            totalWidth -= BUTTON_PADDING;

            int x = (Width - totalWidth) / 2;

            foreach (VmButton button in buttons)
            {
                button.Location = new Point(x, BUTTON_TOP_OFFSET);
                x += button.Width + BUTTON_PADDING;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Method available internally to switch to a VM and then hide the form
 /// </summary>
 /// <param name="vm"></param>
 internal void SwitchVM(XenVM vm)
 {
     hostService.Switch(vm);
     HideAnimated(false);
 }