diff --git a/oslo_utils/netutils.py b/oslo_utils/netutils.py index 4b203d7..ca4de9b 100644 --- a/oslo_utils/netutils.py +++ b/oslo_utils/netutils.py @@ -177,19 +177,6 @@ def is_valid_ip(address): return is_valid_ipv4(address) or is_valid_ipv6(address) -def is_valid_port(port): - """Verify that port represents a valid port number. - - .. versionadded:: 1.1.1 - """ - try: - val = int(port) - except (ValueError, TypeError): - return False - - return (val > 0 and val <= 65535) - - def _is_int_in_range(value, start, end): """Try to convert value to int and check if it lies within range 'start' to 'end'. @@ -206,6 +193,17 @@ def _is_int_in_range(value, start, end): return (start <= val <= end) +def is_valid_port(port): + """Verify that port represents a valid port number. + + Port can be valid integer having a value of 1 up to and + including 65535. + + .. versionadded:: 1.1.1 + """ + return _is_int_in_range(port, 1, 65535) + + def is_valid_icmp_type(type): """Verify if ICMP type is valid.