Exemplo n.º 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)
Exemplo n.º 2
0
    def __init__(self, configs):
        logging.info('Initializing ServerCore ...')

        self.initialized = True
        self.configs = configs
        try:
            self.database = Database(configs)
        except:
            logging.critical('Failed to initialize ServerCore. Shutting down.',
                             exc_info=True)
            self.initialized = False
            return
        
        if self.database.database is None:
            logging.critical('Failed to initialize ServerCore. Shutting down.')
            self.initialized = False
            return
        self.shell = ServerShell(self)
        self.database.shell = self.shell

        self.modules = {}
        self._load_modules()
        
        self.user_system = UserSystem(self.database)
        self.server_interface = ServerInterface(self.configs,
                                                self.user_system, self.shell)
        self.shell.server_interface = self.server_interface

        # Initialize the Notification system
        Notification.registered_classes[Notification.get_name()] = Notification

        # Save the configs
        self.configs.save_settings()

        logging.info('Initialized ServerCore')
    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()