Simone Tiraboschi has uploaded a new change for review. Change subject: packaging: setup: checking required vCPU number against available cores ......................................................................
packaging: setup: checking required vCPU number against available cores Checking the number of required vCPU against the number of available cores to prevent further failures. Change-Id: Id15778a7c3234221260bc8cea10997bf5e1595ed Bug-Url: https://bugzilla.redhat.com/1198581 Signed-off-by: Simone Tiraboschi <[email protected]> --- M src/plugins/ovirt-hosted-engine-setup/vm/cpu.py 1 file changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/72/38372/1 diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py b/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py index c654bc4..b57e182 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py @@ -45,6 +45,13 @@ def __init__(self, context): super(Plugin, self).__init__(context=context) + def _getMaxVCpus(self): + cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + caps = cli.getVdsCapabilities() + if caps['status']['code'] != 0: + raise RuntimeError(caps['status']['message']) + return caps['info']['cpuCores'] + @plugin.event( stage=plugin.Stages.STAGE_INIT, ) @@ -72,6 +79,7 @@ ohostedcons.VMEnv.VCPUS ] is None valid = False + maxvcpus = int(self._getMaxVCpus()) while not valid: if interactive: self.environment[ @@ -111,6 +119,24 @@ ) == _('Yes').lower() ): valid = False + if int( + self.environment[ohostedcons.VMEnv.VCPUS] + ) > maxvcpus: + message = _( + 'Invalid number of cpu specified: {vcpu}, ' + 'while only {maxvcpus} are available on ' + 'the host' + ).format( + vcpu=self.environment[ + ohostedcons.VMEnv.VCPUS + ], + maxvcpus=maxvcpus + ) + if interactive: + self.logger.warning(message) + valid = False + else: + raise RuntimeError(message) except ValueError: valid = False if not interactive: -- To view, visit https://gerrit.ovirt.org/38372 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id15778a7c3234221260bc8cea10997bf5e1595ed Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Simone Tiraboschi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
