You define relations between the vSphere objects by using the RelationSpec object in the plugin.xml manifest file of your vSphere Web Client extension.

You describe each of the relations for the vSphere object using RelationSpec objects, which you must create inside the <relationSpecs> property of the ObjectRelationSetSpec extension object. Each RelationSpec object contains information on the relation target object type, display properties such as icons and labels, and any relevant list extensions for the relation target object.

The following table lists the properties of the RelationSpec object.

Property

Type

Description

<id>

string

Unique identifier for the relation. The best practice for creating an ID value for a relation is to use the format <relation_target_object>For<relation_object>. For example, if the parent ObjectRelationSetSpec object defines the relations for Chassis objects, you might use the value hostForChassis as the ID for the RelationSpec object that describes the relation to host objects.

<icon>

array

Icon resource for the relation. The icon appears in the Related Objectsrelated objects data view and in the object navigator. You can specify a dynamic resource from your plug-in module for the relation icon.

<label>

string

Text label for the relation. This label appears in the Related Objectsrelated objects data view and in the object navigator. You can hard code a string value or include a dynamic resource string from your plug-in module resources file.

<listViewId>

string

Extension ID for a list view that can display the relation target object type. For example, a hostForChassis relation can specify the extension ID of a host list view. The vSphere Web Client uses this list view extension to display the list of related target objects.

<relation>

string

Property name that is included in the relation constraint.

<conditionalProperty>

string

Additional property on the relation target object that can be used to constrain which related items are displayed in the vSphere Web Client GUI. You specify the name of a Boolean property on the target object using this property, and only objects for which the property is true appear in the vSphere Web Client GUI.

<targetType>

string

Relation target object type. For example, in the hostForChassis relation, which displays Host objects related to a selected Chassis object, you specify the <targetType> as HostSystem.

The following example presents an example extension definition for a relation extension. In the example, the extension defines relations for the Chassis object type. When the user selects a chassis object, the vSphere Web Client provides related items information for the relations defined in the example. In the example, relations are defined for Rack and Host object types.

<!-- Chassis relations -->
<extension id="com.vmware.samples.relateditems.specs.chassis">
<extendedPoint>vise.relateditems.specs</extendedPoint>
<object>
<type>samples:Chassis</type>
<!-- relationsViewId references the "related items view" extension created
by the object template. It must be defined for the related items view to
be shown on the right-hand side.
-->
<relationsViewId>com.vmware.samples.chassis.related</relationsViewId>
<relationSpecs>
<com.vmware.ui.relateditems.model.RelationSpec>
<id>rackForChassis</id>
<icon>#{rack}</icon>
<label>#{rackLabel}</label>
<relation>rack</relation>
<targetType>samples:Rack</targetType>
<!-- listViewId must be defined for the chassis' related items tab
to show the rack list. The extension itself gets created as part of
the object view template. Here we use ${namespace}.list for id.
-->
<listViewId>com.vmware.samples.rack.list</listViewId>
</com.vmware.ui.relateditems.model.RelationSpec>
<com.vmware.ui.relateditems.model.RelationSpec>
<id>hostForChassis</id>
<icon>#{CommonImages:hostsystem}</icon>
<label>#{Common:typeResource.hostPlural}</label>
<relation>host</relation>
<targetType>HostSystem</targetType>
<!-- listViewId below is the id defined by vSphere client for the HostSystem
type. This list is shown as one of the items in the chassis Related Items tab.
Other vSphere types like VirtualMachine, ClusterComputeResource, etc., have
similar lists are predefined.
-->
<listViewId>vsphere.core.host.list</listViewId>
</com.vmware.ui.relateditems.model.RelationSpec>
</relationSpecs>
</object>
</extension>