def test__parse_driver_info_invalid_driver(self): # Make sure exception is raised when the driver type is invalid. info = db_utils.get_test_snmp_info(snmp_driver='invalidpower') node = self._get_test_node(info) self.assertRaises(exception.InvalidParameterValue, snmp._parse_driver_info, node)
def test__parse_driver_info_snmp_v1(self): # Make sure SNMPv1 is parsed with a community string. info = db_utils.get_test_snmp_info(snmp_version='1', snmp_community='public') node = self._get_test_node(info) info = snmp._parse_driver_info(node) self.assertEqual('1', info.get('version')) self.assertEqual('public', info.get('community'))
def test__parse_driver_info_missing_security(self): # Make sure exception is raised when security is missing with SNMPv3. info = db_utils.get_test_snmp_info(snmp_version='3') del info['snmp_security'] node = self._get_test_node(info) self.assertRaises(exception.MissingParameterValue, snmp._parse_driver_info, node)
def test__parse_driver_info_snmp_v3(self): # Make sure SNMPv3 is parsed with a security string. info = db_utils.get_test_snmp_info(snmp_version='3', snmp_security='pass') node = self._get_test_node(info) info = snmp._parse_driver_info(node) self.assertEqual('3', info.get('version')) self.assertEqual('pass', info.get('security'))
def test__parse_driver_info_invalid_version(self): # Make sure exception is raised when version is invalid. info = db_utils.get_test_snmp_info(snmp_version='42', snmp_community='public', snmp_security='pass') node = self._get_test_node(info) self.assertRaises(exception.InvalidParameterValue, snmp._parse_driver_info, node)
def test__parse_driver_info_teltronix(self): # Make sure the Teltronix driver type is parsed. info = db_utils.get_test_snmp_info(snmp_driver='teltronix') node = self._get_test_node(info) info = snmp._parse_driver_info(node) self.assertEqual('teltronix', info.get('driver'))
def test__parse_driver_info_eatonpower(self): # Make sure the Eaton Power driver type is parsed. info = db_utils.get_test_snmp_info(snmp_driver='eatonpower') node = self._get_test_node(info) info = snmp._parse_driver_info(node) self.assertEqual('eatonpower', info.get('driver'))
def test__parse_driver_info_apc(self): # Make sure the APC driver type is parsed. info = db_utils.get_test_snmp_info(snmp_driver='apc') node = self._get_test_node(info) info = snmp._parse_driver_info(node) self.assertEqual('apc', info.get('driver'))
def test__parse_driver_info_snmp_port(self): # Make sure non-default SNMP UDP port numbers can be configured info = db_utils.get_test_snmp_info(snmp_port='10161') node = self._get_test_node(info) info = snmp._parse_driver_info(node) self.assertEqual(10161, info.get('port'))
from oslo.config import cfg from ironic.common import exception from ironic.common import states from ironic.conductor import task_manager from ironic.db import api as db_api from ironic.drivers.modules import snmp as snmp from ironic.openstack.common import context from ironic.tests import base from ironic.tests.conductor import utils as mgr_utils from ironic.tests.db import base as db_base from ironic.tests.db import utils as db_utils from ironic.tests.objects import utils as obj_utils CONF = cfg.CONF INFO_DICT = db_utils.get_test_snmp_info() class SNMPValidateParametersTestCase(base.TestCase): def setUp(self): super(SNMPValidateParametersTestCase, self).setUp() self.context = context.get_admin_context() def _get_test_node(self, driver_info): return obj_utils.get_test_node( self.context, driver_info=driver_info) def test__parse_driver_info_default(self): # Make sure we get back the expected things.