Esempio n. 1
0
 def describe_hosts(self, context, **_kwargs):
     """Returns status info for all nodes. Includes:
         * Hostname
         * Compute (up, down, None)
         * Instance count
         * Volume (up, down, None)
         * Volume Count
     """
     services = db.service_get_all(context, False)
     now = utils.utcnow()
     hosts = []
     rv = []
     for host in [service['host'] for service in services]:
         if not host in hosts:
             hosts.append(host)
     for host in hosts:
         compute = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'engine-compute']
         if compute:
             compute = compute[0]
         instances = db.instance_get_all_by_host(context, host)
         volume = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'engine-volume']
         if volume:
             volume = volume[0]
         volumes = db.volume_get_all_by_host(context, host)
         rv.append(host_dict(host, compute, instances, volume, volumes,
                             now))
     return {'hosts': rv}
Esempio n. 2
0
    def index(self, req):
        def service_get_all_compute(context):
            topic = "compute"
            session = get_session()
            result = (
                session.query(models.Service)
                .options(joinedload("compute_node"))
                .filter_by(deleted=False)
                .filter_by(topic=topic)
                .all()
            )

            if not result:
                raise exception.ComputeHostNotFound(host=host)

            return result

        context = req.environ["engine.context"]
        services = []
        for service in service_get_all_compute(context):
            services.append(self._format_service(service))
        for service in db.service_get_all(context):
            if service.binary == "engine-compute":
                continue
            services.append(self._format_service(service))
        return {"services": services}
Esempio n. 3
0
 def describe_hosts(self, context, **_kwargs):
     """Returns status info for all nodes. Includes:
         * Hostname
         * Compute (up, down, None)
         * Instance count
         * Volume (up, down, None)
         * Volume Count
     """
     services = db.service_get_all(context, False)
     now = utils.utcnow()
     hosts = []
     rv = []
     for host in [service['host'] for service in services]:
         if not host in hosts:
             hosts.append(host)
     for host in hosts:
         compute = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'engine-compute']
         if compute:
             compute = compute[0]
         instances = db.instance_get_all_by_host(context, host)
         volume = [s for s in services if s['host'] == host \
                                        and s['binary'] == 'engine-volume']
         if volume:
             volume = volume[0]
         volumes = db.volume_get_all_by_host(context, host)
         rv.append(host_dict(host, compute, instances, volume, volumes,
                             now))
     return {'hosts': rv}
Esempio n. 4
0
    def index(self, req):
        def service_get_all_compute(context):
            topic = 'compute'
            session = get_session()
            result = session.query(models.Service).\
                          options(joinedload('compute_node')).\
                          filter_by(deleted=False).\
                          filter_by(topic=topic).\
                          all()

            if not result:
                raise exception.ComputeHostNotFound(host=host)

            return result

        context = req.environ['engine.context']
        services = []
        for service in service_get_all_compute(context):
            services.append(self._format_service(service))
        for service in db.service_get_all(context):
            if service.binary == 'engine-compute':
                continue
            services.append(self._format_service(service))
        return {'services': services}