本文整理汇总了C#中IXenConnection.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# IXenConnection.Resolve方法的具体用法?C# IXenConnection.Resolve怎么用?C# IXenConnection.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXenConnection
的用法示例。
在下文中一共展示了IXenConnection.Resolve方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportVmAction
public ImportVmAction(IXenConnection connection, Host affinity, string filename, SR sr)
: base(connection, string.Format(Messages.IMPORTVM_TITLE, filename, Helpers.GetName(connection)), Messages.IMPORTVM_PREP)
{
Pool = Helpers.GetPoolOfOne(connection);
m_affinity = affinity;
Host = affinity ?? connection.Resolve(Pool.master);
SR = sr;
VM = null;
m_filename = filename;
#region RBAC Dependencies
ApiMethodsToRoleCheck.AddRange(ConstantRBACRequirements);
if (affinity != null)
ApiMethodsToRoleCheck.Add("vm.set_affinity");
//??
//if (startAutomatically)
// ApiMethodsToRoleCheck.Add("vm.start");
ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList);
ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);
#endregion
}
示例2: 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
}
示例3: GetBeskDiskStorage
/// <summary>
/// returns null if nothing suitable
/// </summary>
private static SR GetBeskDiskStorage(IXenConnection connection, long diskSize, Host affinity, SR suggestion)
{
// try suggestion
if (suggestion != null && suggestion.FreeSpace > diskSize && suggestion.CanBeSeenFrom(affinity))
return suggestion;
// try default sr
SR def_sr = connection.Resolve(Helpers.GetPoolOfOne(connection).default_SR);
if (def_sr != null && def_sr.FreeSpace > diskSize && def_sr.CanBeSeenFrom(affinity))
return def_sr;
// pick an sr
foreach (SR sr in connection.Cache.SRs)
{
if (!sr.CanCreateVmOn())
continue;
if (sr.FreeSpace > diskSize && sr.CanBeSeenFrom(affinity))
return sr;
}
// there is nothing
return null;
}
示例4: DiskGridRowItem
public DiskGridRowItem(IXenConnection connection, VDI vdi, VBD vbd, bool isNew, Host affinity)
{
SourceDisk = vdi;
Disk = new VDI();
Device = new VBD();
Connection = connection;
Disk.virtual_size = vdi.virtual_size;
SR sr = GetBeskDiskStorage(Connection, Disk.virtual_size, affinity, Connection.Resolve(vdi.SR));
Disk.SR = new XenRef<SR>(sr != null ? sr.opaque_ref : Helper.NullOpaqueRef);
Disk.type = vdi.type;
Device.userdevice = vbd.userdevice;
Device.bootable = vbd.bootable;
Disk.name_label = vdi.name_label;
Disk.read_only = vdi.read_only;
Disk.name_description = vdi.name_description;
Device.mode = vbd.mode;
CanDelete = Disk.type == vdi_type.user && isNew;
CanResize = isNew;
MinSize = 0;
AddCells();
}
示例5: PopulateInterfaces
private void PopulateInterfaces(Pool pool, Host host, IXenConnection connection)
{
Dictionary<XenAPI.Network, bool> networksAdded = new Dictionary<XenAPI.Network, bool>();
comboInterfaces.Items.Clear();
foreach (PIF pif in connection.Cache.PIFs)
{
// If the current selection is for a host, rather than a pool, only show
// management interfaces with PIFs on that host.
if (pool == null && host != null && pif.host.opaque_ref != host.opaque_ref)
continue;
if (pif.IsManagementInterface(XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
{
XenAPI.Network network = connection.Resolve(pif.network);
if (network != null && // this should have been checked already by pif.IsManagementInterface, but...
!networksAdded.ContainsKey(network))
{
comboInterfaces.Items.Add(network);
networksAdded[network] = true;
}
}
}
comboInterfaces.SelectedIndexChanged += new EventHandler(comboInterfaces_SelectedIndexChanged);
if (comboInterfaces.Items.Count > 0)
comboInterfaces.SelectedIndex = 0;
}
示例6: GetProblem
private Problem GetProblem(IXenConnection connection, XenRef<VM> vmRef, string[] exception)
{
try
{
System.Diagnostics.Trace.Assert(exception.Length > 0);
VM vm;
switch (exception[0])
{
case Failure.VM_REQUIRES_SR:
vm = connection.Resolve<VM>(vmRef);
if (vm == null)
throw new NullReferenceException(Failure.VM_REQUIRES_SR);
XenRef<SR> srRef = new XenRef<SR>(exception[2]);
SR sr = connection.Resolve<SR>(srRef);
if (sr == null)
throw new NullReferenceException(Failure.VM_REQUIRES_SR);
if (sr.content_type == SR.Content_Type_ISO)
{
return new LocalCD(this, vm);
}
else if (!sr.shared)
{
// Only show the problem if it is really local storage
// As the pbd-plug checks will pick up broken storage.
return new LocalStorage(this, vm);
}
return null;
case Failure.VM_MISSING_PV_DRIVERS:
vm = connection.Resolve<VM>(vmRef);
if (vm == null)
throw new NullReferenceException(Failure.VM_MISSING_PV_DRIVERS);
return new NoPVDrivers(this, vm);
case "VM_OLD_PV_DRIVERS":
vm = connection.Resolve<VM>(vmRef);
if (vm == null)
throw new NullReferenceException("VM_OLD_PV_DRIVERS");
return new PVDriversOutOfDate(this, vm);
case Failure.NO_HOSTS_AVAILABLE:
//CA-63531: Boston server will come here in case of single host pool or standalone host
vm = connection.Resolve<VM>(vmRef);
if (vm == null)
throw new NullReferenceException(Failure.NO_HOSTS_AVAILABLE);
return new NoHosts(this, vm);
case Failure.HOST_NOT_ENOUGH_FREE_MEMORY:
vm = connection.Resolve<VM>(vmRef);
if (vm == null)
throw new NullReferenceException(Failure.HOST_NOT_ENOUGH_FREE_MEMORY);
Pool pool = Helpers.GetPool(vm.Connection);
if (pool == null || pool.Connection.Cache.HostCount == 1)
{
//CA-63531: Cowley server will come here in case of single host pool or standalone host
return new NoHosts(this, vm);
}
Host host = vm.Connection.Resolve(vm.resident_on);
return new NotEnoughMem(this, host);
case Failure.VM_REQUIRES_NETWORK:
vm = connection.Resolve(vmRef);
if (vm == null)
throw new NullReferenceException(Failure.VM_REQUIRES_NETWORK);
XenRef<XenAPI.Network> netRef = new XenRef<XenAPI.Network>(exception[2]);
XenAPI.Network network = connection.Resolve(netRef);
if (network == null)
throw new NullReferenceException(Failure.VM_REQUIRES_NETWORK);
return new VMCannotSeeNetwork(this, vm, network);
case Failure.VM_HAS_VGPU:
vm = connection.Resolve(vmRef);
if (vm == null)
throw new NullReferenceException(Failure.VM_HAS_VGPU);
return new VmHasVgpu(this, vm);
default:
//.........这里部分代码省略.........
示例7: GetBeskDiskStorage
/// <summary>
/// Tries to find the best SR for the given VDI considering the suggestedSR which has priority over other SRs in this check.
/// SuggestedSR, default SR, other SRs are checked.
/// Returns first suitable SR or NULL.
/// </summary>
private static SR GetBeskDiskStorage(IXenConnection connection, VDI disk, Host affinity, SR suggestedSR)
{
// try suggestion
if (suggestedSR != null && suggestedSR.CanBeSeenFrom(affinity) && IsSufficientFreeSpaceAvailableOnSrForVdi(suggestedSR, disk))
return suggestedSR;
// try default sr
SR defaultSR = connection.Resolve(Helpers.GetPoolOfOne(connection).default_SR);
if (defaultSR != null && defaultSR.CanBeSeenFrom(affinity) && IsSufficientFreeSpaceAvailableOnSrForVdi(defaultSR, disk))
return defaultSR;
// pick an sr
foreach (SR sr in connection.Cache.SRs)
{
if (!sr.CanCreateVmOn())
continue;
if (sr.CanBeSeenFrom(affinity) && IsSufficientFreeSpaceAvailableOnSrForVdi(sr, disk))
return sr;
}
// there has been no suitable SR found
return null;
}
示例8: AllVMsAvailable
/// <summary>
/// Checks if all VMs are still available for migration and shows a warning message if the check fails
/// </summary>
/// <returns>true if check succeded, false if failed</returns>
internal static bool AllVMsAvailable(Dictionary<string, VmMapping> vmMappings, IXenConnection connection)
{
Func<bool> vmCheck = delegate
{
if (vmMappings == null || vmMappings.Count == 0 || connection == null)
return false;
return vmMappings.All(kvp => connection.Resolve(new XenRef<VM>(kvp.Key)) != null);
};
return PerformCheck(vmCheck);
}
示例9: CheckAndPlugPBDsFor
private static void CheckAndPlugPBDsFor(IXenConnection connection, List<XenRef<VM>> vmRefs, PlugMode plugMode)
{
//Program.AssertOffEventThread();
List<VM> vms = new List<VM>();
foreach (XenRef<VM> vmRef in vmRefs)
{
VM vm = null;
while ((vm = connection.Resolve<VM>(vmRef)) == null)
Thread.Sleep(100);
vms.Add(vm);
}
CheckAndPlugPBDsFor(vms, plugMode);
}
示例10: NewDiskDialog
public NewDiskDialog(IXenConnection connection, VM vm, SrPicker.SRPickerType PickerUsage, VDI diskTemplate, Host affinity, bool canResize, long minSize, IEnumerable<VDI> vdiNamesInUse)
: this(connection, vdiNamesInUse)
{
TheVM = vm;
DiskTemplate = diskTemplate;
CanResize = canResize;
MinSize = minSize;
this.PickerUsage = PickerUsage;
SrListBox.SetAffinity(affinity);
Pool pool_sr = Helpers.GetPoolOfOne(connection);
if (pool_sr != null)
{
SrListBox.DefaultSR = connection.Resolve(pool_sr.default_SR); //if default sr resolves to null the first sr in the list will be selected
}
SrListBox.selectDefaultSROrAny();
LoadValues();
}
示例11: UpdateEmptyFolders
private static void UpdateEmptyFolders(IXenConnection connection)
{
InvokeHelper.AssertOnEventThread();
String[] emptyFolders = GetEmptyFolders(connection);
Folder root = connection.Resolve(new XenRef<Folder>(PATH_SEPARATOR));
if (root != null)
PurgeEmptyFolders(emptyFolders, root);
foreach (String path in emptyFolders)
GetOrCreateFolder(connection, path);
}
示例12: GetOrCreateFolder
private static Folder GetOrCreateFolder(IXenConnection connection, String[] path, int i)
{
if(i < 0)
return null;
XenRef<Folder> pathToPoint = new XenRef<Folder>(PathToPoint(path, i));
Folder folder = connection.Resolve(pathToPoint);
if (folder != null)
return folder;
Folder parent = GetOrCreateFolder(connection, path, i - 1);
String name = i - 1 >= 0 ? path[i - 1] : String.Empty;
Folder _folder = new Folder(parent, name);
_folder.Path = (parent == null ? "" : parent.opaque_ref);
_folder.opaque_ref = pathToPoint.opaque_ref;
_folder.Connection = connection;
if(parent != null)
parent.AddObject(_folder);
connection.Cache.AddFolder(pathToPoint, _folder);
return _folder;
}