Skip to content

Commit

Permalink
Refactor PKIDeployer.import_master_config()
Browse files Browse the repository at this point in the history
The PKIDeployer.import_master_config() has been modified such
that it will be executed during cloning, but it will only
retrieve and validate database config params from the master
if they are needed to set up DS replication.
  • Loading branch information
edewata committed Aug 4, 2023
1 parent 79e13b5 commit dbab6ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
41 changes: 24 additions & 17 deletions base/server/python/pki/server/deployment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,16 +1386,21 @@ def import_master_config(self, subsystem):

logger.info('Retrieving config params from %s master', subsystem.type)

names = [
'internaldb.ldapauth.password',
'internaldb.replication.password'
]
names = []
substores = []

substores = [
'internaldb',
'internaldb.ldapauth',
'internaldb.ldapconn'
]
if config.str2bool(self.mdict['pki_ds_setup']):

names.extend([
'internaldb.ldapauth.password',
'internaldb.replication.password'
])

substores.extend([
'internaldb',
'internaldb.ldapauth',
'internaldb.ldapconn'
])

tags = subsystem.config['preop.cert.list'].split(',')
for tag in tags:
Expand Down Expand Up @@ -1424,18 +1429,20 @@ def import_master_config(self, subsystem):
substores,
session_id=self.install_token.token)

logger.info('Validating %s master config params', subsystem.type)

master_properties = master_config['Properties']

master_hostname = master_properties['internaldb.ldapconn.host']
master_port = master_properties['internaldb.ldapconn.port']
if config.str2bool(self.mdict['pki_ds_setup']):

logger.info('Validating %s master config params', subsystem.type)

master_hostname = master_properties['internaldb.ldapconn.host']
master_port = master_properties['internaldb.ldapconn.port']

replica_hostname = subsystem.config['internaldb.ldapconn.host']
replica_port = subsystem.config['internaldb.ldapconn.port']
replica_hostname = subsystem.config['internaldb.ldapconn.host']
replica_port = subsystem.config['internaldb.ldapconn.port']

if master_hostname == replica_hostname and master_port == replica_port:
raise Exception('Master and replica must not share LDAP database')
if master_hostname == replica_hostname and master_port == replica_port:
raise Exception('Master and replica must not share LDAP database')

logger.info('Importing %s master config params', subsystem.type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,15 @@ def spawn(self, deployer):

subsystem.save()

if clone:
master_config = deployer.import_master_config(subsystem)
else:
master_config = None

if config.str2bool(deployer.mdict['pki_ds_setup']):

if clone:
deployer.request_ranges(subsystem)
master_config = deployer.import_master_config(subsystem)
else:
master_config = None

deployer.setup_database(subsystem, master_config)

Expand Down

0 comments on commit dbab6ac

Please sign in to comment.