VMware {code} Community
vpatel203
Contributor
Contributor

Showing different menu items based on constraints in plugin.xml

In my vSphere HTML plugin, I want to show a different set of options under the menu item on a datastore. I am not able to figure out how my plugin.xml should look like based on the requirement. If anyone has been in a similar situation before, I would love to know how you solved it.

Situation:

On the Datastore, based on the type of it(VMFS or VVol), I have a different set of options that I want to show. Let's call it VMFS Options and VVol Options. I have some conditions in the backend which gives me true or false based on the VMFS(isMyVMFS) or VVol(isMyVVol).

This(shown in the pluginxml.txt file) is how I tried to do it, but it shows 2 entries of the same name(org.title) when I right-click a Datastore.

<extension id="com.org.orghtml.datastoreMenu">
<extendedPoint>vsphere.core.menus.solutionMenus</extendedPoint>
<object>
<label>#{org.title}</label>
<children>
<Array>
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>action</type>
<uid>com.org.orghtml.actions.VMFSAction1</uid>
</com.vmware.actionsfw.ActionMenuItemSpec>
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>action</type>
<uid>com.org.orghtml.actions.VMFSAction2</uid>
</com.vmware.actionsfw.ActionMenuItemSpec>
</Array>
</children>
</object>
<metadata>
<objectType>Datastore</objectType>
<propertyConditions>
<com.vmware.data.query.CompositeConstraint>
<nestedConstraints>
<com.vmware.data.query.PropertyConstraint>
<propertyName>isMyVMFS</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>
 
<extension id="com.org.orghtml.datastoreMenu">
<extendedPoint>vsphere.core.menus.solutionMenus</extendedPoint>
<object>
<label>#{org.title}</label>
<children>
<Array>
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>action</type>
<uid>com.org.orghtml.actions.VVolAction1</uid>
</com.vmware.actionsfw.ActionMenuItemSpec>
<com.vmware.actionsfw.ActionMenuItemSpec>
<type>action</type>
<uid>com.org.orghtml.actions.VVolAction2</uid>
</com.vmware.actionsfw.ActionMenuItemSpec>
</Array>
</children>
</object>
<metadata>
<objectType>Datastore</objectType>
<propertyConditions>
<com.vmware.data.query.CompositeConstraint>
<nestedConstraints>
<com.vmware.data.query.PropertyConstraint>
<propertyName>isMyVVol</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>

What I want is a single entry of org.title which shows sub items based on the condition it satisfies for.

Reply
0 Kudos
2 Replies
Denis_Chorbadzh
VMware Employee
VMware Employee

Hi,

If I understand correctly, you need to defined two "vise.actions.sets" objects - one with actions for VMFS and the other with actions for VVol.

Use the <propertyConditions> that you already have on the "vise.actions.sets" objects.

Then create one "vsphere.core.menus.solutionMenus" and add all action items there.

 

In addition, you can try using "<conditionalProperty>my_property</conditionalProperty>" on "com.vmware.actionsfw.ActionSpec>" level to filter individual actions.

 

For a concrete example, please refer to "vsphere-wssdk-sample" sample plugin from vSphere 6.5U1 SDK.

 

Let us know if you this helps.

 

Best Regards,

Denis

Reply
0 Kudos
vpatel203
Contributor
Contributor

Thank you, Denis. 🙂 

I referred to the sample project is the 6.5 SDK and was able to fix the plugin.xml file based on that. 

Reply
0 Kudos