Public bug reported: Instead of checking for int type and min value separately, utils.validate_integer method can be used.
for eg.: try: rotation = int(rotation) except ValueError: msg = _("createBackup attribute 'rotation' must be an integer") raise exc.HTTPBadRequest(explanation=msg) if rotation < 0: msg = _("createBackup attribute 'rotation' must be greater " "than or equal to zero") raise exc.HTTPBadRequest(explanation=msg) can be replaced with try: rotation = utils.validate_integer(rotation, "rotation", min_value=0) except exception.InvalidInput as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) ** Affects: nova Importance: Undecided Assignee: Rajesh Tailor (rajesh-tailor) Status: In Progress ** Changed in: nova Assignee: (unassigned) => Rajesh Tailor (rajesh-tailor) ** Changed in: nova Status: New => In Progress -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1465659 Title: Use utils.validate_integer for int validation Status in OpenStack Compute (Nova): In Progress Bug description: Instead of checking for int type and min value separately, utils.validate_integer method can be used. for eg.: try: rotation = int(rotation) except ValueError: msg = _("createBackup attribute 'rotation' must be an integer") raise exc.HTTPBadRequest(explanation=msg) if rotation < 0: msg = _("createBackup attribute 'rotation' must be greater " "than or equal to zero") raise exc.HTTPBadRequest(explanation=msg) can be replaced with try: rotation = utils.validate_integer(rotation, "rotation", min_value=0) except exception.InvalidInput as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1465659/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp