Do not set API object properties that have a default value of "OpaqueRef:NULL" to null.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2017-09-14 12:48:05 +01:00
parent 915059d099
commit 673846924b
3 changed files with 25 additions and 21 deletions

View File

@ -152,12 +152,15 @@ namespace XenAdmin.Dialogs
{
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
};
if (PvsSite != null)
pvsCacheStorage.site = new XenRef<PVS_site>(PvsSite);
if (row.CacheSr != null)
pvsCacheStorage.SR = new XenRef<SR>(row.CacheSr);
newPvsCacheStorages.Add(pvsCacheStorage);
}

View File

@ -76,15 +76,16 @@ namespace XenAdmin.Actions
throw new Exception(Messages.CDDRIVE_MAX_ALLOWED_VBDS);
}
XenAPI.VBD cdDrive = new XenAPI.VBD();
cdDrive.VM = new XenAPI.XenRef<XenAPI.VM>(VM.opaque_ref);
cdDrive.VDI = null;
cdDrive.bootable = false;
cdDrive.device = "";
cdDrive.userdevice = allowedDevices.Contains("3") ? "3" : allowedDevices[0];
cdDrive.empty = true;
cdDrive.type = XenAPI.vbd_type.CD;
cdDrive.mode = XenAPI.vbd_mode.RO;
XenAPI.VBD cdDrive = new XenAPI.VBD
{
VM = new XenAPI.XenRef<XenAPI.VM>(VM.opaque_ref),
bootable = false,
device = "",
userdevice = allowedDevices.Contains("3") ? "3" : allowedDevices[0],
empty = true,
type = XenAPI.vbd_type.CD,
mode = XenAPI.vbd_mode.RO
};
VbdSaveAndPlugAction cdCreate = new VbdSaveAndPlugAction(VM, cdDrive, Messages.DVD_DRIVE, Session, InstallingTools, true,_showMustRebootBoxCD,_showVBDWarningBox);
cdCreate.RunExternal(Session);

View File

@ -441,16 +441,16 @@ namespace XenAdmin.Actions.VMActions
List<string> devices = AllowedVBDs;
if (devices.Count == 0)
throw new Exception(Messages.NO_MORE_USERDEVICES);
VBD vbd = new VBD();
vbd.bootable = InsMethod == InstallMethod.CD;
vbd.empty = true;
vbd.unpluggable = true;
vbd.mode = vbd_mode.RO;
vbd.type = vbd_type.CD;
vbd.userdevice = devices.Contains("3") ? "3" : devices[0];
vbd.device = "";
vbd.VM = new XenRef<VM>(VM.opaque_ref);
vbd.VDI = null;
VBD vbd = new VBD
{
bootable = InsMethod == InstallMethod.CD,
empty = true,
unpluggable = true,
mode = vbd_mode.RO,
type = vbd_type.CD,
userdevice = devices.Contains("3") ? "3" : devices[0],
VM = new XenRef<VM>(VM.opaque_ref)
};
RelatedTask = VBD.async_create(Session, vbd);
PollToCompletion(60, 65);