In vSphere web client plugin i want to fetch the remotehost and remotepath of the datastore

I created a DataByModelRequest in the mediator class and calling one model from the mediator

    [Event(name="{com.vmware.data.query.events.DataByModelRequest.REQUEST_ID}",
          type="com.vmware.data.query.events.DataByModelRequest")]

    private function requestData():void {
          var requestInfo:DataRequestInfo = new DataRequestInfo(DataUpdateSpec.newImplicitInstance());


       var dsdatarequest:DataByModelRequest = DataByModelRequest.newInstance(
           _contextObject, DatastoreDataItem, requestInfo);
       dispatchEvent(vmdatarequest);
       }

[ResponseHandler(name=
         "{com.vmware.data.query.events.DataByModelRequest.RESPONSE_ID}")]
   public function onDataRetrieved(request:DataByModelRequest,
                                   result:DatastoreDataItem, error:Error):void {

       if (error != null) {
           Alert.show("ERROR");
           _logger.debug("onDataRetrieved error: " + error.message);
           return;
       }
       else
           Alert.show(ObjectUtil.toString(_contextObject));
           Alert.show("RETRIVED");


       // Assigning the result to variables to update the view.
       _view.dsprop = result;
       Alert.show(ObjectUtil.toString(result)); 

   }

DatastoreDataItem is my Model Class

[Bindable]
[Model(type="Datastore")]

public class DatastoreDataItem extends DataObject {



    [Model(relation="info.nas", property="type")]
        public var type:String;

    [Model(relation="info.nas", property="remoteHost")]
        public var remotehost:String;

    [Model(relation="info.nas", property="remotePath")]
        public var remotepath:String;

    [Model(property="url")]
        public var url:String;
    }

am getting the null value for all fields but name is working fine and i tried [Model(type="NasDatastoreInfo")] also

有帮助吗?

解决方案

The relational syntax you are using doesn't work because the Datastore info is not a managed entity, it's just a property field. The solution is to cast it to the right type of Datastore.Info, i.e. NasDatastoreInfo in your case. Here is the syntax to use in your model:

[Model(property="info[@type='NasDatastoreInfo'].nas.remoteHost")]

// The server for NFS datastore

public var nfsServer:String; 



[Model(property="info[@type='NasDatastoreInfo'].nas.remotePath")]

// The folder for NFS datastore

public var nfsFolder:String;

Source : https://communities.vmware.com/thread/457542

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top