public void AddDesktopOffering(DesktopOfferingElement offering) { DesktopOfferingElement existing = GetDesktopOffering(offering.Name); if (existing != null) { throw new ArgumentException("Duplicate desktop offering name"); } config.DesktopOfferingsBase.Add(offering); }
public DesktopOfferingModel(DesktopOfferingElement element) { CopyProperties(element, this); // This is a PVS desktop offering if any PVS attributes are set PvsDesktopOffering = ( Hypervisor != null || IsoId != null || DiskOfferingId != null || DeviceCollectionElement != null); }
public ActionResult EndEditDesktopOffering(DesktopOfferingModel item) { IDesktopOffering offering = ConfigStore.Configuration.DesktopOfferings.Where(o => o.Name == item.Name).FirstOrDefault(); if (offering == null) { DesktopOfferingElement element = new DesktopOfferingElement(); ConfigStore.AddDesktopOffering(item.Update(element)); } else { ConfigStore.ReplaceDesktopOffering(item.Update(offering as DesktopOfferingElement)); } ConfigStore.Save(); return RedirectToAction("ViewDesktopOfferings"); }
public static void TestAddDuplicateOffering(ConfigurationStore store) { IDesktopOffering existing = store.Configuration.DesktopOfferings.First(); Console.WriteLine("Add duplicate Desktop Offering {0}", existing.Name); DesktopOfferingElement offering = new DesktopOfferingElement() { Name = existing.Name, }; try { store.AddDesktopOffering(offering); Console.WriteLine("FAIL: added a duplicate desktop offering to the store"); } catch (ArgumentException e) { Console.WriteLine("PASS: Exception thrown: {0}", e.Message); } }
public void ReplaceDesktopOffering(DesktopOfferingElement offering) { DeleteDesktopOffering(offering.Name); AddDesktopOffering(offering); }
public DesktopOfferingElement Update(DesktopOfferingElement element) { CopyProperties(this, element); return element; }
private void SyncDesktopOfferings(DesktopOfferingElement offering) { CtxTrace.TraceVerbose("{0}, {1}", offering.Name, offering.HostnamePrefix); // Arguments to pass to PowerShell script. Dictionary<string, object> args = new Dictionary<string, object>(); args["ccpip"] = config.CloudStackUri.Host; args["hostnameprefix"] = offering.HostnamePrefix; if (!string.IsNullOrEmpty(offering.XenDesktopCatalog)) { args["catalogname"] = offering.XenDesktopCatalog; } if (!string.IsNullOrEmpty(offering.TemplateId)) { args["templateid"] = offering.TemplateId; } if (!string.IsNullOrEmpty(offering.IsoId)) { args["isoid"] = offering.IsoId; } if (IsValidDeviceCollection (offering.DeviceCollection)) { args["devicecollection"] = offering.DeviceCollection; } try { PsWrapper scriptWrapper = new PsWrapper(script.Path, script.Debug); scriptWrapper.IgnoreExceptions.Add("ADIdentityNotFoundException"); Collection<PSObject> results = scriptWrapper.RunPowerShell(args); foreach (PSObject result in results) { CtxTrace.TraceInformation(result); } } catch (Exception e) { CtxTrace.TraceError(e); } }
public static void TestReplaceOfferingNoMatch(ConfigurationStore store) { DesktopOfferingElement offering = new DesktopOfferingElement() { Name = "should not match", Description = "this has been modified" }; Console.WriteLine("Modify Desktop Offering {0}", offering.Name); try { store.ReplaceDesktopOffering(offering); Console.WriteLine("FAIL: replaced with a new name"); } catch (ArgumentException e) { Console.WriteLine("PASS: Exception thrown: {0}", e.Message); } }