本文整理汇总了C#中XenAPI.VDI类的典型用法代码示例。如果您正苦于以下问题:C# VDI类的具体用法?C# VDI怎么用?C# VDI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VDI类属于XenAPI命名空间,在下文中一共展示了VDI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MigrateVirtualDiskAction
public MigrateVirtualDiskAction(IXenConnection connection, VDI vdi, SR sr)
: base(connection, string.Format(Messages.ACTION_MOVING_VDI_TITLE, Helpers.GetName(vdi), Helpers.GetName(sr)))
{
Description = Messages.ACTION_PREPARING;
this.vdi = vdi;
SR = sr;
}
示例2: DestroyDiskAction
public DestroyDiskAction(VDI disk)
: base(disk.Connection, string.Format(Messages.ACTION_DISK_DELETING_TITLE, disk.Name, disk.Connection.Resolve<SR>(disk.SR).NameWithoutHost), false)
{
Disk = disk;
Disk.Locked = true;
#region RBAC Dependencies
ApiMethodsToRoleCheck.Add("vbd.unplug");
ApiMethodsToRoleCheck.Add("vbd.destroy");
ApiMethodsToRoleCheck.Add("vdi.destroy");
#endregion
SR = Connection.Resolve(Disk.SR);
// If there is only one VM involved here we can filter it under the VM
// Otherwise just filter under the SR
VM relevantVM = null;
foreach (VBD vbd in SR.Connection.ResolveAll(Disk.VBDs))
{
VM vm = SR.Connection.Resolve<VM>(vbd.VM);
if (vm == null)
continue;
if (relevantVM == null)
relevantVM = vm;
else
{
// more than one relevant VM, just give it the SR as an owner
relevantVM = null;
break;
}
}
if (relevantVM != null)
VM = relevantVM;
}
示例3: VdiOpenDatabaseAction
public VdiOpenDatabaseAction(IXenConnection connection, VDI vdi)
: base(connection, String.Format(Messages.ACTION_VDI_OPEN_DATABASE_TITLE, connection.Resolve(vdi.SR).Name))
{
_vdi = vdi;
#region RBAC Dependencies
ApiMethodsToRoleCheck.Add("VDI.open_database");
ApiMethodsToRoleCheck.Add("Session.get_record");
#endregion
}
示例4: MoveVirtualDiskDialog
public MoveVirtualDiskDialog(VDI vdi) : this(vdi.Connection)
{
this.vdi = vdi;
srPicker1.SetUsageAsMovingVDI(new[] {vdi});
srPicker1.SrHint.Visible = false;
srPicker1.Connection = vdi.Connection;
srPicker1.DiskSize = vdi.virtual_size;
srPicker1.srListBox.Invalidate();
srPicker1.selectDefaultSROrAny();
SetupEventHandlers();
}
示例5: CreateAction
protected override AsyncAction CreateAction(out bool cancelled)
{
cancelled = false;
VBD cddrive = VM.FindVMCDROM();
if (cddrive != null)
{
LoadedCD = VM.Connection.Resolve(cddrive.VDI);
}
return new ChangeVMISOAction(VM.Connection, VM, null, cddrive);
}
示例6: ChangeVMISOAction
/// <summary>
///
/// </summary>
/// <param name="connection"></param>
/// <param name="vm"></param>
/// <param name="vdi">May be null, indicating that the CD should be ejected (i.e. set to empty).</param>
/// <param name="cdrom">Must not be null.</param>
public ChangeVMISOAction(IXenConnection connection, VM vm,
VDI vdi, VBD cdrom)
: base(connection, vdi == null ? String.Format(Messages.ISO_UNLOADING, vm.Name) :
String.Format(Messages.ISO_LOADING, vdi.Name, vm.Name))
{
this.VM = vm;
this.vdi = vdi;
this.cdrom = cdrom;
System.Diagnostics.Trace.Assert(this.cdrom != null, "ChangeVMISOAction ctor: cdrom vbd must not be null");
System.Diagnostics.Trace.Assert(this.VM != null, "ChangeVMISOAction ctor: VM must not be null");
}
示例7: MoveVirtualDiskAction
public MoveVirtualDiskAction(IXenConnection connection, XenAPI.VDI vdi, SR sr)
: base(connection, string.Format(Messages.ACTION_MOVING_VDI_TITLE, Helpers.GetName(vdi), Helpers.GetName(sr)))
{
this.vdi = vdi;
SR = sr;
vdi.Locked = true;
sr.Locked = true;
ApiMethodsToRoleCheck.Add("vdi.destroy");
ApiMethodsToRoleCheck.Add("vdi.copy");
if (vdi.type == vdi_type.suspend)
ApiMethodsToRoleCheck.Add("vm.set_suspend_VDI");
ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList);
ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);
}
示例8: VBDRow
/// <summary>
/// Arguments should never be null
/// </summary>
public VBDRow(VBD vbd, VDI vdi, SR sr)
{
Debug.Assert(vbd != null && vdi != null && sr != null, "vbd, vdi and sr must be set to a non-null value");
VBD = vbd;
VDI = vdi;
SR = sr;
for (int i = 0; i < 10; i++)
{
DataGridViewTextBoxCell c = new DataGridViewTextBoxCell();
c.Value = CellValue(i);
Cells.Add(c);
}
}
示例9: DetachVirtualDiskAction
/// <summary>
/// Detaches a virtual disk
/// </summary>
/// <param name="disk">The VDI to detach</param>
/// <param name="vm">The VM to detach it from</param>
/// <param name="takeVDILock">Whether it is necessary to lock the VDI (we may be part of another disk action)</param>
public DetachVirtualDiskAction(VDI disk, VM vm, bool takeVDILock)
: base(disk.Connection, string.Format(Messages.ACTION_DISK_DETACHING_TITLE, disk.Name, vm.Name, false))
{
this.takeVDILock = takeVDILock;
vdi = disk;
if (takeVDILock)
vdi.Locked = true;
VM = vm;
VM.Locked = true;
foreach (VBD v in Connection.ResolveAll<VBD>(VM.VBDs))
{
if (v.VDI.opaque_ref == vdi.opaque_ref)
{
vbd = v;
vbd.Locked = true;
}
}
}
示例10: InstallSuppPack
private void InstallSuppPack(Host host, VDI vdi)
{
// Set the correct connection object, for RecomputeCanCancel
Connection = host.Connection;
Session session = host.Connection.DuplicateSession();
try
{
Description = String.Format(Messages.APPLYING_PATCH, vdi.Name, host.Name);
Host.call_plugin(session, host.opaque_ref, "install-supp-pack", "install", new Dictionary<string, string> { { "vdi", vdi.uuid } });
Description = String.Format(Messages.PATCH_APPLIED, vdi.Name, host.Name);
}
catch (Failure failure)
{
log.ErrorFormat("Plugin call install-supp-pack.install({0}) on {1} failed with {2}", vdi.uuid, host.Name, failure.Message);
log.ErrorFormat("Supplemental pack installation error description: {0}", string.Join(";", failure.ErrorDescription));
throw new SupplementalPackInstallFailedException(string.Format(Messages.SUPP_PACK_INSTALL_FAILED, vdi.Name, host.Name), failure);
}
finally
{
Connection = null;
}
}
示例11: InstallSuppPack
private void InstallSuppPack(Host host, VDI vdi)
{
// Set the correct connection object, for RecomputeCanCancel
Connection = host.Connection;
Session session = host.Connection.DuplicateSession();
try
{
Description = String.Format(Messages.APPLYING_PATCH, vdi.Name, host.Name);
Host.call_plugin(session, host.opaque_ref, "install-supp-pack", "install", new Dictionary<string, string> { { "vdi", vdi.uuid } });
Description = String.Format(Messages.PATCH_APPLIED, vdi.Name, host.Name);
}
catch (Failure failure)
{
log.WarnFormat("Plugin call install-supp-pack.install({0}) on {1} failed with {2}", vdi.uuid, host.Name,
failure.Message);
throw;
}
finally
{
Connection = null;
}
}
示例12: DiskGridRowItem
public DiskGridRowItem(IXenConnection connection, XmlNode diskNode, string vmName, Host affinity)
{
Disk = new VDI();
Device = new VBD();
Connection = connection;
Disk.virtual_size = long.Parse(diskNode.Attributes["size"].Value);
SR sruuid = connection.Cache.Find_By_Uuid<SR>(diskNode.Attributes["sr"].Value);
SR sr = GetBeskDiskStorage(Connection, Disk.virtual_size, affinity, sruuid == null ? null : sruuid);
Disk.SR = new XenRef<SR>(sr != null ? sr.opaque_ref : Helper.NullOpaqueRef);
Disk.type = (vdi_type)Enum.Parse(typeof(vdi_type), diskNode.Attributes["type"].Value);
Device.userdevice = diskNode.Attributes["device"].Value;
Device.bootable = diskNode.Attributes["bootable"].Value == "true";
Disk.name_label = string.Format(Messages.NEWVMWIZARD_STORAGEPAGE_VDINAME, vmName, Device.userdevice); //Device.userdevice;
Disk.read_only = false;
Disk.name_description = Messages.NEWVMWIZARD_STORAGEPAGE_DISK_DESCRIPTION;
Device.mode = vbd_mode.RW;
CanDelete = Disk.type == vdi_type.user;
CanResize = true;
MinSize = Disk.virtual_size;
AddCells();
}
示例13: UploadRawVDI
private XenRef<VDI> UploadRawVDI(Session xenSession, string sruuid, string label, Stream filestream, long capacity, string description)
{
log.Debug("OVF.Import.UploadRawVDI Enter");
log.DebugFormat("OVF.Import.UpdoadRadVDI SRUUID: {0}", sruuid);
log.DebugFormat("OVF.Import.UpdoadRadVDI Label: {0}", label);
log.DebugFormat("OVF.Import.UpdoadRadVDI Capacity: {0}", capacity);
#region CREATE A VDI
Hashtable vdiHash = new Hashtable();
vdiHash.Add("uuid", Guid.NewGuid().ToString());
vdiHash.Add("name_label", label);
vdiHash.Add("name_description", description);
if (sruuid.ToLower().StartsWith("opaque"))
{
vdiHash.Add("SR", sruuid);
}
else
{
vdiHash.Add("SR", SR.get_by_uuid(xenSession, sruuid).opaque_ref);
}
vdiHash.Add("virtual_size", Convert.ToString(capacity + (2 * MB))); // Add 2MB, VDIs appear to round down making it too small.
vdiHash.Add("physical_utilisation", Convert.ToString(capacity + (2 * MB)));
vdiHash.Add("type", "user");
vdiHash.Add("shareable", false);
vdiHash.Add("read_only", false);
vdiHash.Add("storage_lock", false);
vdiHash.Add("managed", true);
vdiHash.Add("is_a_snapshot", false);
VDI vdi = new VDI(vdiHash);
XenRef<VDI> vdiRef = null;
try
{
vdiRef = VDI.create(xenSession, vdi);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CANNOT_CREATE_VDI, ex.Message);
throw new Exception(Messages.ERROR_CANNOT_CREATE_VDI, ex);
}
log.Debug("Import.UploadRawVDI::VDI Created");
#endregion
#region UPLOAD HTTP STREAM
XenRef<Task> taskRef = Task.create(xenSession, "UpdateStream", "UpdateStream");
string p2VUri = string.Format("/import_raw_vdi?session_id={0}&task_id={1}&vdi={2}", xenSession.uuid, taskRef.opaque_ref, vdiRef.opaque_ref);
NameValueCollection headers = new NameValueCollection();
headers.Add("Content-Length", Convert.ToString(capacity));
headers.Add("Content-Type", "application/octet-stream");
headers.Add("Expect", "100-continue");
headers.Add("Accept", "*/*");
headers.Add("Connection", "close");
headers.Add("User-Agent", "XenP2VClient/1.5");
try
{
http.Put(filestream, _XenServer, p2VUri, headers, 0, capacity, false);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_HTTP_UPLOAD_FAILED, ex.Message);
if (vdiRef != null)
RemoveVDI(xenSession, vdiRef);
vdiRef = null;
throw new Exception(Messages.ERROR_HTTP_UPLOAD_FAILED, ex);
}
log.Debug("Import.UploadRawVDI::http.put complete");
#endregion
// give it time to catch up.
Thread.Sleep(new TimeSpan(0, 0, 5));
log.Debug("OVF.UploadRawVDI Leave");
return vdiRef;
}
示例14: CreateVDI
private XenRef<VDI> CreateVDI(Session xenSession, string sruuid, string label, long capacity, string description)
{
Hashtable vdiHash = new Hashtable();
vdiHash.Add("uuid", Guid.NewGuid().ToString());
vdiHash.Add("name_label", label);
vdiHash.Add("name_description", description);
if (sruuid.ToLower().StartsWith("opaque"))
{
vdiHash.Add("SR", sruuid);
}
else
{
vdiHash.Add("SR", SR.get_by_uuid(xenSession, sruuid).opaque_ref);
}
vdiHash.Add("virtual_size", Convert.ToString(capacity));
vdiHash.Add("physical_utilisation", Convert.ToString(capacity));
vdiHash.Add("type", "user");
vdiHash.Add("shareable", false);
vdiHash.Add("read_only", false);
vdiHash.Add("storage_lock", false);
vdiHash.Add("managed", true);
vdiHash.Add("is_a_snapshot", false);
VDI vdi = new VDI(vdiHash);
XenRef<VDI> vdiRef = null;
try
{
// Note that XenServer will round the capacity up to the nearest multiple of a 2 MB block.
vdiRef = VDI.create(xenSession, vdi);
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CANNOT_CREATE_VDI, ex.Message);
throw new Exception(Messages.ERROR_CANNOT_CREATE_VDI, ex);
}
log.Debug("Import.CeateVDI::VDI Created");
return vdiRef;
}
示例15: VDIRow
public VDIRow(VDI vdi, bool showStorageLink)
{
this.showStorageLink = showStorageLink;
VDI = vdi;
for (int i = 0; i < 5; i++)
{
Cells.Add(new DataGridViewTextBoxCell());
Cells[i].Value = GetCellText(i);
}
}