public DeletePvsSiteAction(PVS_site pvsSite) : base(pvsSite.Connection, string.Format(Messages.ACTION_DELETE_PVS_SITE_TITLE, pvsSite.Name.Ellipsise(50)), Messages.ACTION_DELETE_PVS_SITE_DESCRIPTION, false) { System.Diagnostics.Trace.Assert(pvsSite != null); this.pvsSite = pvsSite; }
protected override void Run() { // check if there are any running proxies var pvsProxies = Connection.Cache.PVS_proxies.Where(s => s.site.opaque_ref == pvsSite.opaque_ref).ToList(); if (pvsProxies.Count > 0) { throw new Failure(Failure.PVS_SITE_CONTAINS_RUNNING_PROXIES); } // delete PVS_servers var pvsServers = Connection.Cache.PVS_servers.Where(s => s.site.opaque_ref == pvsSite.opaque_ref).ToList(); int inc = pvsServers.Count > 0 ? 50 / pvsServers.Count : 50; foreach (var pvsServer in pvsServers) { RelatedTask = PVS_server.async_forget(Session, pvsServer.opaque_ref); PollToCompletion(PercentComplete, PercentComplete + inc); } RelatedTask = PVS_site.async_forget(Session, pvsSite.opaque_ref); PollToCompletion(); Description = Messages.ACTION_DELETE_PVS_SITE_DONE; PercentComplete = 100; }
public PvsCacheStorageRow(Host host, PVS_site site) { InitializeComponent(); Host = host; PvsSite = site; OrigPvsCacheStorage = site != null ? site.PvsCacheStorage(host) : null; Populate(); }
public ConfigurePvsSiteAction(IXenConnection connection, string siteName, PVS_site pvsSite, List <PVS_cache_storage> pvsCacheStorages) : base(connection, string.Format(Messages.ACTION_CONFUGURE_PVS_SITE_TITLE, siteName.Ellipsise(50)), Messages.ACTION_CONFUGURE_PVS_SITE_DESCRIPTION, false) { this.pvsSite = pvsSite; this.pvsCacheStorages = pvsCacheStorages; this.siteName = siteName; SetRBACPermissions(); }
private void UpdateRow(DataGridViewRow row, VM vm, PVS_proxy pvsProxy) { PVS_site pvsSite = pvsProxy == null ? null : Connection.Resolve(pvsProxy.site); row.Cells[0].Value = vm.Name; row.Cells[1].Value = pvsProxy == null ? Messages.NO : Messages.YES; row.Cells[2].Value = pvsProxy == null || pvsSite == null ? Messages.NO_VALUE : pvsSite.Name; row.Cells[3].Value = pvsProxy == null ? Messages.NO_VALUE : pvs_proxy_status_extensions.ToFriendlyString(pvsProxy.status); }
public PvsCacheStorageRow(Host host, PVS_site site) { InitializeComponent(); Host = host; PvsSite = site; OrigPvsCacheStorage = site != null?site.PvsCacheStorage(host) : null; Populate(); }
public PvsProxyCreateAction(VM vm, PVS_site site, VIF vif) : base(vm.Connection, string.Format(Messages.ACTION_ENABLE_PVS_READ_CACHING_FOR, vm, site)) { this.site = site; this.vif = vif; this.VM = vm; this.Description = Messages.WAITING; SetRBACPermissions(); }
private PvsCacheConfigurationPage NewPage(PVS_site pvsSite) { var existingTabNames = (from PvsCacheConfigurationPage page in verticalTabs.Items select page.Text).ToList(); PvsCacheConfigurationPage editPage = new PvsCacheConfigurationPage(connection, existingTabNames); var pvsSiteCopy = pvsSite != null?pvsSite.Clone() : null; editPage.SetXenObjects(pvsSite, pvsSiteCopy); editPage.Changed += SomethingChangedOnPage; editPage.DeleteButtonClicked += DeleteButtonClickedOnPage; ShowTab(editPage); RefreshButtons(); return(editPage); }
private void PvsSiteCollectionChanged(object sender, CollectionChangeEventArgs e) { if (e.Action == CollectionChangeAction.Add) { PVS_site addedSite = e.Element as PVS_site; Program.Invoke(this, () => { ResizeVerticalTabs(verticalTabs.Items.Count + 1); NewPage(addedSite); }); } }
/// <summary> /// If the VM can have PVS read-caching enabled, returns an action to do so. Else returns null /// </summary> /// <param name="vm"></param> /// <param name="siteSelected"></param> /// <returns></returns> private AsyncAction GetAsyncActionForVm(VM vm, PVS_site siteSelected) { if (vm.PvsProxy != null) { return(null); // PVS read caching already enabled } var vif = GetVifForPvsProxy(vm); if (vif == null) { return(null); // No VIF with device = 0, so can't enable } return(new PvsProxyCreateAction(vm, siteSelected, vif)); }
/// <summary> /// Creates a dialog for viewing the PVS servers on a particular site. /// </summary> /// <param name="site">May not be null.</param> public PvsSiteDialog(PVS_site site) { System.Diagnostics.Trace.Assert(site != null); connection = site.Connection; pvsSite = site; InitializeComponent(); Text = string.Format(Messages.PVS_SITE_DIALOG_TITLE, pvsSite.Name.Ellipsise(50)); System.Diagnostics.Trace.Assert(gridView.Columns.Count > 0); gridView.Columns[0].DefaultCellStyle.NullValue = null; RegisterEventHandlers(); Rebuild(); }
private void RegisterVmEventHandlers(VM vm, PVS_proxy pvsProxy) { vm.PropertyChanged -= VmPropertyChanged; vm.PropertyChanged += VmPropertyChanged; if (pvsProxy != null) { pvsProxy.PropertyChanged -= PvsProxyPropertyChanged; pvsProxy.PropertyChanged += PvsProxyPropertyChanged; PVS_site pvsSite = pvsProxy == null ? null : Connection.Resolve(pvsProxy.site); if (pvsSite != null) { pvsSite.PropertyChanged -= PvsSitePropertyChanged; pvsSite.PropertyChanged += PvsSitePropertyChanged; } } }
private bool DeleteSite(PVS_site site, string siteName) { // We cannot delete the site if there are running proxies if (site != null) { var pvsProxies = connection.Cache.PVS_proxies.Where(s => s.site.opaque_ref == site.opaque_ref).ToList(); if (pvsProxies.Count > 0) { using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.PVS_SITE_CANNOT_BE_REMOVED, Messages.XENCENTER))) { dlg.ShowDialog(Parent); } return(false); } } // show confirmation dialog var message = site != null && !string.IsNullOrEmpty(site.PVS_uuid) ? string.Format(Messages.CONFIRM_DELETE_PVS_SITE_IN_USE, siteName) : string.Format(Messages.CONFIRM_DELETE_PVS_SITE, siteName); DialogResult dialogResult; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.XENCENTER), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(Parent); } if (dialogResult != DialogResult.OK) { return(false); } // if it is a newly added site, then there's noting we need to do here (it does not exist on the server yet) if (site == null) { return(true); } // delete existing site var action = new DeletePvsSiteAction(site); new ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog(this); return(action.Succeeded); }
public void SetXenObjects(IXenObject orig, IXenObject clone) { PvsSite = (PVS_site)clone; if (PvsSite != null) { textBox1.Text = PvsSite.Name; pvsConfigInfoIcon.Visible = pvsConfigInfoLabel.Visible = string.IsNullOrEmpty(PvsSite.PVS_uuid); } else { // Generate list of all taken PVS_site names List <string> takenNames = new List <PVS_site>(connection.Cache.PVS_sites).ConvertAll(s => s.Name); takenNames.AddRange(knownSiteNames); // Generate a unique suggested name for the new site textBox1.Text = Helpers.MakeUniqueName(Messages.PVS_SITE_NAME, takenNames); } LoadServers(); viewPvsServersButton.Enabled = PvsSite != null && PvsSite.servers.Count > 0; }
protected override void Run() { if (pvsSite == null) { // create site RelatedTask = PVS_site.async_introduce(Session, siteName, string.Empty, string.Empty); PollToCompletion(0, 10); pvsSite = Connection.WaitForCache(new XenRef <PVS_site>(Result)); } else { // get the site again from cache, just in case it changed (or dissapeared) in the meantime pvsSite = Connection.Cache.Resolve(new XenRef <PVS_site>(pvsSite.opaque_ref)); if (pvsSite == null) { log.InfoFormat("PVS Site '{0}' cannot be configured, because it cannot be found.", siteName); PercentComplete = 100; Description = Messages.COMPLETED; return; } if (pvsSite.name_label != siteName) { // set name_label PVS_site.set_name_label(Session, pvsSite.opaque_ref, siteName); } } PercentComplete = 10; int inc = pvsCacheStorages.Count > 0 ? 90 / pvsCacheStorages.Count / 3 : 90; foreach (var pvsCacheStorage in pvsCacheStorages) { // create Memory SR, if needed if (pvsCacheStorage.SR != null && Helper.IsNullOrEmptyOpaqueRef(pvsCacheStorage.SR.opaque_ref)) { RelatedTask = SR.async_create(Session, pvsCacheStorage.host, new Dictionary <string, string> { { URI, "" } }, 0, Messages.PVS_CACHE_MEMORY_SR_NAME, "", SR.SRTypes.tmpfs.ToString(), "", false, new Dictionary <string, string>()); PollToCompletion(PercentComplete, PercentComplete + inc); pvsCacheStorage.SR = new XenRef <SR>(Result); } else { PercentComplete += inc; } // destroy existing PVS_cache_storage var existingConfiguration = pvsSite.PvsCacheStorage(Connection.Resolve(pvsCacheStorage.host)); if (existingConfiguration != null) { RelatedTask = PVS_cache_storage.async_destroy(Session, existingConfiguration.opaque_ref); PollToCompletion(PercentComplete, PercentComplete + inc); } else { PercentComplete += inc; } // create new PVS_cache_storage if (pvsCacheStorage.SR != null) { pvsCacheStorage.site = new XenRef <PVS_site>(pvsSite); //asign the new site RelatedTask = PVS_cache_storage.async_create(Session, pvsCacheStorage); PollToCompletion(PercentComplete, PercentComplete + inc); } else { PercentComplete += inc; } } PercentComplete = 100; Description = Messages.ACTION_CONFUGURE_PVS_SITE_DONE; }
/// <summary> /// If the VM can have PVS read-caching enabled, returns an action to do so. Else returns null /// </summary> /// <param name="vm"></param> /// <param name="siteSelected"></param> /// <returns></returns> private AsyncAction GetAsyncActionForVm(VM vm, PVS_site siteSelected) { if (vm.PvsProxy != null) return null; // PVS read caching already enabled var vif = GetVifForPvsProxy(vm); if (vif == null) return null; // No VIF with device = 0, so can't enable return new PvsProxyCreateAction(vm, siteSelected, vif); }
public PvsSiteComboBoxItem(PVS_site site) { Debug.Assert(site != null, "site passed to combobox was null"); _site = site; }
private PvsCacheConfigurationPage NewPage(PVS_site pvsSite) { var existingTabNames = (from PvsCacheConfigurationPage page in verticalTabs.Items select page.Text).ToList(); PvsCacheConfigurationPage editPage = new PvsCacheConfigurationPage(connection, existingTabNames); var pvsSiteCopy = pvsSite != null ? pvsSite.Clone() : null; editPage.SetXenObjects(pvsSite, pvsSiteCopy); editPage.Changed += SomethingChangedOnPage; editPage.DeleteButtonClicked += DeleteButtonClickedOnPage; ShowTab(editPage); RefreshButtons(); return editPage; }
public void SetXenObjects(IXenObject orig, IXenObject clone) { PvsSite = (PVS_site) clone; if (PvsSite != null) { textBox1.Text = PvsSite.Name; pvsConfigInfoIcon.Visible = pvsConfigInfoLabel.Visible = string.IsNullOrEmpty(PvsSite.PVS_uuid); } else { // Generate list of all taken PVS_site names List<string> takenNames = new List<PVS_site>(connection.Cache.PVS_sites).ConvertAll(s => s.Name); takenNames.AddRange(knownSiteNames); // Generate a unique suggested name for the new site textBox1.Text = Helpers.MakeUniqueName(Messages.PVS_SITE_NAME, takenNames); } LoadServers(); viewPvsServersButton.Enabled = PvsSite != null && PvsSite.servers.Count > 0; cacheStorageInUseInfoIcon.Visible = cacheStorageInUseInfoLabel.Visible = rows.Any(row => row.ReadOnly); memoryOnlyInfoIcon.Visible = memoryOnlyInfoLabel.Visible = rows.Any(row => !row.ReadOnly); }
private bool DeleteSite(PVS_site site, string siteName) { // We cannot delete the site if there are running proxies if (site != null) { var pvsProxies = connection.Cache.PVS_proxies.Where(s => s.site.opaque_ref == site.opaque_ref).ToList(); if (pvsProxies.Count > 0) { using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.PVS_SITE_CANNOT_BE_REMOVED, Messages.XENCENTER))) { dlg.ShowDialog(Parent); } return false; } } // show confirmation dialog var message = site != null && !string.IsNullOrEmpty(site.PVS_uuid) ? string.Format(Messages.CONFIRM_DELETE_PVS_SITE_IN_USE, siteName) : string.Format(Messages.CONFIRM_DELETE_PVS_SITE, siteName); DialogResult dialogResult; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.XENCENTER), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(Parent); } if (dialogResult != DialogResult.OK) return false; // if it is a newly added site, then there's noting we need to do here (it does not exist on the server yet) if (site == null) return true; // delete existing site var action = new DeletePvsSiteAction(site); new ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog(this); return action.Succeeded; }