Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: setup: fix provisioning new database detection ......................................................................
packaging: setup: fix provisioning new database detection 1. check for new database at the designated database and not template1. 2. apply database provisioning before pgpass creation. 3. cleanup logic of detecting database rename. Change-Id: I6ff8520556aa04c4d9d8d4f1f7c4094b57f8fb11 Signed-off-by: Alon Bar-Lev <[email protected]> --- M packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py 1 file changed, 21 insertions(+), 19 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/19378/1 diff --git a/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py b/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py index 8ffd72a..c4f5219 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py +++ b/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py @@ -242,8 +242,6 @@ raise def _setDatabaseResources(self, environment): - existing = False - dbstatement = database.Statement( environment=environment, ) @@ -276,24 +274,27 @@ transaction=False, )[0]['count'] != 0 - if hasDatabase and hasUser: - try: - dbovirtutils = database.OvirtUtils( - plugin=self, - environment=environment, - ) - if not dbovirtutils.isNewDatabase(): - raise RuntimeError( - _('Not new database') - ) - self.logger.debug('Using existing empty database') - existing = True - except RuntimeError: - self.logger.debug( - 'Error while trying to connect to existing database' - ) + generate = hasDatabase or hasUser + existing = False - if not existing and (hasDatabase or hasUser): + if hasDatabase and hasUser: + dbovirtutils = database.OvirtUtils( + plugin=self, + environment=environment, + ) + if dbovirtutils.isNewDatabase( + database=self.environment[ + osetupcons.DBEnv.DATABASE + ], + ): + self.logger.debug('Found empty database') + generate = False + existing = True + else: + generate = True + + if generate: + self.logger.debug('Existing resources found, generating names') suffix = '_%s' % datetime.datetime.now().strftime('%Y%m%d%H%M%S') self.environment[osetupcons.DBEnv.DATABASE] += suffix self.environment[osetupcons.DBEnv.USER] += suffix @@ -526,6 +527,7 @@ @plugin.event( stage=plugin.Stages.STAGE_MISC, before=( + osetupcons.Stages.DB_CREDENTIALS_AVAILABLE_LATE, osetupcons.Stages.DB_SCHEMA, ), after=( -- To view, visit http://gerrit.ovirt.org/19378 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ff8520556aa04c4d9d8d4f1f7c4094b57f8fb11 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
