Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #8881: The database name and user can not be changed: rudder-web part #1173

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class SystemVariableServiceImpl(
, sharedFilesFolder : String
, webdavUser : String
, webdavPassword : String
, reportsDbUri : String
, reportsDbUser : String
, syslogPort : Int
, configurationRepository : String
, rudderServerRoleLdap : String
Expand All @@ -108,6 +110,14 @@ class SystemVariableServiceImpl(
, getSyslogProtocol : () => Box[SyslogProtocol]
) extends SystemVariableService with Loggable {

//get the Rudder reports DB (postgres) database name from URI
val reportsDbName = {
reportsDbUri.split("""/""").toSeq.lastOption.getOrElse(throw new IllegalArgumentException(
s"The JDBC URI configure for property 'rudder.jdbc.url' is malformed and should ends by /BASENAME: ${reportsDbUri}")
)
}


val varToolsFolder = systemVariableSpecService.get("TOOLS_FOLDER").toVariable().copyWithSavedValue(toolsFolder)
val varCmdbEndpoint = systemVariableSpecService.get("CMDBENDPOINT").toVariable().copyWithSavedValue(cmdbEndPoint)
val varWebdavUser = systemVariableSpecService.get("DAVUSER").toVariable().copyWithSavedValue(webdavUser)
Expand Down Expand Up @@ -363,15 +373,21 @@ class SystemVariableServiceImpl(
//IT IS VERY IMPORTANT TO SORT SYSTEM VARIABLE HERE: see ticket #4859
val varManagedNodesIp = systemVariableSpecService.get("MANAGED_NODES_IP").toVariable(children.flatMap(_.ips).distinct.sorted)

//Reports DB (postgres) DB name and DB user
val varReportsDBname = systemVariableSpecService.get("RUDDER_REPORTS_DB_NAME").toVariable(Seq(reportsDbName))
val varReportsDBuser = systemVariableSpecService.get("RUDDER_REPORTS_DB_USER").toVariable(Seq(reportsDbUser))

// the schedule must be the default one for policy server


Map(
varManagedNodes.spec.name -> varManagedNodes
, varManagedNodesId.spec.name -> varManagedNodesId
, varManagedNodesAdmin.spec.name -> varManagedNodesAdmin
, varManagedNodesIp.spec.name -> varManagedNodesIp
)
Seq(
varManagedNodes
, varManagedNodesId
, varManagedNodesAdmin
, varManagedNodesIp
, varReportsDBname
, varReportsDBuser
) map (x => (x.spec.name, x))
} else {
Map()
}
Expand Down
2 changes: 2 additions & 0 deletions rudder-web/src/main/scala/bootstrap/liftweb/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,8 @@ object RudderConfig extends Loggable {
, RUDDER_DIR_SHARED_FILES_FOLDER
, RUDDER_WEBDAV_USER
, RUDDER_WEBDAV_PASSWORD
, RUDDER_JDBC_URL
, RUDDER_JDBC_USERNAME
, RUDDER_SYSLOG_PORT
, RUDDER_DIR_GITROOT
, RUDDER_SERVER_ROLES_LDAP
Expand Down