VMware Cloud Community
thanosazlin
Contributor
Contributor

what api cal in vmware.vim.dll that is similar to command "vmkload_mod"

i have been successful in connecting to my vcenter host using api calls from vmware.vim.dll...  i then was able extract the esx hosts names and version of esx.

//connects to vcenter server

VimClient client = new VimClient();

client.Login(@"https://" + vcenter_host_ip + @"/sdk", vcenter_username, vcenter_password);

//holds list of esx hosts

esxList = client.FindEntityViews(typeof(HostSystem), null, null, null);

string hostname = host.Name.ToString();

string version = host.Summary.Config.Product.FullName.ToString();

I think want to be able to query for a specific module on the esx hosts similar to esx command "vmkload_mod --showinfo mod_name"

and get back the version of a specific module i am looking for..

i have not had luck with vmware api reference docs nor exploring on my own to figure out how to get this info.

is it possible to get this info for a module using HostSystem, or is some other method needed? any help appreciated thanks

Tags (2)
0 Kudos
4 Replies
mcowger
Immortal
Immortal

LucD's answer is better.

--Matt VCDX #52 blog.cowger.us
0 Kudos
LucD
Leadership
Leadership

Querying for a kernel module and it's options can be done with the QueryModules and the QueryConfiguredModuleOptionString methods.

The corresponding PowerCLI cmdlet is Get-VMHostModule.

To see the modules and their eventual options you can do

$esx = Get-VMHost MyEsx

$modSys = Get-View $esx.ExtensionData.ConfigManager.KernelModuleSystem $mods = $modSys.QueryModules() $mods | Select Name,OptionString

or just

Get-VMHostModule -VMHost $esx


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
thanosazlin
Contributor
Contributor

thank for that info. i must find a way to use the api calls and not powershell commands.  so i have tried to figure out how vmware sdk calls are made, i adjusted my code many times finally getting something useful of the below code, but for some reason string "test" just has alot of garbage data in it.. am I on the right track here? if not or if so any help in clearing this up for me would be great?  again my goal is to just get the esx host names which i have been able to do, then loop through each of them to have api call to get a specific module version which in this case is called "emcp" .. thanks in advance.

IList<EntityViewBase> esxList; //stores esx hosts info

//connects to vcenter server

VimClient client = new VimClient();

client.Login(@"https://" + vcenter_host_ip + @"/sdk", vcenter_username, vcenter_password);

//holds list of esx hosts

esxList = client.FindEntityViews(typeof(HostSystem), null, null, null);

foreach (HostSystem host in esxList)

{

HostKernelModuleSystem mod = (HostKernelModuleSystem)client.GetView(host.ConfigManager.KernelModuleSystem, null);

string test = mod.QueryConfiguredModuleOptionString("emcp").ToString();

MessageBox.Show(test);

}

0 Kudos
thanosazlin
Contributor
Contributor

i figured it out Smiley Happy !!!! thank you thank you to LucD you got me in the right direction. here is my code, while it just basic enough to test getting what i need, i will tweak it little further but at least i am able to query modules from esx hosts now.

//connects to vcenter server

VimClient client = new VimClient();

client.Login(@"https://" + vcenter_host_ip + @"/sdk", vcenter_username, vcenter_password);

//holds list of esx hosts

esxList = client.FindEntityViews(typeof(HostSystem), null, null, null);

foreach (HostSystem host in esxList)

{

    HostKernelModuleSystem mod = (HostKernelModuleSystem)client.GetView(host.ConfigManager.KernelModuleSystem, null);

    KernelModuleInfo[] test = mod.QueryModules();

     foreach (KernelModuleInfo module in test)

     {

           if (module.Name == "emcp")

           {

                string name = module.Name;

                string version = module.Version;

                MessageBox.Show(name + " " + version);

           }

     }

}

0 Kudos