本文整理汇总了C#中XenAPI.Session.get_this_host方法的典型用法代码示例。如果您正苦于以下问题:C# Session.get_this_host方法的具体用法?C# Session.get_this_host怎么用?C# Session.get_this_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenAPI.Session
的用法示例。
在下文中一共展示了Session.get_this_host方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetectStatus
static void DetectStatus(object obj)
{
object[] args = (object[])obj;
HIMNForm form = args[0] as HIMNForm;
int i = (int)args[1];
string url = form.urls[i];
string sessionRef = form.sessionRefs[i];
string vm_uuid = form.vm_uuids[i];
DataGridViewRow row = form.dgv_vms.Rows[i];
try
{
Log(vm_uuid, "DetectStatus");
//params
Log(vm_uuid, string.Format("url: {0}", url));
Log(vm_uuid, string.Format("sessionRef: {0}", sessionRef));
Log(vm_uuid, string.Format("vm_uuid: {0}", vm_uuid));
//session
Session session = new Session(url, sessionRef);
Log(vm_uuid, "session created");
//host
Host host = Host.get_record(session, session.get_this_host());
Log(vm_uuid, "host: " + host.name_label);
row.Cells[0].Value = host.name_label;
//vm
XenRef<VM> _vm = VM.get_by_uuid(session, vm_uuid);
string vmRef = _vm.opaque_ref;
VM vm = VM.get_record(session, vmRef);
Log(vm_uuid, "vm:" + vm.name_label);
row.Cells[1].Value = vm.name_label;
//power_state
Log(vm_uuid, "power_state:" + vm.power_state);
row.Cells[2].Value = vm.power_state.ToString();
//pv installed
bool pvInstalled = GetPVInstalled(session, vm);
Log(vm_uuid, "pv_installed:" + pvInstalled);
if (vm.power_state == vm_power_state.Running)
{
row.Cells[3].Value = pvInstalled ? "Installed" : "Not installed";
}
else
{
row.Cells[3].Value = "Unknown";
}
//himn exists
XenRef<Network> _network = Network.get_by_name_label(session, HIMN_NAME_LABEL)[0];
string netRef = _network.opaque_ref;
VIF vif = getVIF(session, netRef, vm);
bool HIMNExists = (vif != null);
Log(vm_uuid, "himn_exists:" + HIMNExists);
form.himn_states[i] = HIMNExists;
if (HIMNExists)
{
row.Cells[4].Value = string.Format(
"Already added as VIF '{0}' with MAC '{1}'. ",
vif.device, vif.MAC);
}
else
{
bool RebootRequired = (vm.power_state != vm_power_state.Halted && !pvInstalled);
row.Cells[4].Value = "Ready. " +
(RebootRequired ? "Requires reboot." : "No reboot required.");
row.Cells[5].Value = true;
}
}
catch (Exception ex)
{
Log(vm_uuid, ex.ToString());
row.Cells[4].Value = ex.ToString();
}
finally
{
form.CheckedCounter -= 1;
if (form.CheckedCounter == 0)
{
form.btnAdd.Enabled = true;
form.btnRemove.Enabled = true;
threads.Clear();
}
}
}