Quantcast
Channel: VMware Communities: Message List - vSphere Management SDK
Viewing all articles
Browse latest Browse all 2052

Re: VMINFO.PL: how to list the power state of the VM????

$
0
0

Hi,

 

Not sure if you have got the answer but it is quite easy & have done it myself. I came across this need of getting Power State few days back.

 

I have done few things that I am mentioning here :

 

1. Added a if condition for PowerState under foreach() loop like below-

 

elsif($_ eq 'powerState') {

if (defined($vm_view->runtime) && defined ($vm_view->runtime->powerState)) {

print_log($vm_view->runtime->powerState->val,"powerState", "Power State ");

}

}

 

2. I have updated the powerstate definition under %opts

powerstate' => {

      type    => "=s",

      help    => "State of the virtual machine: poweredOn or poweredOff",

      required => 0,

  }

 

3. Added "powerState" to validate() >> @valid_properties

 

With this I am able to manage to get the below output with Power State of the VM in context-

 

<Root>

<VM>

<Name>vm001</Name>

<noCPU>2</noCPU>

<memorySize>4096</memorySize>

<virtualDisks>1</virtualDisks>

<template>0</template>

<vmPathName>[hfesx005-data] vm001/vm001.vmx</vmPathName>

<guestOS>CentOS 4/5/6/7 (64-bit)</guestOS>

<guestId>centos64Guest</guestId>

<hostName>localhost.localdomain</hostName>

<ipAddress>16.71.85.181</ipAddress>

<VMwareTools>VMware Tools is running and the version is current</VMwareTools>

<cpuUsage>0 MHz</cpuUsage>

<hostMemoryUsage>742 MB</hostMemoryUsage>

<guestMemoryUsage>1064 MB</guestMemoryUsage>

<powerState>poweredOn</powerState>

<overallStatus>The entity is OK</overallStatus>

</VM>

</Root>

 

Hope this will help.

 

Regards

Akshat Tambe


Viewing all articles
Browse latest Browse all 2052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>