protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<IStorageLinkObject>()) { StorageLinkConnection con = ((IStorageLinkObject)selection.First).StorageLinkConnection; // check all selected SL items are on the same SL connection. if (con != null && con.ConnectionState == StorageLinkConnectionState.Connected && selection.AllItemsAre<IStorageLinkObject>(s => s.StorageLinkConnection.Equals(con))) { return true; } } return false; }
protected override void ExecuteCore(SelectedItemCollection selection) { if (selection != null && selection.AllItemsAre<IXenObject>(x => x is Host || x is Pool)) MainWindowCommandInterface.ShowForm(typeof(BugToolWizard), selection.AsXenObjects<IXenObject>().ToArray()); else MainWindowCommandInterface.ShowForm(typeof(BugToolWizard)); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<VM_appliance>()) return selection.AtLeastOneXenObjectCan<VM_appliance>(CanStartAppliance); if (selection.AllItemsAre<VM>()) { var firstVm = (VM)selection.First; if (firstVm.IsAssignedToVapp) { var firstVapp = firstVm.appliance; if (selection.AsXenObjects<VM>().All(vm => vm.appliance != null && vm.appliance.opaque_ref == firstVapp.opaque_ref)) return CanStartAppliance(firstVm.Connection.Resolve(firstVapp)); } } return false; }
protected override void ExecuteCore(SelectedItemCollection selection) { var appsToStart = new List<VM_appliance>(); if (selection.AllItemsAre<VM_appliance>()) { appsToStart = (from IXenObject obj in selection.AsXenObjects() let app = (VM_appliance)obj where CanStartAppliance(app) select app).ToList(); } else if (selection.AllItemsAre<VM>()) { var firstVm = (VM)selection.First; appsToStart.Add(firstVm.Connection.Resolve(firstVm.appliance)); } foreach (var app in appsToStart) (new StartApplianceAction(app, false)).RunAsync(); }
public void LaunchIfRequired(bool nag, ChangeableList <IXenConnection> connections, SelectedItemCollection selectedObjects) { if (selectedObjects != null && selectedObjects.AllItemsAre <IXenObject>(x => x is Pool || x is Host)) { List <IXenObject> itemsSelected = selectedObjects.AsXenObjects <Pool>().ConvertAll(p => p as IXenObject); itemsSelected.AddRange(selectedObjects.AsXenObjects <Host>().Where(h => Helpers.GetPool(h.Connection) == null).ToList().ConvertAll(h => h as IXenObject)); itemsSelected.AddRange(selectedObjects.AsXenObjects <Host>().Where(h => Helpers.GetPool(h.Connection) != null).ToList().ConvertAll(h => Helpers.GetPool(h.Connection)).ConvertAll(p => p as IXenObject).Distinct()); LaunchIfRequired(nag, connections, itemsSelected); } else { LaunchIfRequired(nag, connections); } }
protected override bool CanExecuteCore(SelectedItemCollection selection) { Host hostAncestor = selection.HostAncestorFromConnection; Pool poolAncestor = selection.PooAncestorFromConnection; if ((poolAncestor != null || hostAncestor != null) //CA-61207: this check ensures there's no cross-pool selection && (selection.FirstIs<Pool>() || selection.FirstIs<Host>() || selection.FirstIsRealVM || selection.FirstIs<VM_appliance>())) { if (selection.AllItemsAre<VM>()) return selection.AtLeastOneXenObjectCan<VM>(CanExportVm); if (selection.AllItemsAre<VM_appliance>()) { if (selection.Count != 1) return false; var appliance = ((VM_appliance)selection.FirstAsXenObject); return appliance.VMs.TrueForAll(vmRef => { var vm = appliance.Connection.Resolve(vmRef); return vm != null && CanExportVm(vm); }); } if ((hostAncestor != null && hostAncestor.enabled && hostAncestor.IsLive && selection[0].Connection.IsConnected) || (poolAncestor != null && Helpers.PoolHasEnabledHosts(poolAncestor))) { var vms = selection.FirstAsXenObject.Connection.Cache.VMs.Where(vm => vm.is_a_real_vm && CanExportVm(vm) && vm.Show(Properties.Settings.Default.ShowHiddenVMs)).ToList(); if (vms.Count > 0) return vms.Any(CanExportVm); } } return false; }
public void LaunchIfRequired(bool nag, SelectedItemCollection selectedObjects) { if (selectedObjects != null && selectedObjects.AllItemsAre <IXenObject>(x => x is Pool || x is Host)) { List <IXenObject> itemsSelected = selectedObjects.AsXenObjects <Pool>().ConvertAll(p => p as IXenObject); itemsSelected.AddRange(selectedObjects.AsXenObjects <Host>().Select (host => Helpers.GetPoolOfOne(((IXenObject)host).Connection)).Cast <IXenObject>().Distinct()); LaunchIfRequired(nag, itemsSelected); } else { LaunchIfRequired(nag, new List <IXenObject>()); } }
protected override void ExecuteCore(SelectedItemCollection selection) { var dockerContainers = new List<DockerContainer>(); if (selection.AllItemsAre<DockerContainer>()) { dockerContainers = (from IXenObject obj in selection.AsXenObjects() let container = (DockerContainer)obj where CanExecute(container) select container).ToList(); } foreach (var container in dockerContainers) (new StartDockerContainerAction(container)).RunAsync(); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<IStorageLinkObject>()) { var connections = new List<StorageLinkConnection>(); foreach (IStorageLinkObject s in selection.AsXenObjects<IStorageLinkObject>()) { if (s.StorageLinkConnection.ConnectionState != StorageLinkConnectionState.Connected) { return false; } } return true; } return false; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { // you can only remove a storagelink server from XC if there isn't an SR using it. List<StorageLinkConnection> slCons = new List<StorageLinkConnection>(); if (selection.AllItemsAre<IStorageLinkObject>()) { foreach (IStorageLinkObject s in selection.AsXenObjects()) { if (!slCons.Contains(s.StorageLinkConnection)) { slCons.Add(s.StorageLinkConnection); } } } return slCons.Count == 1; }
public override bool IsValid(SelectedItemCollection selection) { List<string> types = new List<string>(); if (selection.AllItemsAre<IXenObject>()) { foreach (SelectedItem item in selection) { string name = item.XenObject.GetType().Name; VM vm = item.XenObject as VM; if (vm != null && vm.is_a_template) { name = vm.is_a_snapshot ? "snapshot" : "template"; } if (!types.Contains(name)) { types.Add(name); } } } if (types.Count > 1) { // if types only contains a mix of vms and templates then don't use this Builder. MixedVMsAndTemplates should be used instead. types.Remove("VM"); types.Remove("template"); return types.Count > 0; } return false; }
public override bool IsValid(SelectedItemCollection selection) { return selection.AllItemsAre<GroupingTag>(IsValid) && selection.Count > 1; }
public override bool IsValid(SelectedItemCollection selection) { return selection.AllItemsAre<DockerContainer>(); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return selection.AllItemsAre<StorageLinkSystem>(); }
public override bool IsValid(SelectedItemCollection selection) { return selection.AllItemsAre<Folder>() && selection.Count > 1; }
public void LaunchIfRequired(bool nag, ChangeableList<IXenConnection> connections, SelectedItemCollection selectedObjects) { if (selectedObjects != null && selectedObjects.AllItemsAre<IXenObject>(x => x is Pool || x is Host)) { List<IXenObject> itemsSelected = selectedObjects.AsXenObjects<Pool>().ConvertAll(p => p as IXenObject); itemsSelected.AddRange(selectedObjects.AsXenObjects<Host>().Where(h => Helpers.GetPool(h.Connection) == null).ToList().ConvertAll(h => h as IXenObject)); itemsSelected.AddRange(selectedObjects.AsXenObjects<Host>().Where(h => Helpers.GetPool(h.Connection) != null).ToList().ConvertAll(h => Helpers.GetPool(h.Connection)).ConvertAll(p => p as IXenObject).Distinct()); if(itemsSelected.All(xo => Helpers.ClearwaterOrGreater(xo.Connection)) || itemsSelected.All(xo => !Helpers.ClearwaterOrGreater(xo.Connection))) { LaunchIfRequired(nag, connections, itemsSelected); } else LaunchIfRequired(nag, connections, itemsSelected.Where(xo => Helpers.ClearwaterOrGreater(xo.Connection))); } else LaunchIfRequired(nag, connections); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (!selection.AllItemsAre<Host>()) { return false; } foreach (SelectedItem item in selection) { if (CanExecute((Host)item.XenObject)) { return true; } } return false; }
public override bool IsValid(SelectedItemCollection selection) { return selection.AllItemsAre<StorageLinkRepository>(); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<Host>()) { // all hosts must be in same pool. Pool commonPool = null; foreach (Host host in selection.AsXenObjects<Host>()) { if (!CanExecute(host)) { return false; } Pool pool = Helpers.GetPool(host.Connection); if (commonPool != null && !pool.Equals(commonPool)) { return false; } commonPool = pool; } return true; } return false; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return selection.AllItemsAre<Host>() && selection.AtLeastOneXenObjectCan<Host>(CanExecute); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (!selection.AllItemsAre<Host>() || selection.Count > 1) { return false; } return CanExecute(selection.AsXenObjects<Host>().First()); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<DockerContainer>()) return selection.AtLeastOneXenObjectCan<DockerContainer>(CanExecute); return false; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return selection.AllItemsAre<Host>() && selection.Any(item => ((Host)item.XenObject).IsLive); }
public void LaunchIfRequired(bool nag, SelectedItemCollection selectedObjects) { if (selectedObjects != null && selectedObjects.AllItemsAre<IXenObject>(x => x is Pool || x is Host)) { List<IXenObject> itemsSelected = selectedObjects.AsXenObjects<Pool>().ConvertAll(p => p as IXenObject); itemsSelected.AddRange(selectedObjects.AsXenObjects<Host>().Select (host => Helpers.GetPoolOfOne(((IXenObject)host).Connection)).Cast<IXenObject>().Distinct()); LaunchIfRequired(nag, itemsSelected); } else LaunchIfRequired(nag, new List<IXenObject>()); }
public override bool IsValid(SelectedItemCollection selection) { return selection.Count > 1 && selection.AllItemsAre<SR>(); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return selection.AllItemsAre<VM>(v => v != null && v.is_a_snapshot); }
public override bool IsValid(SelectedItemCollection selection) { return selection.AllItemsAre<VM_appliance>(); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (!selection.AllItemsAre<VM>()) { return false; } IXenConnection connection = null; bool atLeaseOneCanExecute = false; foreach (SelectedItem item in selection) { VM vm = (VM)item.XenObject; // all VMs must be on the same connection if (connection != null && vm.Connection != connection) { return false; } if (CanExecute(item.XenObject as VM)) { atLeaseOneCanExecute = true; } } return atLeaseOneCanExecute; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { // Can execute criteria: A selection of VMs in the same pool, where at least one doesn't have PVS read caching enabled if (selection.Any() && selection.AllItemsAre<VM>() && selection.GetConnectionOfAllItems() != null) { var vms = selection.AsXenObjects<VM>(); if (vms.Any(vm => vm.PvsProxy != null)) { return true; } } return false; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { // Must have a selection, of all VMs if (selection.Any() && selection.AllItemsAre<VM>()) { // Must all be in the same pool, which must have at least one PVS site var connection = selection.GetConnectionOfAllItems(); if (connection == null || !connection.Cache.PVS_sites.Any()) { return false; } // At least one must not currently have a PVS Proxy var vms = selection.AsXenObjects<VM>(); if (vms.Any(vm => vm.PvsProxy == null)) { return true; } } return false; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return selection.AllItemsAre<Host>(CanExecute); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return selection.Count > 0 && selection.AllItemsAre<VM>() && selection.GetConnectionOfAllItems() != null && selection.Any(CanExecute); }