Пример #1
0
    def __init__(self, rule_file, discovery_server, discovery_port,
                 collector_addr):
        self.module = Module.COMPUTE_NODE_MGR
        self.module_id = ModuleNames[self.module]

        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        self.sandesh_global = sandesh_global
        EventManager.__init__(self, rule_file, discovery_server,
                              discovery_port, collector_addr, sandesh_global)
        self.node_type = "contrail-vrouter"
        self.uve_node_type = UVENodeTypeNames[NodeType.COMPUTE]
        self.table = "ObjectVRouter"
        _disc = self.get_discovery_client()
        sandesh_global.init_generator(
            self.module_id, socket.gethostname(), node_type_name,
            self.instance_id, self.collector_addr, self.module_id, 8102,
            ['vrouter.loadbalancer', 'nodemgr.common.sandesh'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"
        self.add_current_process()
        ConnectionState.init(
            sandesh_global, socket.gethostname(),
            self.module_id, self.instance_id,
            staticmethod(ConnectionState.get_process_state_cb), NodeStatusUVE,
            NodeStatus, self.table)

        self.lb_stats = LoadbalancerStatsUVE()
        self.send_init_info()
        self.third_party_process_dict = {}
class VrouterEventManager(EventManager):
    def __init__(self, rule_file, unit_names, discovery_server, discovery_port,
                 collector_addr, sandesh_config):
        type_info = EventManagerTypeInfo(
            package_name='contrail-vrouter-common',
            module_type=Module.COMPUTE_NODE_MGR,
            object_table='ObjectVRouter',
            supervisor_serverurl="unix:///var/run/supervisord_vrouter.sock",
            unit_names=unit_names)
        EventManager.__init__(self,
                              type_info,
                              rule_file,
                              discovery_server,
                              discovery_port,
                              collector_addr,
                              sandesh_global,
                              sandesh_config,
                              update_process_list=True)
        self.lb_stats = LoadbalancerStatsUVE()

    # end __init__

    def get_process_stat_object(self, pname):
        return VrouterProcessStat(pname)

    # end get_process_stat_object

    def do_periodic_events(self):
        self.event_tick_60()
        # loadbalancer processing
        self.lb_stats.send_loadbalancer_stats()
Пример #3
0
class VrouterEventManager(EventManager):
    def __init__(self, config, unit_names):
        type_info = EventManagerTypeInfo(
            module_type=Module.COMPUTE_NODE_MGR,
            object_table='ObjectVRouter',
            sandesh_packages=['vrouter.loadbalancer'])
        super(VrouterEventManager, self).__init__(config,
                                                  type_info,
                                                  unit_names,
                                                  update_process_list=True)
        self.host_ip = config.hostip
        self.hostname = socket.getfqdn(self.hostip) \
                        if config.hostname is None else config.hostname
        self.lb_stats = LoadbalancerStatsUVE(self.logger,
                                             self.host_ip,
                                             hostname=self.hostname)

    def get_process_stat_object(self, pname):
        return VrouterProcessStat(pname,
                                  self.host_ip,
                                  self.logger,
                                  hostname=self.hostname)

    def do_periodic_events(self):
        super(VrouterEventManager, self).do_periodic_events()
        # loadbalancer processing
        self.lb_stats.send_loadbalancer_stats()

    def nodemgr_sighup_handler(self):
        self.update_current_process()
        super(VrouterEventManager, self).nodemgr_sighup_handler()
class VrouterEventManager(EventManager):
    def __init__(self, config, rule_file, unit_names):

        if os.path.exists('/tmp/supervisord_vrouter.sock'):
            supervisor_serverurl = "unix:///tmp/supervisord_vrouter.sock"
        else:
            supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"

        type_info = EventManagerTypeInfo(
            package_name = 'contrail-vrouter-common',
            module_type = Module.COMPUTE_NODE_MGR,
            object_table = 'ObjectVRouter',
            supervisor_serverurl = supervisor_serverurl,
            unit_names = unit_names)
        super(VrouterEventManager, self).__init__(config, type_info, rule_file,
                sandesh_global, update_process_list=True)
        self.lb_stats = LoadbalancerStatsUVE(self.logger)
    # end __init__

    def get_process_stat_object(self, pname):
        return VrouterProcessStat(pname, self.logger)
    # end get_process_stat_object

    def do_periodic_events(self):
        self.event_tick_60()
        # loadbalancer processing
        self.lb_stats.send_loadbalancer_stats()
    # end do_periodic_events

    def nodemgr_sighup_handler(self):
        self.update_current_process()
        super(VrouterEventManager, self).nodemgr_sighup_handler()
Пример #5
0
class VrouterEventManager(EventManager):
    def __init__(self, rule_file, unit_names,
                 collector_addr, sandesh_config):

        if os.path.exists('/tmp/supervisord_vrouter.sock'):
            supervisor_serverurl = "unix:///tmp/supervisord_vrouter.sock"
        else:
            supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"

        type_info = EventManagerTypeInfo(
            package_name = 'contrail-vrouter-common',
            module_type = Module.COMPUTE_NODE_MGR,
            object_table = 'ObjectVRouter',
            supervisor_serverurl = supervisor_serverurl,
            unit_names = unit_names)
        EventManager.__init__(self, type_info, rule_file,
                              collector_addr, sandesh_global,
                              sandesh_config, update_process_list = True)
        self.lb_stats = LoadbalancerStatsUVE(self.logger)
    # end __init__

    def get_process_stat_object(self, pname):
        return VrouterProcessStat(pname, self.logger)
    # end get_process_stat_object

    def do_periodic_events(self):
        self.event_tick_60()
        # loadbalancer processing
        self.lb_stats.send_loadbalancer_stats()
    # end do_periodic_events

    def nodemgr_sighup_handler(self):
        self.update_current_process()
        super(VrouterEventManager, self).nodemgr_sighup_handler()
Пример #6
0
 def __init__(self, config, unit_names):
     type_info = EventManagerTypeInfo(
         module_type=Module.COMPUTE_NODE_MGR,
         object_table='ObjectVRouter',
         sandesh_packages=['vrouter.loadbalancer'])
     super(VrouterEventManager, self).__init__(config, type_info,
             sandesh_global, unit_names, update_process_list=True)
     self.lb_stats = LoadbalancerStatsUVE(self.logger)
Пример #7
0
 def __init__(self, config, unit_names):
     type_info = EventManagerTypeInfo(
         module_type=Module.COMPUTE_NODE_MGR,
         object_table='ObjectVRouter',
         sandesh_packages=['vrouter.loadbalancer'])
     super(VrouterEventManager, self).__init__(config,
                                               type_info,
                                               unit_names,
                                               update_process_list=True)
     self.host_ip = config.hostip
     self.hostname = socket.getfqdn(self.hostip) \
                     if config.hostname is None else config.hostname
     self.lb_stats = LoadbalancerStatsUVE(self.logger,
                                          self.host_ip,
                                          hostname=self.hostname)
    def __init__(self, rule_file, discovery_server,
                 discovery_port, collector_addr):
        self.module = Module.COMPUTE_NODE_MGR
        self.module_id = ModuleNames[self.module]

        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        self.sandesh_global = sandesh_global
        EventManager.__init__(self, rule_file, discovery_server,
                              discovery_port, collector_addr, sandesh_global)
        self.node_type = "contrail-vrouter"
        self.table = "ObjectVRouter"
        _disc = self.get_discovery_client()
        sandesh_global.init_generator(
            self.module_id, socket.gethostname(),
            node_type_name, self.instance_id, self.collector_addr,
            self.module_id, 8102, ['vrouter.loadbalancer',
                'nodemgr.common.sandesh'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"
        self.add_current_process()
        ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
            self.instance_id,
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self.table)

        self.lb_stats = LoadbalancerStatsUVE()
        self.send_system_cpu_info()
        self.third_party_process_dict = {}
    def __init__(self, config, rule_file, unit_names):

        if os.path.exists('/tmp/supervisord_vrouter.sock'):
            supervisor_serverurl = "unix:///tmp/supervisord_vrouter.sock"
        else:
            supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"

        type_info = EventManagerTypeInfo(
            package_name = 'contrail-vrouter-common',
            module_type = Module.COMPUTE_NODE_MGR,
            object_table = 'ObjectVRouter',
            supervisor_serverurl = supervisor_serverurl,
            sandesh_packages = ['vrouter.loadbalancer'],
            unit_names = unit_names)
        super(VrouterEventManager, self).__init__(config, type_info, rule_file,
                sandesh_global, update_process_list=True)
        self.lb_stats = LoadbalancerStatsUVE(self.logger)
 def __init__(self, rule_file, unit_names, discovery_server, discovery_port,
              collector_addr, sandesh_config):
     type_info = EventManagerTypeInfo(
         package_name='contrail-vrouter-common',
         module_type=Module.COMPUTE_NODE_MGR,
         object_table='ObjectVRouter',
         supervisor_serverurl="unix:///var/run/supervisord_vrouter.sock",
         unit_names=unit_names)
     EventManager.__init__(self,
                           type_info,
                           rule_file,
                           discovery_server,
                           discovery_port,
                           collector_addr,
                           sandesh_global,
                           sandesh_config,
                           update_process_list=True)
     self.lb_stats = LoadbalancerStatsUVE()
    def __init__(self, config, rule_file, unit_names):

        if os.path.exists('/tmp/supervisord_vrouter.sock'):
            supervisor_serverurl = "unix:///tmp/supervisord_vrouter.sock"
        else:
            supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"

        type_info = EventManagerTypeInfo(
            package_name = 'contrail-vrouter-common',
            module_type = Module.COMPUTE_NODE_MGR,
            object_table = 'ObjectVRouter',
            supervisor_serverurl = supervisor_serverurl,
            unit_names = unit_names)
        super(VrouterEventManager, self).__init__(config, type_info, rule_file,
                sandesh_global, update_process_list=True)
        self.lb_stats = LoadbalancerStatsUVE(self.logger)
class VrouterEventManager(EventManager):
    def __init__(self, rule_file, discovery_server,
                 discovery_port, collector_addr):
        self.module = Module.COMPUTE_NODE_MGR
        self.module_id = ModuleNames[self.module]

        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        self.sandesh_global = sandesh_global
        EventManager.__init__(self, rule_file, discovery_server,
                              discovery_port, collector_addr, sandesh_global)
        self.node_type = "contrail-vrouter"
        self.table = "ObjectVRouter"
        _disc = self.get_discovery_client()
        sandesh_global.init_generator(
            self.module_id, socket.gethostname(),
            node_type_name, self.instance_id, self.collector_addr,
            self.module_id, 8102, ['vrouter.loadbalancer',
                'nodemgr.common.sandesh'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"
        self.add_current_process()
        ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
            self.instance_id,
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self.table)

        self.lb_stats = LoadbalancerStatsUVE()
        self.send_system_cpu_info()
        self.third_party_process_dict = {}
    # end __init__

    def msg_log(self, msg, level):
        self.sandesh_global.logger().log(SandeshLogger.get_py_logger_level(
                            level), msg)

    def process(self):
        if self.rule_file is '':
            self.rule_file = \
                "/etc/contrail/supervisord_vrouter_files/" + \
                "contrail-vrouter.rules"
        json_file = open(self.rule_file)
        self.rules_data = json.load(json_file)

    def send_process_state_db(self, group_names):
        self.send_process_state_db_base(
            group_names, ProcessInfo)

    def send_nodemgr_process_status(self):
        self.send_nodemgr_process_status_base(
            ProcessStateNames, ProcessState, ProcessStatus)

    def get_node_third_party_process_dict(self):
        return self.third_party_process_dict 

    def get_process_state(self, fail_status_bits):
        return self.get_process_state_base(
            fail_status_bits, ProcessStateNames, ProcessState)

    def get_process_stat_object(self, pname):
        return VrouterProcessStat(pname)

    # overridden delete_process_handler -
    def delete_process_handler(self, deleted_process):
        super(VrouterEventManager,
              self).delete_process_handler(deleted_process)
    # end delete_process_handler

    def runforever(self, test=False):
        self.prev_current_time = int(time.time())
        while 1:
            # we explicitly use self.stdin, self.stdout, and self.stderr
            # instead of sys.* so we can unit test this code
            headers, payload = \
                self.listener_nodemgr.wait(self.stdin, self.stdout)

            # self.stderr.write("headers:\n" + str(headers) + '\n')
            # self.stderr.write("payload:\n" + str(payload) + '\n')

            pheaders, pdata = childutils.eventdata(payload + '\n')
            # self.stderr.write("pheaders:\n" + str(pheaders)+'\n')
            # self.stderr.write("pdata:\n" + str(pdata))

            # check for process state change events
            if headers['eventname'].startswith("PROCESS_STATE"):
                self.event_process_state(pheaders, headers)
                # check for addition / deletion of processes in the node.
                # Tor Agent process can get added / deleted based on need.
                self.update_current_process()

            # check for flag value change events
            if headers['eventname'].startswith("PROCESS_COMMUNICATION"):
                self.event_process_communication(pdata)
            # do periodic events
            if headers['eventname'].startswith("TICK_60"):
                self.event_tick_60()

                # loadbalancer processing
                self.lb_stats.send_loadbalancer_stats()

            self.listener_nodemgr.ok(self.stdout)
Пример #13
0
class VrouterEventManager(EventManager):
    def __init__(self, rule_file, discovery_server, discovery_port,
                 collector_addr):
        self.module = Module.COMPUTE_NODE_MGR
        self.module_id = ModuleNames[self.module]

        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        self.sandesh_global = sandesh_global
        EventManager.__init__(self, rule_file, discovery_server,
                              discovery_port, collector_addr, sandesh_global)
        self.node_type = "contrail-vrouter"
        self.uve_node_type = UVENodeTypeNames[NodeType.COMPUTE]
        self.table = "ObjectVRouter"
        _disc = self.get_discovery_client()
        sandesh_global.init_generator(
            self.module_id, socket.gethostname(), node_type_name,
            self.instance_id, self.collector_addr, self.module_id, 8102,
            ['vrouter.loadbalancer', 'nodemgr.common.sandesh'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"
        self.add_current_process()
        ConnectionState.init(
            sandesh_global, socket.gethostname(),
            self.module_id, self.instance_id,
            staticmethod(ConnectionState.get_process_state_cb), NodeStatusUVE,
            NodeStatus, self.table)

        self.lb_stats = LoadbalancerStatsUVE()
        self.send_init_info()
        self.third_party_process_dict = {}

    # end __init__

    def msg_log(self, msg, level):
        self.sandesh_global.logger().log(
            SandeshLogger.get_py_logger_level(level), msg)

    def process(self):
        if self.rule_file is '':
            self.rule_file = \
                "/etc/contrail/supervisord_vrouter_files/" + \
                "contrail-vrouter.rules"
        json_file = open(self.rule_file)
        self.rules_data = json.load(json_file)

    def send_process_state_db(self, group_names):
        self.send_process_state_db_base(group_names, ProcessInfo)

    def send_nodemgr_process_status(self):
        self.send_nodemgr_process_status_base(ProcessStateNames, ProcessState,
                                              ProcessStatus)

    def get_node_third_party_process_dict(self):
        return self.third_party_process_dict

    def get_process_state(self, fail_status_bits):
        return self.get_process_state_base(fail_status_bits, ProcessStateNames,
                                           ProcessState)

    def get_process_stat_object(self, pname):
        return VrouterProcessStat(pname)

    # overridden delete_process_handler -
    def delete_process_handler(self, deleted_process):
        super(VrouterEventManager,
              self).delete_process_handler(deleted_process)

    # end delete_process_handler

    def runforever(self, test=False):
        self.prev_current_time = int(time.time())
        while 1:
            # we explicitly use self.stdin, self.stdout, and self.stderr
            # instead of sys.* so we can unit test this code
            headers, payload = \
                self.listener_nodemgr.wait(self.stdin, self.stdout)

            # self.stderr.write("headers:\n" + str(headers) + '\n')
            # self.stderr.write("payload:\n" + str(payload) + '\n')

            pheaders, pdata = childutils.eventdata(payload + '\n')
            # self.stderr.write("pheaders:\n" + str(pheaders)+'\n')
            # self.stderr.write("pdata:\n" + str(pdata))

            # check for process state change events
            if headers['eventname'].startswith("PROCESS_STATE"):
                self.event_process_state(pheaders, headers)
                # check for addition / deletion of processes in the node.
                # Tor Agent process can get added / deleted based on need.
                self.update_current_process()

            # check for flag value change events
            if headers['eventname'].startswith("PROCESS_COMMUNICATION"):
                self.event_process_communication(pdata)
            # do periodic events
            if headers['eventname'].startswith("TICK_60"):
                self.event_tick_60()

                # loadbalancer processing
                self.lb_stats.send_loadbalancer_stats()

            self.listener_nodemgr.ok(self.stdout)

    def get_package_name(self):
        return self.node_type + '-common'