MetadataRegistry Interface
The MetadataRegistry interface is the runtime product metadata view into the target cloud service. Actual list of available options for resource components, filters, discriminators are dependent on multiple factors, such as who the calling user is and what options are visible to them or not. Due to this constraint, CPBM will use the metadata registry to query the target cloud service at runtime to determine exact set of options available for each case. This allows the service operator to make changes to available options without having to reflect that explicitly in CPBM.
- ResourceComponent
- A representation of ResourceComponent is used by the MetadataRegistry and is defined as follows:
public class ResourceComponent { public ResourceComponent(String resourceType, String name, String value, ResourceComponent parent, Map<String, String> attributes, Set<DisplayAttribute> displayAttributes); public String getResourceType(); public String getName(); public String getValue(); public Map<String, String> getAttributes(); public ResourceComponent getParent(); public Set<DisplayAttribute> getDisplayAttributes(); public String getAttributesString(); public String getDisplayAttributesString(); }
A ResourceComponent object is a representation of a resource component. It contains the following properties:- resourceType: The name of the resource type that this component is a part of
- name: The service defined name of this component option
- value: The service defined value that needs to be passed back to the service to provision a resource with this component
- attributes: additional descriptors for that resource component, if any.
- parent: can usually be null, but under some advanced use cases, resource components may be derived from another resource component. This field defines the parent
A new field has been added in ResourceComponent, called displayAttributes. This is a set of name-value pairs (DisplayAttribute), used to show additional details for a given ResourceComponent in the following places:- While adding or editing provisioning constraints for a Product Bundle.
- While end user provisions a resource using the default UI. (can also be used by connector in custom UI).
The getDisplayAttributesString() is a helper method which returns a comma separated string representation of displayAttributes field.
FilterComponent
public class FilterComponent{ public FilterComponent(String name, String value, Map<String, String> attributes, Set<DisplayAttribute> displayAttributes); public String getName(); public String getValue(); public Map<String, String> getAttributes(); public Set<DisplayAttribute> getDisplayAttributes(); public String getAttributesString(); public String getDisplayAttributesString(); }
The getFilterValues() method has been updated, it now returns a list of filterComponent.
- MetadataRegistry
- The MetadataRegistry as we described earlier is used by CPBM to query the underlying service at runtime to determine dynamically the value space for resource component options, filters, discriminators etc. The metadata registry itself will be used in three different contexts and it is important to understand these. They are:
- At product management time: In order to set pricing, it is important for CPBM to understand the various resource type component options, filter options, possible discriminator attribute values. These help CPBM build the products, define their mediation rules and define product bundles and any constraints they may want to specify.
- At provisioning time: When provisioning a resource type, the user will have to select specific resource component values (optionally filtered by the available filters) for each resource component. The actual list of options can vary depending on the user, account, filter selections or other resource component selections. Resource types may not have components or variations. Selection of product bundles that can be subscribed to will match these selections with bundle constraints to show the set of bundles that match the selections.
- At mediation time: At mediation time, usage can be received for a specific resource type with specific resource component values. At that time, CPBM will need to determine ancestry of resource components to correctly bucket usage into appropriate products. CPBM will query the MetadataRegistry to determine this ancestry.
public interface BaseMetadataRegistry { public List<FilterComponent> getFilterValues(String tenantHandle, String userHandle, String name); public Map<String, String> getDiscriminatorValues(String name); public List<ResourceComponent> getResourceComponentValues(String resourceType, String name); public List<ResourceComponent> getResourceComponentValues(String resourceType, String name, String tenantHandle, String userHandle, Map<String, String> context, Map<String, String> filters); public ResourceComponent getResourceComponent(String resourceType, String resourceComponent, String componentValue); }
public interface MetadataRegistry extends BaseMetadataRegistry { @Deprecated public Map<String, String> getResourceTypeValues(String tenantHandle, String userHandle, String name,Map<String, String> context, Map<String, String> filters); }
DynamicResourceTypeMetadataRegistry will enable the connector to filter out resource types dynamically from the static super set of resource types defined in the service definition. When invoked from the product management, CPBM will pass the portal tenant handle and user handles. Else, it will be the respective tenant and user handle.public interface DynamicResourceTypeMetadataRegistry extends BaseMetadataRegistry { public List<String> getResourceTypes(String tenantHandle, String userHandle); }
- getResourceComponentValues
- This method is overloaded for two different contexts. One is used in product management while the other is used at provisioning time.
The first form is called when the operator is defining products to determine the list of system defined resource components. In this form, ancestry is not important (and will be ignored), as ancestry is typically relevant only during provisioning (for price display) and mediation. Also, in this form, the connector may return sentinel values (such as -1) to designate classes of resource components that are available only to a specific custom scope (since the actual resource component options are known only when the scope is defined. For example, you may want to use -1 to designate all user defined templates. The actual list of user defined templates, of course, can only be known given the user). This form is used to build product mediation rules that use resource component values as discriminators.
The second form is used during provisioning. At this time, the account, user, any other components that have already been selected and any filters applied are known to the system and will be passed to the call. Based on these parameters, the implementation should return a list of specific resource components that are available to be used for provisioning this resource type. In the case of IaaS, for example, this may include user defined templates, templates owned by users, but derived from system templates, zone or account specific templates etc.
- getFilterValues
- This method is called during product management to use filters as usage discriminators as well as during provisioning to filter out resource components. It should basically return a list of legal values for that filter that can be used to filter a resource component or categorize usage with. For example, you may declare availability zone as a filter and this method would return the current list of availability zones.
- getDiscriminatorValues
- getDiscriminatorValues works similar to getFilterValues and returns possible values for a given discriminator attribute. This is typically called only during product management. It may return null, which would indicate that the actual discriminator value space is not static or cannot be determined. In this case, CPBM will assume the value space is undefined and allow the operator to enter free form text. The actual value of course, will have to match the values that are configured by the operator for that usage type. For example, this may be used to discriminate volume usage based on storage pool tags (the list of tags potentially being infinite and not formally defined).
- getResourceTypes
- This method is overloaded for two different contexts. One is used in product management, while the other is used at the time of provisioning.
The first form is called when the operator is creating product Bundle, listing anonymous catalog or while previewing catalog from channels. In this form, CPBM will pass portal's system tenant handle and user handle to the connector and connector will return list of resource type name available for that service instance from the set of resource type defined in service definition.
In the second form it will be called when end user is listing catalog. In this case,CPBM will pass end user's tenant handle and user handle and the connector will return the resource type available for that particular tenant user from the set of resource type defined in service definition.
Comments