I'm trying to add a portlet to HostSystem that only appears if there is a relationship to one of my custom objects. However, I can't find a way to achieve this. I tried various syntaxes to add a relational constraint in "plugin.xml" but this failed to work, including one from an old post here.
I tried this on a modified "chassis-b" sample (where only the first host is assigned to a chassis, to make it easy to tell that the portlet only appears on hosts with chassis).
<metadata>
<propertyConditions>
<com.vmware.data.query.CompositeConstraint>
<nestedConstraints>
<com.vmware.data.query.PropertyConstraint>
<propertyName>chassis</propertyName>
<comparator>EQUALS</comparator>
<comparableValue>
<Boolean>false</Boolean>
</comparableValue>
</com.vmware.data.query.PropertyConstraint>
</nestedConstraints>
<conjoiner>AND</conjoiner>
</com.vmware.data.query.CompositeConstraint>
</propertyConditions>
</metadata>
Any suggestions greatly appreciated!
<PropertyConstraint> conditions are very particular. I would do something like below, where you add a custom property "chassisCount" that resolves into the number of related Chassis object. You need to implement that chassisCount logic in your Data Provider
<conditions>
<com.vmware.data.query.PropertyConstraint>
<propertyName>chassisCount</propertyName>
<comparator>EQUALS</comparator>
<comparableValue>
<String>0</String>
</comparableValue>
</com.vmware.data.query.PropertyConstraint>
</conditions>
<PropertyConstraint> conditions are very particular. I would do something like below, where you add a custom property "chassisCount" that resolves into the number of related Chassis object. You need to implement that chassisCount logic in your Data Provider
<conditions>
<com.vmware.data.query.PropertyConstraint>
<propertyName>chassisCount</propertyName>
<comparator>EQUALS</comparator>
<comparableValue>
<String>0</String>
</comparableValue>
</com.vmware.data.query.PropertyConstraint>
</conditions>
Thanks. This would have to be a property on the "HostSystem" VMWare-provided object, correct? Is it possible for a plugin to add such a property to the built-in objects? Is there any sample code for this? I couldn't find it in any of the samples included with the SDK.
I worked out how to handle a property for a VMWare-provided object in my plugin, so this question is answered. Thanks for your help!
Good to hear. And to answer your previous question, yes, you can use conditional properties on custom objects.