Renamed VM method is_a_real_vm to IsRealVm.

The new name complies with C# conventions and allows distinguishing it from xapi field names.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2022-09-01 10:56:25 +01:00
parent 00c3a87dad
commit d94c55533c
26 changed files with 62 additions and 62 deletions

View File

@ -776,7 +776,7 @@ namespace XenAdmin.Actions
if (Cancelling) if (Cancelling)
throw new CancelledException(); throw new CancelledException();
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
{ {
PercentComplete = Convert.ToInt32((++itemIndex) * baseIndex / itemCount); PercentComplete = Convert.ToInt32((++itemIndex) * baseIndex / itemCount);
continue; continue;

View File

@ -86,7 +86,7 @@ namespace XenAdmin.Commands
{ {
VM vm = vbd.Connection.Resolve<VM>(vbd.VM); VM vm = vbd.Connection.Resolve<VM>(vbd.VM);
VDI vdi = vbd.Connection.Resolve<VDI>(vbd.VDI); VDI vdi = vbd.Connection.Resolve<VDI>(vbd.VDI);
if (vm == null || !vm.is_a_real_vm() || vdi == null) if (vm == null || !vm.IsRealVm() || vdi == null)
return false; return false;
if (vm.power_state != vm_power_state.Running) if (vm.power_state != vm_power_state.Running)
return false; return false;
@ -114,7 +114,7 @@ namespace XenAdmin.Commands
if (vm.is_a_template) if (vm.is_a_template)
return Messages.CANNOT_ACTIVATE_TEMPLATE_DISK; return Messages.CANNOT_ACTIVATE_TEMPLATE_DISK;
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
return base.GetCantRunReasonCore(item); return base.GetCantRunReasonCore(item);
SR sr = vdi.Connection.Resolve<SR>(vdi.SR); SR sr = vdi.Connection.Resolve<SR>(vdi.SR);

View File

@ -276,7 +276,7 @@ namespace XenAdmin.Commands
public bool CanRun(VM vm) public bool CanRun(VM vm)
{ {
return vm != null && vm.is_a_real_vm() && !vm.Locked && VMGroup<T>.FeaturePossible(vm.Connection) && return vm != null && vm.IsRealVm() && !vm.Locked && VMGroup<T>.FeaturePossible(vm.Connection) &&
!Helpers.FeatureForbidden(vm.Connection, VMGroup<T>.FeatureRestricted); !Helpers.FeatureForbidden(vm.Connection, VMGroup<T>.FeatureRestricted);
} }
protected override bool CanRunCore(SelectedItemCollection selection) protected override bool CanRunCore(SelectedItemCollection selection)

View File

@ -87,7 +87,7 @@ namespace XenAdmin.Commands
{ {
VDI vdi = vbd.Connection.Resolve<VDI>(vbd.VDI); VDI vdi = vbd.Connection.Resolve<VDI>(vbd.VDI);
VM vm = vbd.Connection.Resolve<VM>(vbd.VM); VM vm = vbd.Connection.Resolve<VM>(vbd.VM);
if (vm == null || !vm.is_a_real_vm() || vdi == null || vdi.Locked || vbd.Locked) if (vm == null || !vm.IsRealVm() || vdi == null || vdi.Locked || vbd.Locked)
return false; return false;
if (vm.power_state != vm_power_state.Running) if (vm.power_state != vm_power_state.Running)
return false; return false;
@ -115,7 +115,7 @@ namespace XenAdmin.Commands
if (vm.is_a_template) if (vm.is_a_template)
return Messages.CANNOT_ACTIVATE_TEMPLATE_DISK; return Messages.CANNOT_ACTIVATE_TEMPLATE_DISK;
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
return base.GetCantRunReasonCore(item); return base.GetCantRunReasonCore(item);
SR sr = vdi.Connection.Resolve<SR>(vdi.SR); SR sr = vdi.Connection.Resolve<SR>(vdi.SR);

View File

@ -77,7 +77,7 @@ namespace XenAdmin.Commands
if ((hostAncestor != null && hostAncestor.enabled && hostAncestor.IsLive() && selection[0].Connection.IsConnected) if ((hostAncestor != null && hostAncestor.enabled && hostAncestor.IsLive() && selection[0].Connection.IsConnected)
|| (poolAncestor != null && Helpers.PoolHasEnabledHosts(poolAncestor))) || (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(); var vms = selection.FirstAsXenObject.Connection.Cache.VMs.Where(vm => vm.IsRealVm() && CanExportVm(vm) && vm.Show(Properties.Settings.Default.ShowHiddenVMs)).ToList();
if (vms.Count > 0) if (vms.Count > 0)
return vms.Any(CanExportVm); return vms.Any(CanExportVm);
} }
@ -95,7 +95,7 @@ namespace XenAdmin.Commands
if (item != null && item.Connection != null) if (item != null && item.Connection != null)
{ {
var vms = item.Connection.Cache.VMs.Where(xvm => var vms = item.Connection.Cache.VMs.Where(xvm =>
xvm.is_a_real_vm() && CanExportVm(xvm) && xvm.IsRealVm() && CanExportVm(xvm) &&
xvm.Show(Properties.Settings.Default.ShowHiddenVMs)).ToList(); xvm.Show(Properties.Settings.Default.ShowHiddenVMs)).ToList();
if (vms.Count == 0) if (vms.Count == 0)

View File

@ -93,7 +93,7 @@ namespace XenAdmin.Diagnostics.Checks
VMsWithProblems.Add(residentVM.opaque_ref); VMsWithProblems.Add(residentVM.opaque_ref);
} }
if (restrictMigration && residentVM.is_a_real_vm() && !VMsWithProblems.Contains(residentVM.opaque_ref)) if (restrictMigration && residentVM.IsRealVm() && !VMsWithProblems.Contains(residentVM.opaque_ref))
{ {
problems.Add(new CannotMigrateVM(this, residentVM, CannotMigrateVM.CannotMigrateVMReason.LicenseRestriction)); problems.Add(new CannotMigrateVM(this, residentVM, CannotMigrateVM.CannotMigrateVMReason.LicenseRestriction));
VMsWithProblems.Add(residentVM.opaque_ref); VMsWithProblems.Add(residentVM.opaque_ref);

View File

@ -57,7 +57,7 @@ namespace XenAdmin.Diagnostics.Checks
} }
//vCPU configuration check //vCPU configuration check
foreach (var vm in Host.Connection.Cache.VMs.Where(vm => vm.is_a_real_vm())) foreach (var vm in Host.Connection.Cache.VMs.Where(vm => vm.IsRealVm()))
{ {
if (!vm.HasValidVCPUConfiguration()) if (!vm.HasValidVCPUConfiguration())
return new InvalidVCPUConfiguration(this, vm); return new InvalidVCPUConfiguration(this, vm);
@ -71,7 +71,7 @@ namespace XenAdmin.Diagnostics.Checks
if (pool == null) if (pool == null)
return false; return false;
if (!pool.Connection.Cache.VMs.Any(vm => vm.is_a_real_vm() && vm.power_state != vm_power_state.Halted)) if (!pool.Connection.Cache.VMs.Any(vm => vm.IsRealVm() && vm.power_state != vm_power_state.Halted))
return false; return false;
foreach (var host1 in pool.Connection.Cache.Hosts) foreach (var host1 in pool.Connection.Cache.Hosts)

View File

@ -48,7 +48,7 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem
public CPUIncompatibilityProblem(Check check, Pool pool) public CPUIncompatibilityProblem(Check check, Pool pool)
: base(check, pool) : base(check, pool)
{ {
foreach (var vm in pool.Connection.Cache.VMs.Where(vm => vm.is_a_real_vm() && vm.power_state != vm_power_state.Halted)) foreach (var vm in pool.Connection.Cache.VMs.Where(vm => vm.IsRealVm() && vm.power_state != vm_power_state.Halted))
{ {
vmsOnHosts.Add(vm, vm.resident_on); vmsOnHosts.Add(vm, vm.resident_on);
} }

View File

@ -133,7 +133,7 @@ namespace XenAdmin.Dialogs.ScheduledSnapshots
private void RefreshRow() private void RefreshRow()
{ {
PolicyName = Policy.Name(); PolicyName = Policy.Name();
PolicyVmCount = Policy.VMs.FindAll(vm => Policy.Connection.Resolve(vm).is_a_real_vm()).Count; PolicyVmCount = Policy.VMs.FindAll(vm => Policy.Connection.Resolve(vm).IsRealVm()).Count;
PolicyStatus = Policy.enabled ? Messages.ENABLED : Messages.DISABLED; PolicyStatus = Policy.enabled ? Messages.ENABLED : Messages.DISABLED;
//the policy is in server's local time zone //the policy is in server's local time zone
@ -178,7 +178,7 @@ namespace XenAdmin.Dialogs.ScheduledSnapshots
foreach (var vm in pool.Connection.Cache.VMs) foreach (var vm in pool.Connection.Cache.VMs)
{ {
if (vm.is_a_real_vm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs)) if (vm.IsRealVm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs))
{ {
realVMs++; realVMs++;
if (vm.Connection.Resolve(vm.snapshot_schedule) != null) if (vm.Connection.Resolve(vm.snapshot_schedule) != null)

View File

@ -308,7 +308,7 @@ namespace XenAdmin.Dialogs
foreach (VIF vif in xenConnection.Cache.VIFs) foreach (VIF vif in xenConnection.Cache.VIFs)
{ {
var vm = xenConnection.Resolve(vif.VM); var vm = xenConnection.Resolve(vif.VM);
if (vif != ExistingVif && vif.MAC == SelectedMac && vm != null && vm.is_a_real_vm()) if (vif != ExistingVif && vif.MAC == SelectedMac && vm != null && vm.IsRealVm())
{ {
using (var dlg = new WarningDialog(string.Format(Messages.PROBLEM_MAC_ADDRESS_IS_DUPLICATE, SelectedMac, vm.NameWithLocation()), using (var dlg = new WarningDialog(string.Format(Messages.PROBLEM_MAC_ADDRESS_IS_DUPLICATE, SelectedMac, vm.NameWithLocation()),
ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonYes,

View File

@ -126,7 +126,7 @@ namespace XenAdmin.TabPages
private bool VMWanted(VM vm, Host host) private bool VMWanted(VM vm, Host host)
{ {
return vm.is_a_real_vm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs) && vm.Home() == host; return vm.IsRealVm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs) && vm.Home() == host;
} }
private readonly CollectionChangeEventHandler VM_CollectionChangedWithInvoke; private readonly CollectionChangeEventHandler VM_CollectionChangedWithInvoke;
@ -261,7 +261,7 @@ namespace XenAdmin.TabPages
{ {
// Only observe real VMs (but templates come through here too because // Only observe real VMs (but templates come through here too because
// they change into real VMs during VM creation). // they change into real VMs during VM creation).
if (!((VM)sender).is_a_real_vm()) if (!((VM)sender).IsRealVm())
return; return;
// These are used by MainWindow.VMHome() to determine which host the VM belongs to // These are used by MainWindow.VMHome() to determine which host the VM belongs to

View File

@ -101,7 +101,7 @@ namespace XenAdmin.TabPages
if (XenAdminConfigManager.Provider.ObjectIsHidden(vm.opaque_ref)) if (XenAdminConfigManager.Provider.ObjectIsHidden(vm.opaque_ref))
return false; return false;
return vm.is_a_real_vm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs) && !vm.IsBeingCreated; return vm.IsRealVm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs) && !vm.IsBeingCreated;
} }
private static bool VmIsJustAdded(VM vm) private static bool VmIsJustAdded(VM vm)
@ -138,7 +138,7 @@ namespace XenAdmin.TabPages
foreach (var vm in Connection.Cache.VMs) foreach (var vm in Connection.Cache.VMs)
{ {
// Add all real VMs and templates that begin with __gui__ (because this may be a new VM) // Add all real VMs and templates that begin with __gui__ (because this may be a new VM)
var addVm = vm.is_a_real_vm() || VmIsJustAdded(vm) || vm.IsBeingCreated; var addVm = vm.IsRealVm() || VmIsJustAdded(vm) || vm.IsBeingCreated;
if (!addVm) if (!addVm)
continue; continue;

View File

@ -184,7 +184,7 @@ namespace XenAdmin.Wizards.ExportWizard
private bool IsVmExportable(VM vm) private bool IsVmExportable(VM vm)
{ {
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
return false; return false;
if (!vm.Show(Properties.Settings.Default.ShowHiddenVMs)) if (!vm.Show(Properties.Settings.Default.ShowHiddenVMs))

View File

@ -115,7 +115,7 @@ namespace XenAdmin.Wizards.GenericPages
dataGridView1.Rows.Clear(); dataGridView1.Rows.Clear();
foreach (var vm in Pool.Connection.Cache.VMs) foreach (var vm in Pool.Connection.Cache.VMs)
{ {
if (searchTextBox1.Matches(vm.Name()) && vm.is_a_real_vm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs)) if (searchTextBox1.Matches(vm.Name()) && vm.IsRealVm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs))
dataGridView1.Rows.Add(new VMDataGridViewRow(SelectedVMs.Contains(vm), vm)); dataGridView1.Rows.Add(new VMDataGridViewRow(SelectedVMs.Contains(vm), vm));
} }
@ -227,7 +227,7 @@ namespace XenAdmin.Wizards.GenericPages
foreach (var vm in Pool.Connection.Cache.VMs) foreach (var vm in Pool.Connection.Cache.VMs)
{ {
int index = 0; int index = 0;
if (vm.is_a_real_vm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs)) if (vm.IsRealVm() && vm.Show(Properties.Settings.Default.ShowHiddenVMs))
{ {
bool selected = group != null && VMGroup<T>.GroupToVMs(group).Contains(new XenRef<VM>(vm.opaque_ref)); bool selected = group != null && VMGroup<T>.GroupToVMs(group).Contains(new XenRef<VM>(vm.opaque_ref));
index = dataGridView1.Rows.Add(new VMDataGridViewRow(selected, vm)); index = dataGridView1.Rows.Add(new VMDataGridViewRow(selected, vm));

View File

@ -393,7 +393,7 @@ namespace XenAdmin.Wizards.PatchingWizard
foreach (var vmRef in server.resident_VMs) foreach (var vmRef in server.resident_VMs)
{ {
var vm = server.Connection.Resolve(vmRef); var vm = server.Connection.Resolve(vmRef);
if (vm != null && vm.is_a_real_vm() && predicate.Invoke(vm)) if (vm != null && vm.IsRealVm() && predicate.Invoke(vm))
sb.AppendIndented(vm.Name()).AppendLine(); sb.AppendIndented(vm.Name()).AppendLine();
} }
} }

View File

@ -120,7 +120,7 @@ namespace XenAdmin.Actions.DR
foreach (var vmRef in vms.Keys) foreach (var vmRef in vms.Keys)
{ {
VM vm = vms[vmRef]; VM vm = vms[vmRef];
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
continue; continue;
vm.opaque_ref = vmRef.opaque_ref; vm.opaque_ref = vmRef.opaque_ref;
_poolMetadata.Vms.Add(vmRef, vm); _poolMetadata.Vms.Add(vmRef, vm);

View File

@ -62,7 +62,7 @@ namespace XenAdmin.Actions.HostActions
foreach(VM vm in Connection.ResolveAll(Host.resident_VMs)) foreach(VM vm in Connection.ResolveAll(Host.resident_VMs))
{ {
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
continue; continue;
if (VmsRefsNotMigratable.Contains(vm.opaque_ref)) if (VmsRefsNotMigratable.Contains(vm.opaque_ref))

View File

@ -254,7 +254,7 @@ namespace XenAdmin.Model
public static ComparableList<DockerContainer> GetDockerVMs(IXenObject o) public static ComparableList<DockerContainer> GetDockerVMs(IXenObject o)
{ {
var vm = o as VM; var vm = o as VM;
if (vm != null && vm.is_a_real_vm()) if (vm != null && vm.IsRealVm())
{ {
return new ComparableList<DockerContainer>(DockerContainers.GetContainersFromOtherConfig(vm)); return new ComparableList<DockerContainer>(DockerContainers.GetContainersFromOtherConfig(vm));
} }

View File

@ -292,7 +292,7 @@ namespace XenAdmin.Core
{ {
foreach (VM vm in connection.Cache.VMs) foreach (VM vm in connection.Cache.VMs)
{ {
if (vm.is_a_real_vm() && vm.power_state == XenAPI.vm_power_state.Running) if (vm.IsRealVm() && vm.power_state == XenAPI.vm_power_state.Running)
return true; return true;
} }
return false; return false;

View File

@ -883,7 +883,7 @@ namespace XenAPI
{ {
var vms = from XenRef<VM> vmref in resident_VMs var vms = from XenRef<VM> vmref in resident_VMs
let vm = Connection.Resolve(vmref) let vm = Connection.Resolve(vmref)
where vm != null && vm.is_a_real_vm() && !vm.IsHVM() where vm != null && vm.IsRealVm() && !vm.IsHVM()
select vmref; select vmref;
return vms.ToList(); return vms.ToList();
@ -893,7 +893,7 @@ namespace XenAPI
{ {
var vms = from XenRef<VM> vmref in resident_VMs var vms = from XenRef<VM> vmref in resident_VMs
let vm = Connection.Resolve(vmref) let vm = Connection.Resolve(vmref)
where vm != null && vm.is_a_real_vm() && vm.IsHVM() where vm != null && vm.IsRealVm() && vm.IsHVM()
select vmref; select vmref;
return vms.ToList(); return vms.ToList();
@ -904,7 +904,7 @@ namespace XenAPI
{ {
var vms = from XenRef<VM> vmref in resident_VMs var vms = from XenRef<VM> vmref in resident_VMs
let vm = Connection.Resolve(vmref) let vm = Connection.Resolve(vmref)
where vm != null && vm.is_a_real_vm() where vm != null && vm.IsRealVm()
select vmref; select vmref;
return vms.ToList(); return vms.ToList();

View File

@ -275,7 +275,7 @@ namespace XenAPI
public bool IsPvVm() public bool IsPvVm()
{ {
return is_a_real_vm() && !IsHVM() && !other_config.ContainsKey("pvcheckpass"); return IsRealVm() && !IsHVM() && !other_config.ContainsKey("pvcheckpass");
} }
public bool IsUEFIEnabled() public bool IsUEFIEnabled()
@ -1104,7 +1104,7 @@ namespace XenAPI
{ {
if (this.Connection != null) if (this.Connection != null)
{ {
if (this.is_a_real_vm()) if (this.IsRealVm())
{ {
return base.NameWithLocation(); return base.NameWithLocation();
} }
@ -1221,7 +1221,7 @@ namespace XenAPI
/// </summary> /// </summary>
public bool HaCanProtect(bool showHiddenVMs) public bool HaCanProtect(bool showHiddenVMs)
{ {
return is_a_real_vm() && Show(showHiddenVMs); return IsRealVm() && Show(showHiddenVMs);
} }
@ -1331,7 +1331,7 @@ namespace XenAPI
return false; return false;
} }
public bool is_a_real_vm() public bool IsRealVm()
{ {
return !is_a_snapshot && !is_a_template && !is_control_domain; return !is_a_snapshot && !is_a_template && !is_control_domain;
} }
@ -1373,7 +1373,7 @@ namespace XenAPI
public bool IsConversionVM() public bool IsConversionVM()
{ {
return is_a_real_vm() && BoolKey(other_config, "conversionvm"); return IsRealVm() && BoolKey(other_config, "conversionvm");
} }
public override string ToString() public override string ToString()

View File

@ -63,7 +63,7 @@ namespace XenAPI
foreach (var otherVm in vmsNotInCurApp) foreach (var otherVm in vmsNotInCurApp)
{ {
if (otherVm.is_a_real_vm() && otherVm.power_state != vm_power_state.Halted && otherVm.SRs().Intersect(thisVm.SRs()).FirstOrDefault() != null && !fateSharingVms.Contains(otherVm)) if (otherVm.IsRealVm() && otherVm.power_state != vm_power_state.Halted && otherVm.SRs().Intersect(thisVm.SRs()).FirstOrDefault() != null && !fateSharingVms.Contains(otherVm))
fateSharingVms.Add(otherVm); fateSharingVms.Add(otherVm);
} }
} }

View File

@ -302,12 +302,12 @@ namespace XenAdmin.XenSearch
property_types.Add(PropertyNames.in_any_appliance, typeof(bool)); property_types.Add(PropertyNames.in_any_appliance, typeof(bool));
property_types.Add(PropertyNames.disks, typeof(VDI)); property_types.Add(PropertyNames.disks, typeof(VDI));
properties[PropertyNames.os_name] = o => o is VM vm && vm.is_a_real_vm() ? vm.GetOSName() : null; properties[PropertyNames.os_name] = o => o is VM vm && vm.IsRealVm() ? vm.GetOSName() : null;
properties[PropertyNames.power_state] = o => o is VM vm && vm.is_a_real_vm() ? (IComparable)vm.power_state : null; properties[PropertyNames.power_state] = o => o is VM vm && vm.IsRealVm() ? (IComparable)vm.power_state : null;
properties[PropertyNames.vendor_device_state] = o => o is VM vm && vm.is_a_real_vm() ? (bool?)vm.WindowsUpdateCapable() : null; properties[PropertyNames.vendor_device_state] = o => o is VM vm && vm.IsRealVm() ? (bool?)vm.WindowsUpdateCapable() : null;
properties[PropertyNames.virtualisation_status] = o => o is VM vm && vm.is_a_real_vm() ? (IComparable)vm.GetVirtualisationStatus(out _) : null; properties[PropertyNames.virtualisation_status] = o => o is VM vm && vm.IsRealVm() ? (IComparable)vm.GetVirtualisationStatus(out _) : null;
properties[PropertyNames.start_time] = o => o is VM vm && vm.is_a_real_vm() ? (DateTime?)vm.GetStartTime() : null; properties[PropertyNames.start_time] = o => o is VM vm && vm.IsRealVm() ? (DateTime?)vm.GetStartTime() : null;
properties[PropertyNames.read_caching_enabled] = o => o is VM vm && vm.is_a_real_vm() ? (bool?)vm.ReadCachingEnabled() : null; properties[PropertyNames.read_caching_enabled] = o => o is VM vm && vm.IsRealVm() ? (bool?)vm.ReadCachingEnabled() : null;
properties[PropertyNames.label] = Helpers.GetName; properties[PropertyNames.label] = Helpers.GetName;
properties[PropertyNames.pool] = o => o == null ? null : Helpers.GetPool(o.Connection); properties[PropertyNames.pool] = o => o == null ? null : Helpers.GetPool(o.Connection);
@ -329,7 +329,7 @@ namespace XenAdmin.XenSearch
properties[PropertyNames.memory] = o => properties[PropertyNames.memory] = o =>
{ {
if (o is VM vm && vm.is_a_real_vm() && vm.Connection != null) if (o is VM vm && vm.IsRealVm() && vm.Connection != null)
{ {
var metrics = vm.Connection.Resolve(vm.metrics); var metrics = vm.Connection.Resolve(vm.metrics);
if (metrics != null) if (metrics != null)
@ -340,7 +340,7 @@ namespace XenAdmin.XenSearch
properties[PropertyNames.ha_restart_priority] = delegate(IXenObject o) properties[PropertyNames.ha_restart_priority] = delegate(IXenObject o)
{ {
if (o is VM vm && vm.is_a_real_vm()) if (o is VM vm && vm.IsRealVm())
{ {
Pool pool = Helpers.GetPool(vm.Connection); Pool pool = Helpers.GetPool(vm.Connection);
if (pool != null && pool.ha_enabled) if (pool != null && pool.ha_enabled)
@ -359,7 +359,7 @@ namespace XenAdmin.XenSearch
if (o is VM_appliance app) if (o is VM_appliance app)
return app; return app;
if (o is VM vm && vm.is_a_real_vm() && vm.Connection != null) if (o is VM vm && vm.IsRealVm() && vm.Connection != null)
return vm.Connection.Resolve(vm.appliance); return vm.Connection.Resolve(vm.appliance);
return null; return null;
@ -369,7 +369,7 @@ namespace XenAdmin.XenSearch
{ {
if (o is VM_appliance) if (o is VM_appliance)
return true; return true;
if (o is VM vm && vm.is_a_real_vm() && vm.Connection != null) if (o is VM vm && vm.IsRealVm() && vm.Connection != null)
return vm.Connection.Resolve(vm.appliance) != null; return vm.Connection.Resolve(vm.appliance) != null;
return null; return null;
}; };
@ -422,7 +422,7 @@ namespace XenAdmin.XenSearch
private static IComparable UptimeProperty(IXenObject o) private static IComparable UptimeProperty(IXenObject o)
{ {
if (o is VM vm) if (o is VM vm)
return vm.is_a_real_vm() ? vm.RunningTime() : null; return vm.IsRealVm() ? vm.RunningTime() : null;
if (o is Host host) if (o is Host host)
return host.Uptime(); return host.Uptime();
@ -433,7 +433,7 @@ namespace XenAdmin.XenSearch
private static IComparable CPUTextProperty(IXenObject o) private static IComparable CPUTextProperty(IXenObject o)
{ {
if (o is VM vm) if (o is VM vm)
return vm.is_a_real_vm() && vm.power_state == vm_power_state.Running return vm.IsRealVm() && vm.power_state == vm_power_state.Running
? PropertyAccessorHelper.vmCpuUsageString(vm) ? PropertyAccessorHelper.vmCpuUsageString(vm)
: null; : null;
@ -448,7 +448,7 @@ namespace XenAdmin.XenSearch
private static IComparable CPUValueProperty(IXenObject o) private static IComparable CPUValueProperty(IXenObject o)
{ {
if (o is VM vm) if (o is VM vm)
return vm.is_a_real_vm() && vm.power_state == vm_power_state.Running return vm.IsRealVm() && vm.power_state == vm_power_state.Running
? (IComparable)PropertyAccessorHelper.vmCpuUsageRank(vm) ? (IComparable)PropertyAccessorHelper.vmCpuUsageRank(vm)
: null; : null;
@ -464,7 +464,7 @@ namespace XenAdmin.XenSearch
{ {
if (o is VM vm) if (o is VM vm)
{ {
return vm.is_a_real_vm() && return vm.IsRealVm() &&
vm.power_state == vm_power_state.Running && vm.power_state == vm_power_state.Running &&
vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED) vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)
? PropertyAccessorHelper.vmMemoryUsageString(vm) ? PropertyAccessorHelper.vmMemoryUsageString(vm)
@ -486,7 +486,7 @@ namespace XenAdmin.XenSearch
{ {
if (o is VM vm) if (o is VM vm)
{ {
return vm.is_a_real_vm() && return vm.IsRealVm() &&
vm.power_state == vm_power_state.Running && vm.power_state == vm_power_state.Running &&
vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED) vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)
? (IComparable)PropertyAccessorHelper.vmMemoryUsageRank(vm) ? (IComparable)PropertyAccessorHelper.vmMemoryUsageRank(vm)
@ -508,7 +508,7 @@ namespace XenAdmin.XenSearch
{ {
if (o is VM vm) if (o is VM vm)
{ {
return vm.is_a_real_vm() && return vm.IsRealVm() &&
vm.power_state == vm_power_state.Running && vm.power_state == vm_power_state.Running &&
vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED) vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)
? (IComparable)PropertyAccessorHelper.vmMemoryUsageValue(vm) ? (IComparable)PropertyAccessorHelper.vmMemoryUsageValue(vm)
@ -530,7 +530,7 @@ namespace XenAdmin.XenSearch
{ {
if (o is VM vm) if (o is VM vm)
{ {
return vm.is_a_real_vm() && return vm.IsRealVm() &&
vm.power_state == vm_power_state.Running && vm.power_state == vm_power_state.Running &&
vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)
? PropertyAccessorHelper.vmNetworkUsageString(vm) ? PropertyAccessorHelper.vmNetworkUsageString(vm)
@ -548,7 +548,7 @@ namespace XenAdmin.XenSearch
private static IComparable DiskTextProperty(IXenObject o) private static IComparable DiskTextProperty(IXenObject o)
{ {
return o is VM vm && return o is VM vm &&
vm.is_a_real_vm() && vm.IsRealVm() &&
vm.power_state == vm_power_state.Running && vm.power_state == vm_power_state.Running &&
vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)
? PropertyAccessorHelper.vmDiskUsageString(vm) ? PropertyAccessorHelper.vmDiskUsageString(vm)
@ -670,7 +670,7 @@ namespace XenAdmin.XenSearch
if (o is VM vm) if (o is VM vm)
{ {
if (vm.is_a_real_vm() && vm.Connection != null) if (vm.IsRealVm() && vm.Connection != null)
foreach (VIF vif in vm.Connection.ResolveAll(vm.VIFs)) foreach (VIF vif in vm.Connection.ResolveAll(vm.VIFs))
{ {
XenAPI.Network network = vm.Connection.Resolve(vif.network); XenAPI.Network network = vm.Connection.Resolve(vif.network);
@ -752,7 +752,7 @@ namespace XenAdmin.XenSearch
vms.Add(container.Parent); vms.Add(container.Parent);
} }
vms.RemoveAll(vm => !vm.is_a_real_vm()); vms.RemoveAll(vm => !vm.IsRealVm());
return vms; return vms;
} }
@ -815,7 +815,7 @@ namespace XenAdmin.XenSearch
if (o is VM vm) if (o is VM vm)
{ {
if (vm.is_a_real_vm()) if (vm.IsRealVm())
foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs)) foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs))
{ {
VDI vdi = vbd.Connection.Resolve(vbd.VDI); VDI vdi = vbd.Connection.Resolve(vbd.VDI);
@ -855,7 +855,7 @@ namespace XenAdmin.XenSearch
} }
else if (o is VM vm) else if (o is VM vm)
{ {
if (vm.is_a_real_vm()) if (vm.IsRealVm())
foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs)) foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs))
{ {
VDI vdi = vbd.Connection.Resolve(vbd.VDI); VDI vdi = vbd.Connection.Resolve(vbd.VDI);
@ -875,7 +875,7 @@ namespace XenAdmin.XenSearch
if (o is VM vm) if (o is VM vm)
{ {
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
return addresses; return addresses;
VM_guest_metrics metrics = vm.Connection.Resolve(vm.guest_metrics); VM_guest_metrics metrics = vm.Connection.Resolve(vm.guest_metrics);

View File

@ -265,7 +265,7 @@ namespace XenAdmin.XenSearch
if (o is Host) if (o is Host)
return "30"; return "30";
VM vm = o as VM; VM vm = o as VM;
if (vm != null && vm.is_a_real_vm()) if (vm != null && vm.IsRealVm())
return "40"; return "40";
return o.GetType().ToString(); return o.GetType().ToString();
} }

View File

@ -357,7 +357,7 @@ namespace XenAdmin.XenSearch
// Special case: if the type is VM, and the object is not a real VM, // Special case: if the type is VM, and the object is not a real VM,
// it's not a group. This is because snapshots are XMO<VM>s internally, // it's not a group. This is because snapshots are XMO<VM>s internally,
// but we want to group them by the real VM they came from. // but we want to group them by the real VM they came from.
if (o is VM vm && !vm.is_a_real_vm()) if (o is VM vm && !vm.IsRealVm())
return false; return false;
// Otherwise this is a group // Otherwise this is a group

View File

@ -315,7 +315,7 @@ namespace XenAdmin.XenSearch
public static string GetVMHAStatus(VM vm) public static string GetVMHAStatus(VM vm)
{ {
if (!vm.is_a_real_vm()) if (!vm.IsRealVm())
return "-"; return "-";
return Helpers.RestartPriorityI18n(vm.HARestartPriority()); return Helpers.RestartPriorityI18n(vm.HARestartPriority());
} }