A selector extension associates a registered object extension with one or more of the phases of an extensible object type.

Associating a selector extension with an object type or instance and registered object extension enables the object extension to receive messages when an operation on the type or instance reaches an extensible phase of its execution. A selector extension can be associated with one or more object extensions.

This operation is restricted to system administrators.

You must provide the ID of a registered object extension as part of the request to create a selector extension. That ID is returned when you create the object extension. If you don't know the ID of the object extension, you can retrieve a list of all registered object extensions with a request like this one:

GET https://vcloud.example.com/api/admin/extension/object

1

Construct an ObjectExtension element.

The ObjectExtensionId element in the request must specify the ID of the object extension for which you are creating this selector extension. See the request portion of Example: Create a Selector Extension for a Registered Object Extension.

2

POST the ObjectExtension element to the URL for the object that you wish to extend.

The URL can refer to a specific object or all objects of a certain type. See the request portion of Example: Create a Selector Extension for a Registered Object Extension.

This example adds a selector extension to the object extension registered in Example: Register an Object Extension. This request is appropriate for an extension that must gather and analyze Provider VDC requirements associated with the creation of a virtual machine, but not influence the operation of the phase. The selector specifies the urn:extensionPoint:vm:gatherRequirements phase and async execution, so the system does not block awaiting a response. Because the phase has an optional attribute with a value of true phase execution continues even if the extension fails.

If the extension is to influence the outcome of the phase by replying with modified requirements, it must set type to blocking and be prepared to reply within the specified time-out interval.

In this example, the selector extension sets Priority to 1. The system uses the Priority value to control the order of execution when multiple extensions have registered interest in a phase. Note that a Priority of 1 does not always mean that the extension is called first. For some extensions, such as those that select the urn:extensionPoint:vm:calculateSolution phase and affect placement, the highest priority position in the execution order is the final one. This approach ensures that any placement solution offered by the extension cannot be superseded by a solution offered by a different extension.

A request like this one sets this SelectorExtension as the default extension policy for all Provider VDCs in the system.

Request:

POST https://vcloud.example.com/api/admin/providervdcs/extension
Content Type: application/vnd.vmware.admin.extensibility.selector+xml
...
<?xml version="1.0" encoding="UTF-8"?>
<SelectorExtension
   xmlns="http://www.vmware.com/vcloud/v1.5" >
   <Enabled>false</Enabled>
   <Priority>1</Priority>
   <ObjectExtensionId>83...0d39</ObjectExtensionId>
   <Phases>
      <Phase
         name="urn:extensionPoint:vm:gatherRequirements"
         type="async"
         optional="true" />
   </Phases>
</SelectorExtension>

To apply this policy to a single Provider VDC, use a request of the following form:

POST https://vcloud.example.com/api/admin/providervdc/ID/extension

The system creates the selector extension and returns a SelectorExtension element that includes information derived from the contents you POSTed, and a set of Link elements that you can use to access or modify the new object extension.

Response:

201 Created
Content Type: application/vnd.vmware.admin.extensibility.selector+xml
...
<SelectorExtension  
   xmlns="http://www.vmware.com/vcloud/v1.5"  
   id="b3...f8ee"  
   href="https://vcloud.example.com/api/admin/providervdcs/extension/b3...f8ee"  
   ... >
   <Link  
      rel="remove"  
      href="https://vcloud.example.com/api/admin/providervdcs/extension/b3...f8ee" />
   <Link  
      rel="edit"  
      href="https://vcloud.example.com/api/admin/providervdcs/extension/b3...f8ee"  
      type="application/vnd.vmware.admin.extensibility.selector+xml" />
   <Link  
      rel="up"  
      href="https://vcloud.example.com/api/admin/providervdcs/extension"  
      type="application/vnd.vmware.admin.extensibility.selectors+xml" />
   <Enabled>false</Enabled>
   <Priority>1</Priority>
   <ObjectExtensionId>83...0d39</ObjectExtensionId>
   <Phases>
      <Phase  
         name="urn:extensionPoint:vm:gatherRequirements"  
         optional="true"  
         type="ASYNC" />
    </Phases>
</SelectorExtension>

The selector extension is added to the set of selector extensions associated with the specified object extension. You can retrieve a list of those selector extensions with a request to the object extension's extensibility.selectors link.

GET https://vcloud.example.com/api/admin/extension/object/83...0d39/selectorExtensions
...
<SelectorExtension  
   xmlns="http://www.vmware.com/vcloud/v1.5"  
   id="b3...f8ee"  
   href="https://vcloud.example.com/api/admin/providervdcs/extension/b3...f8ee" ...>
   ...
</SelectorExtension>