Bug 534460 (RHQ-1253)
Summary: | allow agent to change its preferences node without user having to edit agent-configuration.xml | ||
---|---|---|---|
Product: | [Other] RHQ Project | Reporter: | John Mazzitelli <mazz> |
Component: | Agent | Assignee: | John Mazzitelli <mazz> |
Status: | CLOSED NEXTRELEASE | QA Contact: | Jeff Weiss <jweiss> |
Severity: | medium | Docs Contact: | |
Priority: | low | ||
Version: | unspecified | CC: | dajohnso |
Target Milestone: | --- | Keywords: | FutureFeature |
Target Release: | --- | ||
Hardware: | All | ||
OS: | All | ||
URL: | http://jira.rhq-project.org/browse/RHQ-1253 | ||
Whiteboard: | |||
Fixed In Version: | 1.2 | Doc Type: | Enhancement |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | Type: | --- | |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
John Mazzitelli
2008-12-12 14:24:00 UTC
we might not even need a tmp .xml file - just store the processed XML content in memory and stream it to the Java Preferences API (assuming the API takes a stream - would have to look at it to make sure). Java Prefs API has this: http://java.sun.com/j2se/1.4.2/docs/api/java/util/prefs/Preferences.html#importPreferences(java.io.InputStream) The more I think about this, the more I think this could be very easy to implement. 1) load in the .xml like we do today 2) run the xml content through a pre-processor that simply replaces ${} with system prop values 3) pass to preferences API We already do 1 and 3 - just need to insert 2. DOH! I knew it wasn't this easy. I'm getting flashbacks - this is the same train of thought I was on long ago when I tried fixing this. The rhq.agent.name isn't set until after the config is loaded (the rhq.agent.name IS in preferences - chicken and egg, can't get prefs until you have a pref value to tell you where the prefs are stored?) Need to figure out some other key to use - hostname may or may not a good alternative. How would the agent get the hostname (Java API I assume)? Using hostname limits us to running a single agent on a box (in testing environment, we can run 100 or more on the same box) Idea: rhq-agent-env.sh: RHQ_AGENT_CMDLINE_OPTS=--daemon -Drhq.agent.preference-node=`hostname` agent-configuration.xml: <node name="${rhq.agent.preferences-node}"> The user can use whatever value they want. `hostname` or "helloworld" or whatever. Better yet, why not just use the cmdline option we already have: rhq-agent.sh --pref=`hostname` or, in rhq-agent-env.sh: RHQ_AGENT_CMDLINE_OPTS=--pref=`hostname` Our code is already looking for this option, we just take it and set an internal system property (call it rhq.agent.preference-node), and replace it in the agent-configuration.xml, assuming the .xml has: <node name=${rhq.agent.preference-node}> Yes... I think that might work. We would just have to go through all the agent-configuration.xml files in SVN, and change the name="default" to name="${rhq.agent.preference-node}" and make sure whenever the agent uses this .xml, it pre-processes it first. i think we can fix rhq-11 once this is added --pref now can be specified without editing the config .xml by hand. the pref node name is replaced with the value of your given pref node, default is still "default". To test: 1) shutdown any agent running 2) delete any perferences location (on windows, purge the registry entries for rhq-agent, on UNIX, delete the $HOME/.java directory) - this starts clean for you 3) Start the agent with the --pref option (--pref=testing) 4) now go into the registry (if windows) or $HOME/.java (if UNIX) and look for the "testing" node - you shoudl see the testing node and NOT the node named "default" Verified that using the "pref" option causes the agent to save and load its prefs from the specified properties. rev2561, linux This bug was previously known as http://jira.rhq-project.org/browse/RHQ-1253 This bug incorporates RHQ-11 |