Created 07-21-2016 11:42 PM
I am trying to setup a new custom service, and I would like to be able to update Ambari's view of the configuration from the python script. However, when I try to set a value (e.g. Script.get_config()['configurations']['my-config-file']['my-property'] = "some data"), I see an error telling me I cannot update the immutable config dict.
I see some methods in the Ambari python resource_management.core source such as "update_config", "set_params", etc. that seem like they might be what I need, but they are not well documented.
The Ambari REST API is not an option either, unless I can determine the Ambari username/password from inside the script.
Is there a good way for me to set a property from within the python script?
Created 07-21-2016 11:44 PM
It can be done via Stack Advisor. Does that option work for you ?
Created 07-21-2016 11:50 PM
Yes, I think that'll work. Can you point me to the relevant documentation?
Created 07-23-2016 08:53 PM
@Ben Weintraub Thanks for confirming.
- In order to go the Stack Advisor route, check the stack and version on which you are trying to support/add this service.
Lets take example of HDP stack 2.5 and service as HIVE.
File path : https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...
Lets say you are adding service named 'myService' in HDP 2.5 stack. You may name you recommendation fn. as "recommendMyServiceConfigurations". You will add this fn. to the dictionary here :
- After that you will write definition for your function "recommendMyServiceConfigurations()", reference fn.:
The way to deposit value for the config can be referred here as :
I assume that you will have relevant config file (.xml) associated with your service, of which configuration that you intend to set/modify is part of. Lets say its name is 'myService-site.xml'.
After that, if this config change is made dependent on any other config change, you need to add depends-on tag. Eg: if you intend to change configs 'A' based on change in config 'B', you may do like this:
<property> <name>A</name> <value>some_value</value> <description></description> <depends-on> <property> <type>B-config_site-name</type> <name>B</name> </property> </depends-on> </property>
For reference, see : https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...
- In case there is no explicit dependency possible, you may need to do the forced-configuration use, as otherwise Stack Advisor will filter the recommendation made. You will add the config 'A' in to 'forced-configuration', so that Stack Advisor doesn't filter it out while sending recommendations. Reference:
and then the same way you will deposit value, as mentioned earlier.
For testing while while development, you may put debugs to see we are hitting the code and eventually depositing value to config. Finally, whether the recommendation actually made way to UI, you can do it by doing inspect element on browser. Example browser on Chrome, and we are have set the value for config 'hive.llap.daemon.yarn.container.mb' on same lines as mentioned above.
screen-shot-2016-07-23-at-20146-pm.png
Let me know if you run into any issues and the stage you are at while developing/testing.
Created 10-14-2016 03:11 PM
I have similar issue
Can you please guide?