コード例 #1
0
ファイル: services.py プロジェクト: digantasahoo/nova
    def index(self, req):
        """
        Return a list of all running services. Filter by host & service name.
        """
        context = req.environ['nova.context']
        authorize(context)
        now = timeutils.utcnow()
        services = db.service_get_all(context)

        host = ''
        if 'host' in req.GET:
            host = req.GET['host']
        service = ''
        if 'service' in req.GET:
            service = req.GET['service']
        if host:
            services = [s for s in services if s['host'] == host]
        if service:
            services = [s for s in services if s['binary'] == service]

        svcs = []
        for svc in services:
            delta = now - (svc['updated_at'] or svc['created_at'])
            alive = abs(utils.total_seconds(delta)) <= CONF.service_down_time
            art = (alive and "up") or "down"
            active = 'enabled'
            if svc['disabled']:
                active = 'disabled'
            svcs.append({"binary": svc['binary'], 'host': svc['host'],
                         'zone': svc['availability_zone'],
                         'status': active, 'state': art,
                         'updated_at': svc['updated_at']})
        return {'services': svcs}
コード例 #2
0
ファイル: services.py プロジェクト: whitekid/nova
    def index(self, req):
        """
        Return a list of all running services. Filter by host & service name.
        """
        context = req.environ['nova.context']
        authorize(context)
        now = timeutils.utcnow()
        services = db.service_get_all(context)

        host = ''
        if 'host' in req.GET:
            host = req.GET['host']
        service = ''
        if 'service' in req.GET:
            service = req.GET['service']
        if host:
            services = [s for s in services if s['host'] == host]
        if service:
            services = [s for s in services if s['binary'] == service]

        svcs = []
        for svc in services:
            delta = now - (svc['updated_at'] or svc['created_at'])
            alive = abs(utils.total_seconds(delta)) <= CONF.service_down_time
            art = (alive and "up") or "down"
            active = 'enabled'
            if svc['disabled']:
                active = 'disabled'
            svcs.append({"binary": svc['binary'], 'host': svc['host'],
                         'zone': svc['availability_zone'],
                         'status': active, 'state': art,
                         'updated_at': svc['updated_at']})
        return {'services': svcs}
コード例 #3
0
ファイル: db_driver.py プロジェクト: Karamax/nova
 def is_up(self, service_ref):
     """Moved from nova.utils
     Check whether a service is up based on last heartbeat.
     """
     last_heartbeat = service_ref['updated_at'] or service_ref['created_at']
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(timeutils.utcnow() - last_heartbeat)
     LOG.debug('DB_Driver.is_up last_heartbeat = %(lhb)s elapsed = %(el)s',
               {'lhb': str(last_heartbeat), 'el': str(elapsed)})
     return abs(elapsed) <= CONF.service_down_time
コード例 #4
0
ファイル: db_driver.py プロジェクト: ameade/nova
 def is_up(self, service_ref):
     """Moved from nova.utils
     Check whether a service is up based on last heartbeat.
     """
     last_heartbeat = service_ref['updated_at'] or service_ref['created_at']
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(timeutils.utcnow() - last_heartbeat)
     LOG.debug('DB_Driver.is_up last_heartbeat = %(lhb)s elapsed = %(el)s',
               {'lhb': str(last_heartbeat), 'el': str(elapsed)})
     return abs(elapsed) <= CONF.service_down_time
コード例 #5
0
ファイル: db.py プロジェクト: AnyBucket/nova
 def is_up(self, service_ref):
     """Moved from nova.utils
     Check whether a service is up based on last heartbeat.
     """
     last_heartbeat = service_ref['updated_at'] or service_ref['created_at']
     if isinstance(last_heartbeat, basestring):
         # NOTE(russellb) If this service_ref came in over rpc via
         # conductor, then the timestamp will be a string and needs to be
         # converted back to a datetime.
         last_heartbeat = timeutils.parse_strtime(last_heartbeat)
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(timeutils.utcnow() - last_heartbeat)
     LOG.debug('DB_Driver.is_up last_heartbeat = %(lhb)s elapsed = %(el)s',
               {'lhb': str(last_heartbeat), 'el': str(elapsed)})
     return abs(elapsed) <= CONF.service_down_time
