/// <summary>
        /// Tests starting a VM
        /// </summary>
        static void Test_StartVM(Host host, string uuid)
        {
            Console.WriteLine("Starting virtual machine with uuid " + uuid);
            XenConnect con    = new XenConnect(host, testServerId, testip);
            XenError   status = con.startVm(uuid);

            if (status.Type == XenError.XenErrorType.SUCCESS)
            {
                Console.WriteLine("VM with uuid " + uuid + " started successfully");
            }
            else
            {
                Console.WriteLine("Unable to start vm with uuid " + uuid + " " + status.Message);
            }
        }
Beispiel #2
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;
            KeyValuePair <string, VM> kvpVM = (KeyValuePair <string, VM>)item.DataContext;

            string menuOption = item.Header.ToString();


            VM   vm   = kvpVM.Value;
            Host host = SysManager.getVmHost(vm.UUID);

            XenConnect conn = new XenConnect(host, Settings.SystemIdentifier, Settings.SystemIp);


            switch (menuOption)
            {
            case "Start":
                Task.Run(() => conn.startVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Stop":
                Task.Run(() => conn.stopVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Pause":
                Task.Run(() => conn.pauseVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Resume":
                Task.Run(() => conn.resumeVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Force Shutdown":
                Task.Run(() => conn.ForceShutdownVm(vm.UUID));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Delete":
                //Task.Run(() => conn.cloneVm(vm.UUID, "CopyOf" + vm.Name));
                //conn.Notifications += e_logXenMasterNotification;
                notifyUser("The virtual machine SeniorBuntu has been deleted", "Virtual Machine Deleted", MessageBoxImage.Information);
                break;

            case "Clone":
                Task.Run(() => conn.cloneVm(vm.UUID, "CopyOf" + vm.Name));
                conn.Notifications += e_logXenMasterNotification;
                break;

            case "Remote Control":
                Application.Current.Dispatcher.Invoke((Action) delegate {
                    remoteView(host, vm);
                });
                break;

            case "Info":
                VMInfoWindow newHostWin = new VMInfoWindow(vm);
                newHostWin.Show();
                break;

            default:
                return;
            }
        }