diff --git a/rudder-core/src/main/scala/com/normation/rudder/services/policies/SystemVariableService.scala b/rudder-core/src/main/scala/com/normation/rudder/services/policies/SystemVariableService.scala index cfa222d5cea..7d44cec795e 100644 --- a/rudder-core/src/main/scala/com/normation/rudder/services/policies/SystemVariableService.scala +++ b/rudder-core/src/main/scala/com/normation/rudder/services/policies/SystemVariableService.scala @@ -101,6 +101,7 @@ class SystemVariableServiceImpl( , getCfengineOutputsTtl : () => Box[Int] , getStoreAllCentralizedLogsInFile: () => Box[Boolean] , getSendMetrics : () => Box[Option[Boolean]] + , getReportProtocol : () => Box[String] ) extends SystemVariableService with Loggable { val varToolsFolder = systemVariableSpecService.get("TOOLS_FOLDER").toVariable().copyWithSavedValue(toolsFolder) @@ -136,6 +137,7 @@ class SystemVariableServiceImpl( val skipIdentify = getProp("SKIPIDENTIFY", getSkipIdentify) val modifiedFilesTtl = getProp("MODIFIED_FILES_TTL", getModifiedFilesTtl) val cfengineOutputsTtl = getProp("CFENGINE_OUTPUTS_TTL", getCfengineOutputsTtl) + val reportProtocol = getProp("REPORT_PROTOCOL", getReportProtocol) val sendMetricsValue = if (getSendMetrics().getOrElse(None).getOrElse(false)) { "yes" @@ -177,6 +179,7 @@ class SystemVariableServiceImpl( cfengineOutputsTtl :: storeAllCentralizedLogsInFile :: varSendMetrics :: + reportProtocol :: Nil vars.map(v => (v.spec.name,v)).toMap } diff --git a/rudder-web/src/main/scala/bootstrap/liftweb/AppConfig.scala b/rudder-web/src/main/scala/bootstrap/liftweb/AppConfig.scala index b39aabd41ae..715cb56bdac 100644 --- a/rudder-web/src/main/scala/bootstrap/liftweb/AppConfig.scala +++ b/rudder-web/src/main/scala/bootstrap/liftweb/AppConfig.scala @@ -1267,6 +1267,7 @@ object RudderConfig extends Loggable { , configService.cfengine_outputs_ttl _ , configService.rudder_store_all_centralized_logs_in_file _ , configService.send_server_metrics _ + , configService.report_protocol _ ) private[this] lazy val rudderCf3PromisesFileWriterService = new RudderCf3PromisesFileWriterServiceImpl( techniqueRepositoryImpl, diff --git a/rudder-web/src/main/scala/com/normation/rudder/appconfig/ConfigService.scala b/rudder-web/src/main/scala/com/normation/rudder/appconfig/ConfigService.scala index 5bf8f62c756..ee438e2dda6 100644 --- a/rudder-web/src/main/scala/com/normation/rudder/appconfig/ConfigService.scala +++ b/rudder-web/src/main/scala/com/normation/rudder/appconfig/ConfigService.scala @@ -133,6 +133,11 @@ trait ReadConfigService { */ def send_server_metrics(): Box[Option[Boolean]] + /** + * Report protocol + */ + def report_protocol(): Box[String] + } /** @@ -201,6 +206,11 @@ trait UpdateConfigService { def set_rudder_compliance_heartbeatPeriod(frequency : Int, actor: EventActor, reason: Option[String]) : Box[Unit] + /** + * Report protocol + */ + def set_report_protocol(value : String): Box[Unit] + } class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workflowUpdate: AsyncWorkflowInfo) extends ReadConfigService with UpdateConfigService with Loggable { @@ -229,6 +239,7 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl send.server.metrics=none rudder.compliance.mode=${FullCompliance.name} rudder.compliance.heartbeatPeriod=1 + rudder.reports.protocol=tcp """ val configWithFallback = configFile.withFallback(ConfigFactory.parseString(defaultConfig)) @@ -392,4 +403,11 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl save("send_server_metrics",newVal,Some(info)) } + + /** + * Report protocol + */ + def report_protocol(): Box[String] = get("rudder_reports_protocol") + def set_report_protocol(value : String): Box[Unit] = save("rudder_reports_protocol", value) + } diff --git a/rudder-web/src/main/scala/com/normation/rudder/web/snippet/administration/PropertiesManagement.scala b/rudder-web/src/main/scala/com/normation/rudder/web/snippet/administration/PropertiesManagement.scala index 8db2356f5c0..e67f7f4c518 100644 --- a/rudder-web/src/main/scala/com/normation/rudder/web/snippet/administration/PropertiesManagement.scala +++ b/rudder-web/src/main/scala/com/normation/rudder/web/snippet/administration/PropertiesManagement.scala @@ -83,6 +83,7 @@ class PropertiesManagement extends DispatchSnippet with Loggable { case "cfengineGlobalProps" => cfengineGlobalProps case "loggingConfiguration" => loggingConfiguration case "sendMetricsConfiguration" => sendMetricsConfiguration + case "networkProtocolSection" => networkProtocolSection } @@ -469,6 +470,45 @@ class PropertiesManagement extends DispatchSnippet with Loggable { ) apply (xml ++ Script(Run("correctButtons();") & check())) } + def networkProtocolSection = { xml : NodeSeq => + // initial values, updated on successfull submit + var initReportsProtocol = configService.report_protocol + var reportProtocol = initReportsProtocol.getOrElse("tcp") + def check() = { + S.notice("updateNetworkProtocol","") + Run(s"""$$("#networkProtocolSubmit").button( "option", "disabled",${initReportsProtocol.map(_ == reportProtocol).getOrElse(false)});""") + } + + def submit = { + configService.set_report_protocol(reportProtocol).foreach(updateOk => initReportsProtocol = Full(reportProtocol)) + + // start a promise generation, Since we check if there is change to save, if we got there it mean that we need to redeploy + startNewPolicyGeneration + S.notice("updateNetworkProtocol","Network protocol options correctly updated") + check() + } + + ( "#reportProtocol" #> { + initReportsProtocol match { + case Full(value) => + SHtml.ajaxCheckbox( + value == "udp" + , (b : Boolean) => { reportProtocol = if (b) "udp" else "tcp"; check() } + , ("id","reportProtocol") + ) + case eb: EmptyBox => + val fail = eb ?~ "there was an error while fetching value of property: 'Report protocol' " +
{fail.msg}
+ } + } & + + "#networkProtocolSubmit " #> { + SHtml.ajaxSubmit("Save changes", submit _) + } + ) apply (xml ++ Script(Run("correctButtons();") & check())) + + } + val agentScheduleEditForm = new AgentScheduleEditForm( getSchedule , saveSchedule diff --git a/rudder-web/src/main/webapp/secure/administration/policyServerManagement.html b/rudder-web/src/main/webapp/secure/administration/policyServerManagement.html index 149ebf3fae1..6ca4f4a5951 100644 --- a/rudder-web/src/main/webapp/secure/administration/policyServerManagement.html +++ b/rudder-web/src/main/webapp/secure/administration/policyServerManagement.html @@ -118,6 +118,31 @@

Security


+
+

Protocol

+
+
+
+ + +
+
+ + [messages] +
+
+
+