public HttpServer(object context = null, int port = Http.DefaultPort, IVM vm = null, Visualizer visualizer = null, bool discoverable = true) { this.port = port; this.visualizer = visualizer ?? new Visualizer(context); this.vm = vm ?? (new VM()); this.broadcaster = discoverable ? new DiscoveryBroadcaster() : null; }
public AppWindow(MyFlightSimulatorModel model, MainWindow main, IVM vm) { InitializeComponent(); // initializing the main wondow fields and the vm field this._main = main; this.vm = vm; // creating the view model of the dashboard DashboardVM dashboardVM = new DashboardVM(model); myDashboard.DataContext = dashboardVM; // creating the view model of the map MapVM mapVM = new MapVM(model); myMap.DataContext = mapVM; // creating the view model of the joystick JoystickVM joystickVm = new JoystickVM(model); myControlPlane.DataContext = joystickVm; myControlPlane.myJoystick.DataContext = joystickVm; // creating the view model of the dashboard errors myDashboardErrors.DataContext = dashboardVM; }
public HttpServer (object context = null, int port = Http.DefaultPort, IVM vm = null, Visualizer visualizer = null, bool discoverable = true) { this.port = port; this.visualizer = visualizer ?? new Visualizer (context); this.vm = vm ?? (new VM()); this.broadcaster = discoverable ? new DiscoveryBroadcaster () : null; }
public List <Dictionary <string, dynamic> > UpdateProcessList() { List <Dictionary <string, dynamic> > ret = new List <Dictionary <string, dynamic> >(); IVM hvm = (IVM)handle; Debug.Assert(state.HasFlag(VMSTATE.login)); IJob job = hvm.ListProcessesInGuest(0, null); ulong err = job.WaitWithoutResults(); Debug.Assert(err == 0); Debug.WriteLine("update process list...", name); int n = job.GetNumProperties(Constants.VIX_PROPERTY_JOB_RESULT_ITEM_NAME); int[] propids = new int[] { Constants.VIX_PROPERTY_JOB_RESULT_ITEM_NAME, Constants.VIX_PROPERTY_JOB_RESULT_PROCESS_ID, Constants.VIX_PROPERTY_JOB_RESULT_PROCESS_COMMAND }; for (int i = 0; i < n; i++) { Dictionary <string, dynamic> r = new Dictionary <string, dynamic>(); object robj = null; err = job.GetNthProperties(i, propids, ref robj); Debug.Assert(err == 0); object[] rarray = (object[])robj; r["name"] = (string)rarray[0]; r["pid"] = rarray[1]; r["cmd"] = (string)rarray[2]; ret.Add(r); } Program.CloseVixObject(job); return(ret); }
protected bool CanStop(string vmx) { if (!IsRunning(vmx)) { return(false); } IVM vm = GetResult <IVM2>(WaitForResults(_host.OpenVM(vmx, null))); int power_state = GetVMProperty <int>(vm, Constants.VIX_PROPERTY_VM_POWER_STATE); int alt = power_state & ~(Constants.VIX_POWERSTATE_POWERED_ON | IGNORED_POWER_FLAG); return(alt == 0); }
public void Login(string username, string password) { IVM hvm = (IVM)handle; Debug.WriteLine("wait for vmware-tools...", name); // Program.WaitJob(hvm.PowerOn(Constants.VIX_VMPOWEROP_LAUNCH_GUI, null, null), false); if (!((POWERSTATE)props["power"]).HasFlag(POWERSTATE.on)) { Debug.Assert(false, "PowerState must be ON", "{0} power_state = {1}", name, (POWERSTATE)props["power"]); } Program.WaitJob(hvm.WaitForToolsInGuest(3, null), false); Debug.WriteLine("login...", name); Program.WaitJob(hvm.LoginInGuest(username, password, Constants.VIX_LOGIN_IN_GUEST_REQUIRE_INTERACTIVE_ENVIRONMENT, null), false); state |= VMSTATE.login; }
/// <summary> /// Lists the vms matching the specified filter options /// </summary> /// <param name="options">The options to use when querying for vms</param> /// <returns>The vms matching the specified filter options</returns> public IEnumerable <PSVM> ListVMs(ListVMOptions options) { if (options == null) { throw new ArgumentNullException("options"); } string poolName = options.Pool == null ? options.PoolName : options.Pool.Name; // Get the single vm matching the specified name if (!string.IsNullOrEmpty(options.VMName)) { WriteVerbose(string.Format(Resources.GBVM_GetByName, options.VMName, poolName)); using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager()) { IVM vm = poolManager.GetVM(poolName, options.VMName, additionalBehaviors: options.AdditionalBehaviors); PSVM psVM = new PSVM(vm); return(new PSVM[] { psVM }); } } // List vms using the specified filter else { ODATADetailLevel odata = null; string verboseLogString = null; if (!string.IsNullOrEmpty(options.Filter)) { verboseLogString = string.Format(Resources.GBVM_GetByOData, poolName); odata = new ODATADetailLevel(filterClause: options.Filter); } else { verboseLogString = string.Format(Resources.GBVM_NoFilter, poolName); } WriteVerbose(verboseLogString); using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager()) { IEnumerableAsyncExtended <IVM> vms = poolManager.ListVMs(poolName, odata, options.AdditionalBehaviors); Func <IVM, PSVM> mappingFunction = v => { return(new PSVM(v)); }; return(PSAsyncEnumerable <PSVM, IVM> .CreateWithMaxCount( vms, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount)))); } } }
protected T GetVMProperty <T>(IVM vm, int property_id) { int[] properties = { property_id }; Object result = null; ulong ret = ((IVixHandle)vm).GetProperties(properties, ref result); if (_api.ErrorIndicatesFailure(ret)) { return(default(T)); } //throw new VMXServiceException("Unable to get vm status."); if (result == null) { return(default(T)); } else { return((T)(((Object[])result)[0])); } }
/* * The cconection button - responsible for connecting properly, and showing the right windows. */ private void Button_Click(object sender, RoutedEventArgs e) { // connection MyTelnetClient telnetCli = new MyTelnetClient(); MyFlightSimulatorModel model = new MyFlightSimulatorModel(telnetCli); this.vm = new ConnectionViewModel(model); // bind the error light to the vm this.errorLight.DataContext = new DashboardVM(model); // get the ip and port from the textbox string ip = this.IPTextbox.Text; string port = this.PortTextbox.Text; try { // converting the port from string to int int intPort = int.Parse(port); // connecting to the server int isSucceed = this.vm.model.connect(ip, intPort); if (isSucceed == 1) { this.vm.model.start(); this.vm.model.startQueue(); AppWindow app = new AppWindow(model, this, this.vm); app.Show(); this.Hide(); } } catch { this.vm.model.ConnectionError = "Blue"; } }
public PublisherEditor(IVM vm) { InitializeComponent(); DataContext = vm; }
public BackCommand(IVM currentVM) { this.currentVM = currentVM; }
public TvmModel(PoolModel parentPool, IVM vm) { this.VM = vm; this.ParentPool = parentPool; this.LastUpdatedTime = DateTime.UtcNow; }
public AuthorEditor(IVM vm) { InitializeComponent(); DataContext = vm; }
public GenreEditor(IVM vm) { InitializeComponent(); DataContext = vm; }
/// <summary> /// Dispose the object. /// </summary> public void Dispose() { _sharedFolders = null; _vm = null; }
/// <summary> /// A collection of shared folders that belong to a virtual machine. /// </summary> /// <param name="vm">Virtual machine.</param> public VMWareSharedFolderCollection(IVM vm) { _vm = vm; }
public BookList(IVM vm) { InitializeComponent(); DataContext = vm; }