예제 #1
0
    def __init__(self, configs, shell):
        ServerModule.__init__(self, configs, shell)

        # The users dict (USM)
        self.users = dict()

        # Get the configurations
        self.port = int(self.options[SNMPListener.port_option])
        self.community_string = self.options[SNMPListener.community_string]
        self.check_community_string =\
                self.options[SNMPListener.check_community_string]

        Notification.register_class(SNMPv1Notification)
        Notification.register_class(SNMPv2cNotification)
    def __init__(self, configs, shell):
        ServerModule.__init__(self, configs, shell)

        self.udp_port = int(self.options[AgentListener.udp_port_option])
        self.ssl_port = int(self.options[AgentListener.ssl_port_option])
        self.ssl_auth = bool(self.options[AgentListener.ssl_auth_enabled])
        self.udp_auth = bool(self.options[AgentListener.udp_auth_enabled])

        self.agent_tracker = None
        self.command_tracker = None
        
        # Mapping request types to their handlers
        self.request_handlers = {\
            AgentRequestTypes.add_user : self.evaluate_add_user_request,\
            AgentRequestTypes.del_user : self.evaluate_del_user_request,\
            AgentRequestTypes.get_users : self.evaluate_get_users_request,\
            AgentRequestTypes.get_configs : self.evaluate_get_configs_request,\
            AgentRequestTypes.set_configs : self.evaluate_set_configs_request,\
            AgentRequestTypes.restart : self.evaluate_restart_request,\
            }

        Notification.register_class(AgentNotification)
        
        # Generate the SSL key and certificate
        logging.info('AgentListener: Loading SSL support ...')
        self.ssl_enabled = True
        try:
            self._generate_ssl_files()
        except:
            logging.error('AgentListener: Failed to load SSL support.',\
                          exc_info=True)
            self.ssl_enabled = False
        logging.info('AgentListener: Loaded SSL support')

        # The users used for authentication if enabled
        self.users = {}

        # The command ports of the hosts in the network. If the value is
        # None, then the host is down
        self.hosts_command_port = {}

        # Mapping GET_CONFIG requests to their data_connection
        self.get_configs_map = dict()