Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: setup: database: support get vdc option's versions ......................................................................
packaging: setup: database: support get vdc option's versions Change-Id: I4c36d59afbc502f0bb28b0bbad1315f4e9c65702 Signed-off-by: Alon Bar-Lev <[email protected]> --- M packaging/setup/ovirt_engine_setup/database.py 1 file changed, 39 insertions(+), 24 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/25102/1 diff --git a/packaging/setup/ovirt_engine_setup/database.py b/packaging/setup/ovirt_engine_setup/database.py index b1f9a14..155ef6e 100644 --- a/packaging/setup/ovirt_engine_setup/database.py +++ b/packaging/setup/ovirt_engine_setup/database.py @@ -195,6 +195,41 @@ self.logger.debug('Result: %s', ret) return ret + def getVdcOptionVersions( + self, + name, + type=str, + ownConnection=False, + ): + result = self.execute( + statement=""" + select version, option_value + from vdc_options + where option_name = %(name)s + """, + args=dict( + name=name, + ), + ownConnection=ownConnection, + ) + if len(result) == 0: + raise RuntimeError( + _('Cannot locate application option {name}').format( + name=name, + ) + ) + + return dict([ + ( + r['version'], + ( + r['option_value'] + if type != bool + else r['option_value'].lower() not in ('false', '0') + ) + ) for r in result + ]) + def getVdcOption( self, name, @@ -202,31 +237,11 @@ type=str, ownConnection=False, ): - result = self.execute( - statement=""" - select option_name, option_value - from vdc_options - where - option_name = %(name)s and - version = %(version)s - """, - args=dict( - name=name, - version=version, - ), + return self.getVdcOptionVersions( + name=name, + type=type, ownConnection=ownConnection, - ) - if len(result) != 1: - raise RuntimeError( - _('Cannot locate application option {name}').format( - name=name, - ) - ) - value = result[0]['option_value'] - if type == bool: - value = value.lower() not in ('false', '0') - - return value + )[version] def updateVdcOptions( self, -- To view, visit http://gerrit.ovirt.org/25102 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4c36d59afbc502f0bb28b0bbad1315f4e9c65702 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
