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

vmodl.ManagedObjectReference?

$
0
0


Any ideas which VMware jar contains the following class:


    com.vmware.vim.binding.vmodl.ManagedObjectReference


I am getting HostSystem managed object references back in a data service query, but the class type is different than the expected vim25.ManagedObjectReference, so I cannot de-reference the object to access sub fields.   Or is there some workaround to get the Object's class and fields?


The code in question gets Host related objects for my plugin.  This code is borrowed from the HTML bridge ChassisB samples.  The code creates a QuerySpec and sets the targetType to 'HostSystem'.   The QuerySpec is added to a RequestSpec which is given to the data service method to return the Host data.  The Response returns a list of ResultItems in an array.   The resourceObject field of the Object items contains the managed reference.  Ideally, I'd like to cast this object to its class so I can query the fields.


          // create QuerySpec
          QuerySpec qs = new QuerySpec();
          qs.resourceSpec = new ResourceSpec();
          qs.resourceSpec.constraint = new Constraint();


          // HostSystem is the targetType

          qs.resourceSpec.constraint.targetType = StorageSystemDataAdapter.HOST_TYPE;

          // request the name property

          PropertySpec pSpec = new PropertySpec();

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

          qs.resourceSpec.propertySpecs = new PropertySpec[];

          qs.resultSpec = new ResultSpec();

          

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

 


          // 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;
          if (items == null) {
             return new String[0];
          }
          
          ArrayList<Object> hostList = new ArrayList<Object>();

           
          for (int index = 0; index < items.length; ++index) {
              Object hostRef = items[index].resourceObject; }


             // hostRef Class is com.vmware.vim.binding.vmodl.ManagedObjectReference


            // not com.vmware.vim25.ManagedObjectReference


 


Viewing all articles
Browse latest Browse all 2218

Trending Articles