Esempio n. 1
0
    def _health_checker(self):
        while True:
            try:
                # do the healthcheck only if we are connected
                if self._conn_state == ConnectionStatus.DOWN:
                    continue
                meta = Metadata('display-name',
                                '', {'ifmap-cardinality': 'singleValue'},
                                ns_prefix='contrail',
                                elements='')
                request_str = self._build_request('healthcheck', 'self',
                                                  [meta])
                self._publish_to_ifmap_enqueue('update',
                                               request_str,
                                               do_trace=False)

                # Confirm the existence of the following default global entities in IFMAP.
                search_list = [
                    ('global-system-config', ['default-global-system-config']),
                ]
                for type, fq_name in search_list:
                    if not entity_is_present(self._mapclient, type, fq_name):
                        raise Exception("%s not found in IFMAP DB" %
                                        ':'.join(fq_name))

                # If we had unpublished the IFMAP server to discovery server earlier
                # publish it back now since it is valid now.
                if not self._is_ifmap_up:
                    self._get_api_server().publish_ifmap_to_discovery('up', '')
                    self._is_ifmap_up = True
                    ConnectionState.update(
                        conn_type=ConnectionType.IFMAP,
                        name='IfMap',
                        status=ConnectionStatus.UP,
                        message='',
                        server_addrs=[
                            "%s:%s" %
                            (self._ifmap_srv_ip, self._ifmap_srv_port)
                        ])
            except Exception as e:
                log_str = 'IFMAP Healthcheck failed: %s' % (str(e))
                self.config_log(log_str, level=SandeshLevel.SYS_ERR)
                if self._is_ifmap_up:
                    self._get_api_server().publish_ifmap_to_discovery(
                        'down', 'IFMAP DB - Invalid state')
                    self._is_ifmap_up = False
                    ConnectionState.update(
                        conn_type=ConnectionType.IFMAP,
                        name='IfMap',
                        status=ConnectionStatus.DOWN,
                        message='Invalid IFMAP DB State',
                        server_addrs=[
                            "%s:%s" %
                            (self._ifmap_srv_ip, self._ifmap_srv_port)
                        ])
            finally:
                gevent.sleep(
                    self._get_api_server().get_ifmap_health_check_interval())
Esempio n. 2
0
    def _health_checker(self):
        while True:
            try:
                # do the healthcheck only if we are connected
                if self._conn_state == ConnectionStatus.DOWN:
                    continue
                meta = Metadata('display-name', '',
                        {'ifmap-cardinality': 'singleValue'},
                        ns_prefix='contrail', elements='')
                request_str = self._build_request('healthcheck', 'self', [meta])
                self._publish_to_ifmap_enqueue('update', request_str, do_trace=False)

                # Confirm the existence of the following default global entities in IFMAP.
                search_list = [
                    ('global-system-config', ['default-global-system-config']),
                ]
                for type, fq_name in search_list:
                    if not entity_is_present(self._mapclient, type, fq_name):
                        raise Exception("%s not found in IFMAP DB" % ':'.join(fq_name))

                # If we had unpublished the IFMAP server to discovery server earlier
                # publish it back now since it is valid now.
                if not self._is_ifmap_up:
                    self._get_api_server().publish_ifmap_to_discovery('up', '')
                    self._is_ifmap_up = True
                    ConnectionState.update(conn_type = ConnectionType.IFMAP,
                                           name = 'IfMap',
                                           status = ConnectionStatus.UP,
                                           message = '',
                                           server_addrs = ["%s:%s" % (self._ifmap_srv_ip,
                                                                      self._ifmap_srv_port)])
            except Exception as e:
                log_str = 'IFMAP Healthcheck failed: %s' %(str(e))
                self.config_log(log_str, level=SandeshLevel.SYS_ERR)
                if self._is_ifmap_up:
                    self._get_api_server().publish_ifmap_to_discovery('down',
                                                   'IFMAP DB - Invalid state')
                    self._is_ifmap_up = False
                    ConnectionState.update(conn_type = ConnectionType.IFMAP,
                                           name = 'IfMap',
                                           status = ConnectionStatus.DOWN,
                                           message = 'Invalid IFMAP DB State',
                                           server_addrs = ["%s:%s" % (self._ifmap_srv_ip,
                                                                      self._ifmap_srv_port)])
            finally:
                gevent.sleep(
                    self._get_api_server().get_ifmap_health_check_interval())
Esempio n. 3
0
 def _ifmap_restarted(self):
     return not entity_is_present(self._mapclient, 'config-root', ['root'])
Esempio n. 4
0
 def _ifmap_restarted(self):
     return not entity_is_present(self._mapclient, 'config-root', ['root'])