コード例 #6
0
 def is_up(self, service_ref):
     """Moved from nova.utils
     Check whether a service is up based on last heartbeat.
     """
     last_heartbeat = service_ref['updated_at'] or service_ref['created_at']
     if isinstance(last_heartbeat, basestring):
         # NOTE(russellb) If this service_ref came in over rpc via
         # conductor, then the timestamp will be a string and needs to be
         # converted back to a datetime.
         last_heartbeat = timeutils.parse_strtime(last_heartbeat)
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(timeutils.utcnow() - last_heartbeat)
     LOG.debug('DB_Driver.is_up last_heartbeat = %(lhb)s elapsed = %(el)s',
               {'lhb': str(last_heartbeat), 'el': str(elapsed)})
     return abs(elapsed) <= CONF.service_down_time
コード例 #7
0
 def _get_dead_hosts(self, context):
     '''
     get the node status by nova-recover service
     and return all failed node
     :param context:
     :return:
     '''
     now = timeutils.utcnow()
     services = db.service_get_all_by_topic(context, topic)
     dead_hosts = []
     alive_hosts = []
     for service in services:
         delta = now - (service['updated_at'] or service['created_at'])
         alive = abs(utils.total_seconds(delta)) <= FLAGS.service_down_time
         service_host = service['host']
         if  alive:
             alive_hosts.append(service_host)
         else:
             dead_hosts.append(service_host)
     return dead_hosts, alive_hosts
コード例 #8
0
ファイル: db.py プロジェクト: ryu25ish/nova
 def is_up(self, service_ref):
     """Moved from nova.utils
     Check whether a service is up based on last heartbeat.
     """
     last_heartbeat = service_ref["updated_at"] or service_ref["created_at"]
     if isinstance(last_heartbeat, basestring):
         # NOTE(russellb) If this service_ref came in over rpc via
         # conductor, then the timestamp will be a string and needs to be
         # converted back to a datetime.
         last_heartbeat = timeutils.parse_strtime(last_heartbeat)
     else:
         # Objects have proper UTC timezones, but the timeutils comparison
         # below does not (and will fail)
         last_heartbeat = last_heartbeat.replace(tzinfo=None)
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(timeutils.utcnow() - last_heartbeat)
     LOG.debug(
         "DB_Driver.is_up last_heartbeat = %(lhb)s elapsed = %(el)s",
         {"lhb": str(last_heartbeat), "el": str(elapsed)},
     )
     return abs(elapsed) <= CONF.service_down_time
コード例 #9
0
ファイル: services.py プロジェクト: k-i-t-e/nova
    def index(self, req):
        """
        Return a list of all running services. Filter by host & service name.
        """
        context = req.environ["nova.context"]
        authorize(context)
        now = timeutils.utcnow()
        services = self.host_api.service_get_all(context, set_zones=True)

        host = ""
        if "host" in req.GET:
            host = req.GET["host"]
        service = ""
        if "service" in req.GET:
            service = req.GET["service"]
        if host:
            services = [s for s in services if s["host"] == host]
        if service:
            services = [s for s in services if s["binary"] == service]

        svcs = []
        for svc in services:
            delta = now - (svc["updated_at"] or svc["created_at"])
            alive = abs(utils.total_seconds(delta)) <= CONF.service_down_time
            art = (alive and "up") or "down"
            active = "enabled"
            if svc["disabled"]:
                active = "disabled"
            svcs.append(
                {
                    "binary": svc["binary"],
                    "host": svc["host"],
                    "zone": svc["availability_zone"],
                    "status": active,
                    "state": art,
                    "updated_at": svc["updated_at"],
                }
            )
        return {"services": svcs}
コード例 #10
0
ファイル: utils.py プロジェクト: emonty/healthnmon
def is_service_alive(updated_at, created_at):
    delta = timeutils.utcnow() - (updated_at or created_at)
    return abs(utils.total_seconds(delta)) <= CONF.service_down_time
コード例 #11
0
ファイル: driver.py プロジェクト: BillTheBest/nova
 def service_is_up(service):
     """Check whether a service is up based on last heartbeat."""
     last_heartbeat = service['updated_at'] or service['created_at']
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(utils.utcnow() - last_heartbeat)
     return abs(elapsed) <= FLAGS.service_down_time
コード例 #12
0
ファイル: driver.py プロジェクト: nicoleLiu/nova
 def service_is_up(service):
     """Check whether a service is up based on last heartbeat."""
     last_heartbeat = service['updated_at'] or service['created_at']
     # Timestamps in DB are UTC.
     elapsed = utils.total_seconds(utils.utcnow() - last_heartbeat)
     return abs(elapsed) <= FLAGS.service_down_time
コード例 #13
0
ファイル: utils.py プロジェクト: jessegonzalez/healthnmon
def is_service_alive(updated_at, created_at):
    delta = timeutils.utcnow() - (updated_at or created_at)
    return abs(utils.total_seconds(delta)) <= CONF.service_down_time