[
https://issues.apache.org/jira/browse/AMBARI-10306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14391646#comment-14391646
]
Tom Beerbower commented on AMBARI-10306:
----------------------------------------
*Cluster Association Usage*
# The view developer indicates that a parameter is configurable through cluster
association by using the <cluster-config> element in the view descriptor. The
cluster configuration is given in the form {{configuration type/configuration
key}}. For example, ...{code}
<parameter>
<name>http-address</name>
<description>The http-address.</description>
<cluster-config>hdfs-site/dfs.namenode.http-address</cluster-config>
<required>false</required>
</parameter>
{code}
# The API user can see that a parameter is tagged as cluster configuration by
looking at the parameters of the view version resource. For example, ... {code}
{
"href" :
"http://c6401.ambari.apache.org:8080/api/v1/views/MYVIEW/versions/1.0.0/",
"ViewVersionInfo" : {
...
"cluster_configurable" : true,
...
"parameters" : [
{
"name" : "http-address",
"description" : "The http-address. Defaults to \"default value\".",
"label" : null,
"placeholder" : null,
"defaultValue" : "default value",
"clusterConfig" : "hdfs-site/dfs.namenode.http-address",
"required" : false,
"masked" : false
}
], ...
{code}Note that the parameter contains a cluster configuration value. Also
note that the view version is tagged as "cluster configurable" since it
contains at least one parameter that may be configured through association with
a cluster.
# The view instance may be associated with a cluster instance. This is done by
assigning a cluster handle to the view instance. For a local cluster reference
(view and cluster managed by the same Ambari server) the cluster handle is
simply the unique cluster name. Currently only a local association is
supported. The API to set the cluster handle is a POST on a view instance.
For example ... {code}
POST api/v1/views/MYVIEW/versions/1.0.0/instances/INSTANCE1
{
"ViewInstanceInfo" : {
"cluster_handle" : "c1"
}
}
{code}
# The cluster association can be checked by doing a GET on a view instance.
For example ... {code}
GET api/v1/views/MYVIEW/versions/1.0.0/instances/INSTANCE1
...
{
"href" :
"http://c6401.ambari.apache.org:8080/api/v1/views/MYVIEW/versions/1.0.0/instances/INSTANCE1",
"ViewInstanceInfo" : {
"cluster_handle" : "c1",
...
{code}
# Once a cluster association is set on a view instance then the view code
accessing the properties should see the cluster-config properties with values
from the cluster's configuration. For example, in the view code ... {code}
ViewContext viewContext;
...
Map<String, String> properties = viewContext.getProperties();
String httpAddress = properties.get("http-address");
// httpAddress should come from cluster "c1", configuration
"hdfs-site/dfs.namenode.http-address"
{code}
# The view code may also access the cluster configuration directly without
assigning it to a view parameter. For example, in the view code ... {code}
ViewContext viewContext;
...
Map<String, String> properties = viewContext.getProperties();
Cluster cluster = viewContext.getCluster();
if (cluster != null) { // view instance is associated with a cluster
String httpAddress = cluster.getConfigurationValue("hdfs-site",
"dfs.namenode.http-address");
// httpAddress should come from cluster "c1", configuration
"hdfs-site/dfs.namenode.http-address"
}
{code}
> Views: Ability for a view instance to be associated to a cluster for
> configuration
> ----------------------------------------------------------------------------------
>
> Key: AMBARI-10306
> URL: https://issues.apache.org/jira/browse/AMBARI-10306
> Project: Ambari
> Issue Type: Task
> Reporter: Tom Beerbower
> Assignee: Tom Beerbower
> Fix For: 2.1.0
>
> Attachments: AMBARI-10306.patch
>
>
> Ability for a view instance to be associated to a cluster for configuration
> (so the view can have access to cluster config information via view context).
> This enables the view instance to be configured w/o the admin having to
> wire-up properties. Whether the view is auto instantiated or instantiated
> manually, the Ambari Admin should have an option to relate an instance of a
> cluster to the view instance. This make the cluster config information
> available to the view so the view can "auto-configure". Therefore, in
> addition to today's manual configure option, need to add options for picking
> a cluster in same ambari, or picking remote ambari server to
> "auto-configure". Based on the configuration option the user chooses, the
> way the user gets configuration changes. If the user chooses today mode of
> config, they can use the same ViewContext.getProperties() as they do today.
> If they choose a local cluster, they need a way to get access to all cluster
> configurations. For remote cluster, maybe we just provide convenient method
> way to get rest endpoint to the cluster resource to limit scope? In any of
> the three cases, the view developer needs to know how he is to get his
> configurations (custom, local or remote), and have a way to get access via
> ViewContext. Also, need ability to flag properties as cluster "configuration"
> or "setting" so the UI can organize properties that can be derived from
> cluster configuration properties vs. settings props related to the view
> itself.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)