Quantcast
Channel: VMware Communities : Discussion List - vSphere Client SDK
Viewing all articles
Browse latest Browse all 2218

Web Client SDK 6.0 - Java code to examine bmc HostSystem Object - config.ipmi.bmcIpAddress

$
0
0


I've been trying to get information programmatically about the bmc - specifically its IP.  Using the web client  (with no changes) I was able to see bmc information in Navigator->Hosts->Hardware Status->Sensors->Baseboard Management Controller->Management Controller IP Interface->Details.  So, I know the information is available.


I changed some code you helped me with earlier to allow me to query for "config.ipmi.bmcIpAddress" from HostSystem.

   /**



    * Returns the current Host objects in the system.



    */



   private ResultItem[] getHosts(int maxResultCount) {



 



      // create QuerySpec



      QuerySpec qs = new QuerySpec();



      qs.resourceSpec = new ResourceSpec();



      qs.resourceSpec.constraint = new Constraint();



      // HostSystem is the targetType



      qs.resourceSpec.constraint.targetType = HOST_TYPE;



      // request the name property



      PropertySpec pSpec = new PropertySpec();



      //pSpec.propertyNames = new String[]{"name"};



      pSpec.propertyNames = new String[]{"name", /"hardware.systemInfo.model",/ "config.ipmi.bmcIpAddress"};

      qs.resourceSpec.propertySpecs = new PropertySpec[];</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      qs.resultSpec = new ResultSpec();</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      qs.resultSpec.maxResultCount = new Integer(maxResultCount);</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      // use default ordering</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      qs.resultSpec.order = new OrderingCriteria();</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      qs.resultSpec.order.orderingProperties = new OrderingPropertySpec[0];</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      // get data from DataService</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      RequestSpec requestSpec = new RequestSpec();</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      requestSpec.querySpec = new QuerySpec[];</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;"> </div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      Response response = _dataService.getData(requestSpec);</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;"> </div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      ResultItem[] items = response.resultSet[0].items;</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //if (items == null) {</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //   return new Object[0];</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //}</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //Object[] hosts = new Object[items.length];</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //for (int index = 0; index &lt; items.length; ++index) {</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //   hosts[index] = items[index].resourceObject;</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //}</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      //return hosts;</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">      return items;</div><div id="cke_pastebin" style="position: absolute; top: -508px; width: 1px; height: 860px; overflow: hidden; margin: 0px; padding: 0px; left: -1000px;">   }</div><br><code>  /** Returns the current Host objects in the system. */   private ResultItem[] getHosts(int maxResultCount) {</code><br><code>      // create QuerySpec      QuerySpec qs = new QuerySpec();      qs.resourceSpec = new ResourceSpec();      qs.resourceSpec.constraint = new Constraint();      // HostSystem is the targetType      qs.resourceSpec.constraint.targetType = HOST_TYPE;      // request the name property      PropertySpec pSpec = new PropertySpec();      //pSpec.propertyNames = new String[]{"name"};      pSpec.propertyNames = new String[]{"name", /"hardware.systemInfo.model",/ <span style="color:#FF0000;">"config.ipmi.bmcIpAddress"</span>};      qs.resourceSpec.propertySpecs = new PropertySpec[];

      qs.resultSpec = new ResultSpec();

      qs.resultSpec.maxResultCount = new Integer(maxResultCount);

      // use default ordering

      qs.resultSpec.order = new OrderingCriteria();

      qs.resultSpec.order.orderingProperties = new OrderingPropertySpec[0];

      // get data from DataService

      RequestSpec requestSpec = new RequestSpec();

      requestSpec.querySpec = new QuerySpec[];


      Response response = _dataService.getData(requestSpec);




      ResultItem[] items = response.resultSet[0].items;

      return items;
   }




name is returned, but no item is returned for the bmc.  Here is the error I get in the Virgo server log - which I don't understand, except that it says it only returned "name"...  Shouldn't there be a bmc Property name in the ResourceSpec?


[2015-05-05T17:23:53.537-06:00] http-bio-9443-exec-3         70000094 100002 200001 com.vmware.vise.data.query.impl.DataServiceImpl                   Error occurred while executing query: 

QuerySpec

   QueryName: dam-auto-generated: GraphEdgeSet:dr-17

   ResourceSpec

      Constraint: Constraint

         TargetType: samples:Chassis

      PropertySpec[1]

         ProviderType: samples:Chassis

         Relationship: null

         Properties[3]

            PropertyName: labelIds

            PropertyName: primaryIconId

            PropertyName: name

   ResultSpec:

      Offset: 0

      MaxResultCount: 42

      OrderingCriteria

         OrderPropertySpec[1]

            ProviderType: samples:Chassis

            Relationship: null

            SortType: ASCENDING

            OrderingProperties[1]

               PropertyName: name

      Facets: null

   Options:

      REDUCE_QUERIES=true


 


Viewing all articles
Browse latest Browse all 2218

Trending Articles