示例#1
0
文件: hosts.py 项目: hl10502/vsm
def _list_hosts(req, service=None):
    """Returns a summary list of hosts."""
    curr_time = timeutils.utcnow()
    context = req.environ['vsm.context']
    services = db.service_get_all(context, False)
    zone = ''
    if 'zone' in req.GET:
        zone = req.GET['zone']
    if zone:
        services = [s for s in services if s['availability_zone'] == zone]
    hosts = []
    for host in services:
        delta = curr_time - (host['updated_at'] or host['created_at'])
        alive = abs(utils.total_seconds(delta)) <= FLAGS.service_down_time
        status = (alive and "available") or "unavailable"
        active = 'enabled'
        if host['disabled']:
            active = 'disabled'
        LOG.debug('status, active and update: %s, %s, %s' %
                  (status, active, host['updated_at']))
        hosts.append({'host_name': host['host'],
                      'service': host['topic'],
                      'zone': host['availability_zone'],
                      'service-status': status,
                      'service-state': active,
                      'last-update': host['updated_at']})
    if service:
        hosts = [host for host in hosts
                 if host["service"] == service]
    return hosts
示例#2
0
    def index(self, req):
        """
        Return a list of all running services. Filter by host & service name.
        """
        context = req.environ['vsm.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))
            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
 def service_get_all(self, context, disabled=None):
     LOG.debug("DEBUG test service_get_all func")
     service_list = db.service_get_all(context)
     for x in service_list:
         LOG.debug("service id = %s" % x.id)
         LOG.debug("service host = %s" % x.host)
         LOG.debug("service binary = %s" % x.binary)
         LOG.debug("service topic = %s" % x.topic)
         LOG.debug("service report_count = %s" % x.report_count)
         LOG.debug("service created_at = %s" % x.created_at)
示例#4
0
 def service_get_all(self, context, disabled=None):
     LOG.debug("DEBUG test service_get_all func")
     service_list = db.service_get_all(context)
     for x in service_list:
         LOG.debug("service id = %s" % x.id)
         LOG.debug("service host = %s" % x.host)
         LOG.debug("service binary = %s" % x.binary)
         LOG.debug("service topic = %s" % x.topic)
         LOG.debug("service report_count = %s" % x.report_count)
         LOG.debug("service created_at = %s" % x.created_at)
示例#5
0
    def index(self, req):
        """
        Return a list of all running services. Filter by host & service name.
        """
        context = req.environ['vsm.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))
            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}
示例#6
0
 def service_get_all(self, context):
     service_list = db.service_get_all(context)
     for x in service_list:
         LOG.debug('x.id = %s' % x.id)
         LOG.debug('x.topic = %s' % x.topic)
         LOG.debug('x.recipeId = %s' % x.recipe_Id)
 def get_service_list(self, req, cluster_id=None):
     context = req.environ['vsm.context']
     service = db.service_get_all(context)
     return {"services": service}
示例#8
0
 def get_service_list(self, req,cluster_id=None):
     context = req.environ['vsm.context']
     service = db.service_get_all(context)
     return {"services":service}
示例#9
0
 def service_get_all(self, context):
     service_list = db.service_get_all(context)
     for x in service_list:
         LOG.debug('x.id = %s' % x.id)
         LOG.debug('x.topic = %s' % x.topic)
         LOG.debug('x.recipeId = %s' % x.recipe_Id)