void updateAgentConfigurationFile ( TargetHandlerParameters parameters , SSHClient ssh , File tmpDir , Map < String , String > keyToNewValue ) throws IOException { this . logger . fine ( "Updating agent parameters on remote host..." ) ; // Update the agent's configuration file String agentConfigDir = Utils . getValue ( parameters . getTargetProperties ( ) , SCP_AGENT_CONFIG_DIR , DEFAULT_SCP_AGENT_CONFIG_DIR ) ; File localAgentConfig = new File ( tmpDir , Constants . KARAF_CFG_FILE_AGENT ) ; File remoteAgentConfig = new File ( agentConfigDir , Constants . KARAF_CFG_FILE_AGENT ) ; // Download remote agent config file... ssh . newSCPFileTransfer ( ) . download ( remoteAgentConfig . getCanonicalPath ( ) , new FileSystemFile ( tmpDir ) ) ; // Replace "parameters" property to point on the user data file... String config = Utils . readFileContent ( localAgentConfig ) ; config = Utils . updateProperties ( config , keyToNewValue ) ; Utils . writeStringInto ( config , localAgentConfig ) ; // Then upload agent config file back ssh . newSCPFileTransfer ( ) . upload ( new FileSystemFile ( localAgentConfig ) , agentConfigDir ) ; }
Updates the configuration file of an agent .