public AsyncAction SaveSettings() { if (!ValidToSave) { return(null); } var newPvsCacheStorages = new List <PVS_cache_storage>(); foreach (var row in rows.Where(r => r.HasChanged)) { var pvsCacheStorage = new PVS_cache_storage { site = PvsSite != null ? new XenRef <PVS_site>(PvsSite) : null, host = new XenRef <Host>(row.Host), SR = row.CacheSr != null ? new XenRef <SR>(row.CacheSr) : null, size = row.CacheSize }; newPvsCacheStorages.Add(pvsCacheStorage); } if (newPvsCacheStorages.Count > 0 || NameHasChanged) { return(new ConfigurePvsSiteAction(connection, textBox1.Text, PvsSite, newPvsCacheStorages)); } return(null); }
public PvsCacheStorageRow(Host host, PVS_site site) { InitializeComponent(); Host = host; PvsSite = site; OrigPvsCacheStorage = site != null?site.PvsCacheStorage(host) : null; Populate(); }
public AsyncAction SaveSettings() { if (!ValidToSave) return null; var newPvsCacheStorages = new List<PVS_cache_storage>(); foreach (var row in rows.Where(r => r.HasChanged)) { var pvsCacheStorage = new PVS_cache_storage { site = PvsSite != null ? new XenRef<PVS_site>(PvsSite) : null, host = new XenRef<Host>(row.Host), SR = row.CacheSr != null ? new XenRef<SR>(row.CacheSr) : null, size = row.CacheSize }; newPvsCacheStorages.Add(pvsCacheStorage); } if (newPvsCacheStorages.Count > 0 || NameHasChanged) return new ConfigurePvsSiteAction(connection, textBox1.Text, PvsSite, newPvsCacheStorages); return null; }
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; }