mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-24 22:06:59 +01:00
CP-36392: Refactor useless null checks in actions constructors
Also remove useless `this` usage Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
parent
0623717627
commit
df53a4cd98
@ -50,8 +50,6 @@ namespace XenAdmin.Dialogs
|
||||
public ControlDomainMemoryDialog(Host host)
|
||||
: base(host.Connection)
|
||||
{
|
||||
if (host == null) throw new ArgumentNullException("host");
|
||||
|
||||
InitializeComponent();
|
||||
this.host = host;
|
||||
this.host.PropertyChanged += Server_PropertyChanged;
|
||||
|
@ -44,10 +44,8 @@ namespace XenAdmin.Actions
|
||||
public EnableHostAction(Host host, bool resumeVMs,Func<Pool, Host, long, long, bool> acceptNTolChangesOnEnable)
|
||||
: base(host.Connection, Messages.HOST_ENABLE, Messages.WAITING, null, acceptNTolChangesOnEnable)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
_resumeVMs = resumeVMs;
|
||||
this.Host = host;
|
||||
Host = host;
|
||||
AddCommonAPIMethodsToRoleCheck();
|
||||
ApiMethodsToRoleCheck.Add("pool.ha_compute_hypothetical_max_host_failures_to_tolerate");
|
||||
ApiMethodsToRoleCheck.Add("pool.set_ha_host_failures_to_tolerate");
|
||||
|
@ -60,8 +60,6 @@ namespace XenAdmin.Actions
|
||||
public EvacuateHostAction(Host host, Host newCoordinator, Dictionary<XenRef<VM>, String[]> hostRecommendations, Func<HostAbstractAction, Pool, long, long, bool> acceptNTolChanges, Func<Pool, Host, long, long, bool> acceptNTolChangesOnEnable)
|
||||
: base(host.Connection, null, Messages.HOST_EVACUATE, acceptNTolChanges, acceptNTolChangesOnEnable)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
Host = host;
|
||||
_newCoordinator = newCoordinator;
|
||||
_hostRecommendations = hostRecommendations;
|
||||
|
@ -50,9 +50,7 @@ namespace XenAdmin.Actions
|
||||
public RebootHostAction(Host host, Func<HostAbstractAction, Pool, long, long, bool> acceptNTolChanges)
|
||||
: base(host.Connection, Messages.HOST_REBOOTING, Messages.WAITING, acceptNTolChanges, null)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
this.Host = host;
|
||||
Host = host;
|
||||
AddCommonAPIMethodsToRoleCheck();
|
||||
ApiMethodsToRoleCheck.Add("pool.ha_compute_hypothetical_max_host_failures_to_tolerate");
|
||||
ApiMethodsToRoleCheck.Add("pool.set_ha_host_failures_to_tolerate");
|
||||
|
@ -44,8 +44,6 @@ namespace XenAdmin.Actions
|
||||
public ShutdownHostAction(Host host, Func<HostAbstractAction, Pool, long, long, bool> acceptNTolChanges)
|
||||
: base(host.Connection, Messages.HOST_SHUTDOWN, Messages.WAITING, acceptNTolChanges, null)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
Host = host;
|
||||
ApiMethodsToRoleCheck.Add("pool.ha_compute_hypothetical_max_host_failures_to_tolerate");
|
||||
ApiMethodsToRoleCheck.Add("pool.set_ha_host_failures_to_tolerate");
|
||||
|
@ -49,12 +49,10 @@ namespace XenAdmin.Actions
|
||||
public EnableHAAction(Pool pool, Dictionary<VM, VMStartupOptions> startupOptions, List<SR> heartbeatSRs, long failuresToTolerate)
|
||||
: base(pool.Connection, string.Format(Messages.ENABLING_HA_ON, Helpers.GetName(pool).Ellipsise(50)), Messages.ENABLING_HA, false)
|
||||
{
|
||||
if (pool == null)
|
||||
throw new ArgumentNullException("pool");
|
||||
if (heartbeatSRs.Count == 0)
|
||||
throw new ArgumentException("You must specify at least 1 heartbeat SR");
|
||||
|
||||
this.Pool = pool;
|
||||
Pool = pool;
|
||||
this.startupOptions = startupOptions;
|
||||
this.heartbeatSRs = heartbeatSRs.ToArray();
|
||||
this.failuresToTolerate = failuresToTolerate;
|
||||
|
@ -57,8 +57,6 @@ namespace XenAdmin.Actions
|
||||
public CheckDiskSpaceForPatchUploadAction(Host host, string fileName, long size, bool suppressHistory)
|
||||
: base(host.Connection, Messages.ACTION_CHECK_DISK_SPACE_TITLE, "", suppressHistory)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
Host = host;
|
||||
this.fileName = fileName;
|
||||
fileSize = size;
|
||||
|
@ -45,8 +45,6 @@ namespace XenAdmin.Actions
|
||||
public CleanupDiskSpaceAction(Host host, Pool_patch excludedPatch, bool suppressHistory)
|
||||
: base(host.Connection, Messages.ACTION_CLEANUP_DISK_SPACE_TITLE, "", suppressHistory)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
Host = host;
|
||||
this.excludedPatch = excludedPatch;
|
||||
}
|
||||
|
@ -81,8 +81,6 @@ namespace XenAdmin.Actions
|
||||
public GetDiskSpaceRequirementsAction(Host host, string updateName, long size, bool suppressHistory)
|
||||
: base(host.Connection, Messages.ACTION_GET_DISK_SPACE_REQUIREMENTS_TITLE, suppressHistory)
|
||||
{
|
||||
if (host == null)
|
||||
throw new ArgumentNullException("host");
|
||||
Host = host;
|
||||
this.updateName = updateName;
|
||||
updateSize = size;
|
||||
|
@ -43,8 +43,6 @@ namespace XenAdmin.Actions
|
||||
: base(pool.Connection, string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATE, patch.Name(), pool.Name()), suppressHistory)
|
||||
{
|
||||
this.patch = patch;
|
||||
if (patch == null)
|
||||
throw new ArgumentNullException("patch");
|
||||
|
||||
#region RBAC Dependencies
|
||||
ApiMethodsToRoleCheck.Add("pool_patch.pool_clean");
|
||||
|
@ -55,10 +55,8 @@ namespace XenAdmin.Actions
|
||||
public SrRepairAction(IXenConnection connection, SR sr,bool isSharedAction)
|
||||
: base(connection, isSharedAction ? string.Format(Messages.ACTION_SR_SHARING, sr.NameWithoutHost()) : string.Format(Messages.ACTION_SR_REPAIRING, sr.NameWithoutHost()))
|
||||
{
|
||||
if (sr == null)
|
||||
throw new ArgumentNullException("sr");
|
||||
this.isSharedAction = isSharedAction;
|
||||
this.SR = sr;
|
||||
SR = sr;
|
||||
|
||||
#region RBAC Dependencies
|
||||
ApiMethodsToRoleCheck.Add("pbd.plug");
|
||||
|
Loading…
Reference in New Issue
Block a user