private void AddNetworkButton_Click(object sender, EventArgs e) { if (XenObject is VM) { VM vm = (VM)_xenObject; if (NetworksGridView.Rows.Count >= vm.MaxVIFsAllowed()) { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, FriendlyErrorNames.VIFS_MAX_ALLOWED, FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE))) { dlg.ShowDialog(Program.MainWindow); } return; } Host master = Helpers.GetMaster(vm.Connection); if (master == null) { // Cache populating? return; } VIF pVif; using (var d = new VIFDialog(vm.Connection, null, VIF.GetDeviceId(vm), vm.HasSriovRecommendation())) { if (d.ShowDialog(this) != DialogResult.OK) { return; } pVif = d.GetNewSettings(); } pVif.VM = new XenRef <VM>(vm.opaque_ref); var action = new CreateVIFAction(vm, pVif); action.Completed += createVIFAction_Completed; action.RunAsync(); } else if (XenObject is Host) { Host host = (Host)_xenObject; Program.MainWindow.ShowPerConnectionWizard(_xenObject.Connection, new NewNetworkWizard(_xenObject.Connection, null, host)); } else if (XenObject is Pool) { Pool pool = (Pool)_xenObject; Host host = pool.Connection.Resolve(pool.master); if (host != null) { Program.MainWindow.ShowPerConnectionWizard(_xenObject.Connection, new NewNetworkWizard(_xenObject.Connection, pool, host)); } } }
protected override void ExecuteCore(SelectedItemCollection selection) { Trace.Assert(selection.Count == 1); var action = new CreateVIFAction(_vm, _vifDescriptor); action.Completed += action_Completed; action.RunAsync(); }