def test_valid_port(self): self.assertTrue(PanoptesValidators.valid_port(1)) self.assertFalse(PanoptesValidators.valid_port(1.0)) self.assertFalse(PanoptesValidators.valid_port(65540)) self.assertFalse(PanoptesValidators.valid_port(0)) self.assertFalse(PanoptesValidators.valid_port(-1)) self.assertFalse(PanoptesValidators.valid_port(u"0")) self.assertFalse(PanoptesValidators.valid_port(u"1")) self.assertFalse(PanoptesValidators.valid_port(True)) self.assertFalse(PanoptesValidators.valid_port(False))
def _parse_snmp_configuration(self): self._connection_factory_module = self._plugin_snmp_configuration.get(u'connection_factory_module', self._default_snmp_configuration[ u'connection_factory_module']) assert PanoptesValidators.valid_nonempty_string( self._connection_factory_module), u'SNMP connection factory module must be a non-empty string' self._connection_factory_class = self._plugin_snmp_configuration.get(u'connection_factory_class', self._default_snmp_configuration[ u'connection_factory_class']) assert PanoptesValidators.valid_nonempty_string( self._connection_factory_class), u'SNMP connection factory class must be a non-empty string' self._community_string_key = self._plugin_snmp_configuration.get(u'community_string_key', self._default_snmp_configuration.get( u'community_string_key')) assert PanoptesValidators.valid_nonempty_string( self._community_string_key), u'SNMP community string key must be a non-empty string' self._port = int( self._plugin_snmp_configuration.get(u'port', self._default_snmp_configuration[u'port'])) assert PanoptesValidators.valid_port(self._port), u'SNMP port must be a valid TCP/UDP port number' self._proxy_port = int( self._plugin_snmp_configuration.get(u'proxy_port', self._default_snmp_configuration[u'proxy_port'])) assert PanoptesValidators.valid_port(self._proxy_port), u'SNMP proxy port must be a valid TCP/UDP port number' self._timeout = int( self._plugin_snmp_configuration.get(u'timeout', self._default_snmp_configuration[u'timeout'])) assert PanoptesValidators.valid_nonzero_integer( self._timeout), u'SNMP timeout must be a positive integer' self._retries = int( self._plugin_snmp_configuration.get(u'retries', self._default_snmp_configuration[u'retries'])) assert PanoptesValidators.valid_nonzero_integer( self._retries), u'SNMP retries must be a positive integer' self._non_repeaters = int(self._plugin_snmp_configuration.get(u'non_repeaters', self._default_snmp_configuration[ u'non_repeaters'])) assert PanoptesValidators.valid_positive_integer( self._non_repeaters), u'SNMP non-repeaters must be a positive integer' self._max_repetitions = int( self._plugin_snmp_configuration.get(u'max_repetitions', self._default_snmp_configuration[u'max_repetitions'])) assert PanoptesValidators.valid_nonzero_integer( self._max_repetitions), u'SNMP max-repetitions must be a positive integer'
def __init__(self, host, port, timeout, retries): assert PanoptesValidators.valid_nonempty_string(host), u'host must a non-empty string' assert PanoptesValidators.valid_port(port), u'port must be an integer between 1 and 65535' assert PanoptesValidators.valid_nonzero_integer(timeout), u'timeout must be a integer greater than zero' assert PanoptesValidators.valid_positive_integer(retries), u'retries must a non-negative integer' self._host = host self._port = port self._timeout = timeout self._retries = retries self._easy_snmp_session = None