개요
MS 에서 만든 가상화 솔루션이며 아래는 참고 자료입니다.
- http://www.virtualizationadmin.com/articles-tutorials/general-virtualization-articles/chapter-2-hyper-v-overview.html
- http://winadmins.tistory.com/20
Management API
- Hyper -V WMI Provider라고 부른다.
- Java API는 없으며 VB / C# API가 있다.
- 샘플코드 : http://msdn.microsoft.com/en-us/library/cc160706(v=VS.85).aspx
using System.Management;
namespace HyperVSamples
{
class GetSummaryInformationClass
{
ManagementObject virtualSystemService = null;
ManagementScope scope = null;
GetSummaryInformationClass()
{
scope = new ManagementScope(@"root\virtualization", null);
virtualSystemService = Utility.GetServiceObject
(scope, "Msvm_VirtualSystemManagementService");
}
ManagementObject GetVirtualSystemSetting(string vmName)
{
ManagementObject virtualSystem = Utility.GetTargetComputer
(vmName, scope);
ManagementObjectCollection virtualSystemSettings =
virtualSystem.GetRelated
(
"Msvm_VirtualSystemSettingData",
"Msvm_SettingsDefineState",
null,
null,
"SettingData",
"ManagedElement",
false,
null
);
ManagementObject virtualSystemSetting = null;
foreach (ManagementObject instance in virtualSystemSettings)
{
virtualSystemSetting = instance;
break;
}
return virtualSystemSetting;
}
void GetSummaryInformation(ManagementObject[]
virtualSystemSettings, UInt32[] requestedInformation)
{
ManagementBaseObject inParams =
virtualSystemService.GetMethodParameters("GetSummaryInformation");
string[] settingPaths = new string[virtualSystemSettings.Length];
for (int i = 0; i < settingPaths.Length; ++i)
{
settingPaths[i] = virtualSystemSettings[i].Path.Path;
}
inParams["SettingData"] = settingPaths;
inParams["RequestedInformation"] = requestedInformation;
ManagementBaseObject outParams = virtualSystemService.InvokeMethod
("GetSummaryInformation", inParams, null);
if ((UInt32)outParams["ReturnValue"] == ReturnCode.Completed)
{
Console.WriteLine("Summary information was retrieved
successfully.");
ManagementBaseObject[] summaryInformationArray =
(ManagementBaseObject[])outParams["SummaryInformation"];
foreach (ManagementBaseObject summaryInformation in
summaryInformationArray)
{
Console.WriteLine("\nVirtual System Summary Information:");
foreach (UInt32 requested in requestedInformation)
{
switch (requested)
{
case 0:
Console.WriteLine("\n\tName: {0}",
summaryInformation["Name"].ToString());
break;
case 1:
Console.WriteLine("\tElement Name: {0}",
summaryInformation["ElementName"].ToString());
break;
case 2:
Console.WriteLine("\tCreation Time: {0}",
summaryInformation["CreationTime"].ToString());
break;
case 3:
Console.WriteLine("\tNotes: {0}",
summaryInformation["Notes"].ToString());
break;
case 4:
Console.WriteLine("\tNumber of Processors:
{0}", summaryInformation
["NumberofProcessors"].ToString());
break;
}
}
}
}
else
{
Console.WriteLine("Failed to retrieve virtual system
summary information");
}
inParams.Dispose();
outParams.Dispose();
}
void Close()
{
this.virtualSystemService.Dispose();
}
static void Main(string[] args)
{
if (args != null && (args.Length < 2 || args.Length > 6))
{
Console.WriteLine("GetSummaryInformation vmName value1
value2...");
Console.WriteLine("value:");
Console.WriteLine("\t0:Name");
Console.WriteLine("\t1:Element Name");
Console.WriteLine("\t2:Creation Time");
Console.WriteLine("\t3:Notes");
Console.WriteLine("\t4:Number of Processors");
Console.WriteLine("\nExample: GetSummaryInformation
MyfirstVM 0 1 4");
return;
}
GetSummaryInformationClass getSummaryInfo = new
GetSummaryInformationClass();
string vmName = args[0];
ManagementObject virtualSystemSetting =
getSummaryInfo.GetVirtualSystemSetting(vmName);
ManagementObject[] settings = new ManagementObject[1];
settings[0] = virtualSystemSetting;
UInt32[] requestedInfo = new UInt32[args.Length - 1];
for (int i = 1; i < args.Length; ++i)
{
requestedInfo[i - 1] = UInt32.Parse(args[i]);
}
getSummaryInfo.GetSummaryInformation(settings, requestedInfo);
getSummaryInfo.Close();
virtualSystemSetting.Dispose();
}
}
|
SummaryInformation Class : http://msdn.microsoft.com/en-us/library/cc136898(v=VS.85).aspx
[Dynamic, Provider("VmmsWmiInstanceAndMethodProvider")] class Msvm_SummaryInformation{ string Name; string ElementName; uint16 EnabledState; uint16 HealthState; string Notes; uint16 NumberOfProcessors; uint8 ThumbnailImage[]; DateTime CreationTime; uint16 ProcessorLoad; uint16 ProcessorLoadHistory[]; uint64 MemoryUsage; sint32 MemoryAvailable; sint32 AvailableMemoryBuffer; uint16 Heartbeat; uint64 UpTime; string GuestOperatingSystem; uint16 OperationalStatus[]; string StatusDescriptions[]; CIM_VirtualSystemSettingData Snapshots[]; CIM_ConcreteJob AsynchronousTasks[]; string AllocatedGPU; }; |
댓글 없음:
댓글 쓰기