VMware {code} Community
violinbw
Contributor
Contributor

propertyConditions problems with plugin for 6.7.u2

I found an older post on these forums containing example code for filtering extensions that isn't working for me in 6.7.u2 for my HTML5 plug-in.  The plug-in is never visible even when customProperty returns true.  Could you tell me where the mistake is?

   <extension id="com.violin.violinplugin.datastore.configureView">

      <extendedPoint>vsphere.core.datastore.manageViews</extendedPoint>

      <object>

         <name>Violin Storage</name>

         <contentSpec>

            <url>/ui/violinplugin/resources/datastore-edit.html</url>

         </contentSpec>

      </object>

      <metadata>

          <objectType>Datastore</objectType>

          <propertyConditions>

              <com.vmware.data.query.CompositeConstraint>

                 <nestedConstraints>

                     <com.vmware.data.query.PropertyConstraint>

                       <propertyName>customProperty</propertyName>

                       <comparator>EQUALS</comparator>

                       <comparableValue>

                          <Boolean>true</Boolean>

                       </comparableValue>

                     </com.vmware.data.query.PropertyConstraint>

                 </nestedConstraints>

                 <conjoiner>AND</conjoiner>

              </com.vmware.data.query.CompositeConstraint>

          </propertyConditions>

       </metadata>    

   </extension>  

PropertyProviderAdapter code (with a slightly modified constructor signature) copied off these forums:

public class ViolinPropertyAdapter implements PropertyProviderAdapter {

private Log _logger = LogFactory.getLog(ViolinPropertyAdapter.class);

private static final String CUSTOMPROPERTY = "customProperty";

public ViolinPropertyAdapter(DataService dataService,

     ObjectReferenceService objectReferenceService,

     DataServiceExtensionRegistry extensionRegistry,

     UserSessionService userSessionService) {

     TypeInfo vmTypeInfo = new TypeInfo();

     vmTypeInfo.type = "Datastore";

     vmTypeInfo.properties = new String[]{CUSTOMPROPERTY};

     TypeInfo[] providerTypes = new TypeInfo[]{vmTypeInfo};

     extensionRegistry.registerDataAdapter(this, providerTypes);

}

@Override

public ResultSet getProperties(PropertyRequestSpec propertyRequest) {

     _logger = LogFactory.getLog(ViolinPropertyAdapter.class);

     _logger.info("getProperties()");

     ResultSet result = new ResultSet();

     try {

     List<ResultItem> resultItems = new ArrayList<ResultItem>();

     if(propertyRequest.properties != null && propertyRequest.properties.length > 0) {

     String[] listPropertyNames = propertyRequest.properties[0].propertyNames;

     for(String propertyName : listPropertyNames) {

          for(Object dsRef : propertyRequest.objects) {

          ResultItem resultItem = getDsProperties(dsRef, propertyName);

          if(resultItem != null) {

          resultItems.add(resultItem);

     }

     }

     }

     } else

     result.items = resultItems.toArray(new ResultItem[]{});

     } catch(Exception e) {

     // Passing the exception in the result allows to display an error

     // notification

     // in the client UI.

     result.error = e;

     }

     return result;

}

private ResultItem getDsProperties(Object dsRef, String propertyName) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

     ResultItem ri = new ResultItem();

     ri.resourceObject = dsRef;

     PropertyValue pvCustomProperty = new PropertyValue();

     pvCustomProperty.resourceObject = dsRef;

     pvCustomProperty.propertyName = CUSTOMPROPERTY;

     boolean val = new Random().nextBoolean();

     _logger.info(CUSTOMPROPERTY + "=" + val);

     pvCustomProperty.value = val;// here taken the random boolean value which will load in

     // plugin.xml. On true return you can filter the extension

     // point using property

     ri.properties = new PropertyValue[]{pvCustomProperty};

     return ri;

}

}

And finally, the entries in my log file, that shows the PropertyProviderAdapter  being called:

[2020-04-08 23:02:58] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:44 - getProperties()

[2020-04-08 23:02:58] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:76 - customProperty=false

[2020-04-08 23:03:14] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:44 - getProperties()

[2020-04-08 23:03:14] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:76 - customProperty=false

[2020-04-08 23:03:15] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:44 - getProperties()

[2020-04-08 23:03:15] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:76 - customProperty=true

[2020-04-08 23:03:17] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:44 - getProperties()

[2020-04-08 23:03:17] [INFO] com.violin.violinplugin.adapters.ViolinPropertyAdapter:76 - customProperty=true

If you could give me a working code example of filtering based of a datastore property for 6.7, or tell me what needs to be fixed in the simple example I've included, that'd really help me out.  Thanks!

0 Kudos
3 Replies
_vladi_
VMware Employee
VMware Employee

Hi,

I don't see an issue with the code above.

My suggestion is to test without the PropertyConstraint first to make sure there is no error in the rest of the code.

Also please try and compare to the WSSDK and other samples from the 6.5U1 SDK which demonstrate such filtering.

Cheers,

Vladi

0 Kudos
violinbw
Contributor
Contributor

Thanks for your response, Vladi.  The plugin works as expected without the PropertyConstraint.  Could you please provide me with the correct link to download the WSSDK and other samples from the 6.5U1 SDK?  I want to make sure I'm referencing the correct material.  Thanks!

0 Kudos
_vladi_
VMware Employee
VMware Employee

Please use the legacy vSphere Web Client SDK 6.5: vSphere Web Client SDK - VMware {code}

Download the 6.5U1 one. You can both check the code or try reproducing this against the WSSDK sample.

Cheers,

Vladi

0 Kudos