예제 #1
0
    def sandesh_init(self, http_server_port=None):
        """ Init sandesh """
        self._sandesh = Sandesh()
        self.redefine_sandesh_handles()
        if not http_server_port:
            http_server_port = self._args.http_server_port
        self._sandesh.init_generator(
            self._module_name,
            self._hostname,
            self._node_type_name,
            self._instance_id,
            self._args.random_collectors,
            '%s_context' % self.context,
            int(http_server_port),
            ['cfgm_common', '%s.sandesh' % self.module_pkg],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # connection state init
        ConnectionState.init(
            self._sandesh, self._hostname, self._module_name,
            self._instance_id,
            staticmethod(ConnectionState.get_process_state_cb), NodeStatusUVE,
            NodeStatus, self.table)
예제 #2
0
    def sandesh_init(self):
        """ Init Sandesh """
        self._sandesh = Sandesh()

        # Register custom sandesh request handlers.
        self._redefine_sandesh_handles()

        # Initialize Sandesh generator.
        self._sandesh.init_generator(
            self._module["name"], self._module["hostname"],
            self._module["node_type_name"], self._module["instance_id"],
            self._args.random_collectors, 'kube_manager_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'kube_manager'],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        # Set Sandesh logging params.
        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category, level=self._args.log_level,
            file=self._args.log_file, enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # Connect to collector.
        ConnectionState.init(
            self._sandesh, self._module["hostname"], self._module["name"],
            self._module["instance_id"],
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self._module["table"])
예제 #3
0
    def _sandesh_init(self, discovery):
        sandesh_instance = Sandesh()
        sandesh.ServiceInstanceList.handle_request =\
            self.sandesh_si_handle_request
        sandesh_instance.init_generator(
            self._module_name,
            self._hostname,
            self._node_type_name,
            self._instance_id,
            self._args.collectors,
            'svc_monitor_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'svc_monitor.sandesh'],
            discovery,
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf)

        sandesh_instance.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)
        return sandesh_instance
예제 #4
0
    def sandesh_init(self, http_server_port=None):
        if self._sandesh is not None:
            return

        self._sandesh = Sandesh()
        self.redefine_sandesh_handles()
        if not http_server_port:
            http_server_port = self._args.http_server_port

        self._instance_id = self.sandesh_instance_id

        self._sandesh.init_generator(
            self._module_name,
            self._hostname,
            self._node_type_name,
            self.sandesh_instance_id,
            self._args.random_collectors,
            '%s_context' % self.context,
            int(http_server_port), ['cfgm_common'],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        VncGreenlet.register_sandesh_handler()

        self._sandesh.trace_buffer_create(name="MessageBusNotifyTraceBuf",
                                          size=1000)
예제 #5
0
 def setUp(self):
     self.maxDiff = None
     self._sandesh = Sandesh()
     http_port = test_utils.get_free_port()
     self._sandesh.init_generator('conn_info_test', socket.gethostname(),
                                  'Test', 'Test', None,
                                  'conn_info_test_ctxt', http_port)
    def sandesh_init(self):
        """ Init sandesh """
        self._sandesh = Sandesh()
        # Reset the sandesh send rate limit value
        if self._args.sandesh_send_rate_limit is not None:
            SandeshSystem.set_sandesh_send_rate_limit(
                self._args.sandesh_send_rate_limit)
        self.redefine_sandesh_handles()
        self._sandesh.init_generator(
            self._module_name,
            self._hostname,
            self._node_type_name,
            self._instance_id,
            self._args.collectors,
            '%s_context' % self.context,
            int(self._args.http_server_port),
            ['cfgm_common', '%s.sandesh' % self.module_pkg],
            self.discovery,
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf)

        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # connection state init
        ConnectionState.init(
            self._sandesh, self._hostname, self._module_name,
            self._instance_id,
            staticmethod(ConnectionState.get_process_state_cb), NodeStatusUVE,
            NodeStatus, self.table)
예제 #7
0
    def sandesh_init(self):
        """ Init Sandesh """
        self._sandesh = Sandesh()

        # Initialize Sandesh generator.
        self._sandesh.init_generator(
            self.module['name'],
            self.module['hostname'],
            self.module['node_type_name'],
            self.module['instance_id'],
            self._args.collectors,
            'mesos_manager_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'mesos_manager.sandesh'],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        # Set Sandesh logging params.
        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # Connect to collector.
        ConnectionState.init(
            self._sandesh, self.module['hostname'], self.module['name'],
            self.module['instance_id'],
            staticmethod(ConnectionState.get_process_state_cb), NodeStatusUVE,
            NodeStatus, self.module['table'])
예제 #8
0
    def __init__(self, vnc_lib, args=None):
        self._args = args

        # api server and cassandra init
        self._vnc_lib = vnc_lib
        self._cassandra_init()

        # dictionary for nova
        self._nova = {}

        #initialize discovery client
        self._disc = None
        if self._args.disc_server_ip and self._args.disc_server_port:
            self._disc = client.DiscoveryClient(self._args.disc_server_ip,
                                                self._args.disc_server_port,
                                                client_type='Service Monitor')

        #sandesh init
        self._sandesh = Sandesh()
        sandesh.ServiceInstanceList.handle_request =\
            self.sandesh_si_handle_request
        module = Module.SVC_MONITOR
        module_name = ModuleNames[module]
        node_type = Module2NodeType[module]
        node_type_name = NodeTypeNames[node_type]
        instance_id = INSTANCE_ID_DEFAULT
        self._sandesh.init_generator(module_name, socket.gethostname(),
                                     node_type_name, instance_id,
                                     self._args.collectors,
                                     'svc_monitor_context',
                                     int(self._args.http_server_port),
                                     ['cfgm_common', 'sandesh'], self._disc)
        self._sandesh.set_logging_params(enable_local_log=self._args.log_local,
                                         category=self._args.log_category,
                                         level=self._args.log_level,
                                         file=self._args.log_file)

        #create default analyzer template
        self._create_default_template('analyzer-template', 'analyzer',
                                      'analyzer')
        self._create_default_template('nat-template', 'nat-service',
                                      'firewall', 'in-network-nat')

        #create cpu_info object to send periodic updates
        sysinfo_req = False
        cpu_info = vnc_cpu_info.CpuInfo(module_name, instance_id, sysinfo_req,
                                        self._sandesh, 60)
        self._cpu_info = cpu_info

        # logging
        self._err_file = '/var/log/contrail/svc-monitor.err'
        self._tmp_file = '/var/log/contrail/svc-monitor.tmp'
        self._svc_err_logger = logging.getLogger('SvcErrLogger')
        self._svc_err_logger.setLevel(logging.ERROR)
        handler = logging.handlers.RotatingFileHandler(self._err_file,
                                                       maxBytes=64 * 1024,
                                                       backupCount=2)
        self._svc_err_logger.addHandler(handler)
예제 #9
0
 def setUp(self):
     self.sandesh_instance = Sandesh()
     self.sandesh_instance.init_generator('SandeshSessionTest',
                                          'localhost',
                                          'UT',
                                          0,
                                          None,
                                          'context',
                                          -1,
                                          connect_to_collector=False)
예제 #10
0
 def setUp(self):
     self._sandesh = Sandesh()
     http_port = get_free_port()
     self._sandesh.init_generator('sandesh_trace_test',
                                  socket.gethostname(), 'Test', 'Test',
                                  None, 'trace_test_ctxt', http_port)
     self._sandesh.set_logging_params(level=SandeshLevel.SYS_DEBUG,
                                      enable_local_log=True,
                                      enable_trace_print=True)
     self._trace_read_list = []
 def setUp(self):
     self.maxDiff = None
     self.sandesh = Sandesh()
     self.sandesh.init_generator('sandesh_uve_alarm_test',
                                 socket.gethostname(),
                                 'Test',
                                 '0',
                                 None,
                                 '',
                                 get_free_port(),
                                 connect_to_collector=False)
     # mock the sandesh client object
     self.sandesh._client = mock.MagicMock(spec=SandeshClient)
예제 #12
0
def run_introspect(cfg, database, lock):
    sandesh_config = cfg['sandesh']
    sandesh_config['collectors'] = sandesh_config['collectors'].split()
    random.shuffle(sandesh_config['collectors'])
    sandesh_config.update({
        'id': Module.VCENTER_MANAGER,
        'hostname': socket.gethostname(),
        'table': 'ObjectContrailvCenterManagerNode',
        'instance_id': INSTANCE_ID_DEFAULT,
        'introspect_port': ServiceHttpPortMap['contrail-vcenter-manager'],
    })
    sandesh_config['name'] = ModuleNames[sandesh_config['id']]
    sandesh_config['node_type'] = Module2NodeType[sandesh_config['id']]
    sandesh_config['node_type_name'] = NodeTypeNames[sandesh_config['node_type']]

    sandesh = Sandesh()
    sandesh_handler = SandeshHandler(database, lock)
    sandesh_handler.bind_handlers()
    config = SandeshConfig(http_server_ip=sandesh_config['http_server_ip'])
    sandesh.init_generator(
        module='cvm',
        source=sandesh_config['hostname'],
        node_type=sandesh_config['node_type_name'],
        instance_id=sandesh_config['instance_id'],
        collectors=sandesh_config['collectors'],
        client_context='cvm_context',
        http_port=sandesh_config['introspect_port'],
        sandesh_req_uve_pkg_list=['cfgm_common', 'cvm'],
        config=config
    )
    sandesh.sandesh_logger().set_logger_params(
        logger=sandesh.logger(),
        enable_local_log=True,
        level=translate_logging_level(sandesh_config['logging_level']),
        file=sandesh_config['log_file'],
        enable_syslog=False,
        syslog_facility=None
    )
    ConnectionState.init(
        sandesh=sandesh,
        hostname=sandesh_config['hostname'],
        module_id=sandesh_config['name'],
        instance_id=sandesh_config['instance_id'],
        conn_status_cb=staticmethod(ConnectionState.get_conn_state_cb),
        uve_type_cls=NodeStatusUVE,
        uve_data_type_cls=NodeStatus,
        table=sandesh_config['table']
    )
예제 #13
0
    def sandesh_init(self):
        """ Init Sandesh """
        self._sandesh = Sandesh()

        # Reset sandesh send rate limit value.
        if self._args.sandesh_send_rate_limit is not None:
            SandeshSystem.set_sandesh_send_rate_limit(
                self._args.sandesh_send_rate_limit)

        # Initialize Sandesh generator.
        self._sandesh.init_generator(
            self.module.name,
            self.module.hostname,
            self.module.node_type_name,
            self.module.instance_id,
            self._args.collectors,
            'mesos_manager_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'mesos_manager.sandesh'],
            self.module.discovery,
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf)

        # Set Sandesh logging params.
        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # Connect to collector.
        ConnectionState.init(
            self._sandesh, self.module.hostname, self.module.name,
            self.module.instance_id,
            staticmethod(ConnectionState.get_process_state_cb), NodeStatusUVE,
            NodeStatus, self.module.table)