summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/snmp.py
diff options
context:
space:
mode:
authorZhenguo Niu <niuzhenguo@huawei.com>2015-11-12 23:25:30 +0800
committerZhenguo Niu <niuzhenguo@huawei.com>2015-11-19 09:23:33 +0800
commit750393821fa8a894127862d2d7bc72976bc9985b (patch)
treebc648448e5c3ae701430b1c661179f0f3f9e9ace /ironic/drivers/modules/snmp.py
parent7e5f6788780b51eaaf5c6dbdac1826be721cff39 (diff)
downloadironic-750393821fa8a894127862d2d7bc72976bc9985b.tar.gz
Validate all tcp/udp port numbers
We introduced a common port validation method validate_network_port, this patch try to validate all port parameters using it. Change-Id: I209b89d2a4c2bbc5619d058f78da2f5f76d1723c
Diffstat (limited to 'ironic/drivers/modules/snmp.py')
-rw-r--r--ironic/drivers/modules/snmp.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/ironic/drivers/modules/snmp.py b/ironic/drivers/modules/snmp.py
index 33e02dbae..1eb7c9eaf 100644
--- a/ironic/drivers/modules/snmp.py
+++ b/ironic/drivers/modules/snmp.py
@@ -40,6 +40,7 @@ from ironic.common import exception
from ironic.common.i18n import _
from ironic.common.i18n import _LW
from ironic.common import states
+from ironic.common import utils
from ironic.conductor import task_manager
from ironic.drivers import base
@@ -603,11 +604,8 @@ def _parse_driver_info(node):
# In absence of a configured UDP port, default to the standard port
port_str = info.get('snmp_port', SNMP_PORT)
- try:
- snmp_info['port'] = int(port_str)
- except ValueError:
- raise exception.InvalidParameterValue(_(
- "SNMPPowerDriver: SNMP UDP port must be numeric: %s") % port_str)
+ snmp_info['port'] = utils.validate_network_port(port_str, 'snmp_port')
+
if snmp_info['port'] < 1 or snmp_info['port'] > 65535:
raise exception.InvalidParameterValue(_(
"SNMPPowerDriver: SNMP UDP port out of range: %d")