コード例 #1
0
    def _index(self, req):
        """Return a list of all running services."""

        context = req.environ['manila.context']
        all_services = db.service_get_all(context)

        services = []
        for service in all_services:
            service = {
                'id': service['id'],
                'binary': service['binary'],
                'host': service['host'],
                'zone': service['availability_zone']['name'],
                'status': 'disabled' if service['disabled'] else 'enabled',
                'state': 'up' if utils.service_is_up(service) else 'down',
                'updated_at': service['updated_at'],
            }
            services.append(service)

        search_opts = [
            'host',
            'binary',
            'zone',
            'state',
            'status',
        ]
        for search_opt in search_opts:
            value = ''
            if search_opt in req.GET:
                value = req.GET[search_opt]
                services = [s for s in services if s[search_opt] == value]
            if len(services) == 0:
                break

        return self._view_builder.detail_list(services)
コード例 #2
0
ファイル: manage.py プロジェクト: openstack/manila
 def list(self):
     """Show a list of all manila services."""
     ctxt = context.get_admin_context()
     services = db.service_get_all(ctxt)
     print_format = "%-16s %-36s %-16s %-10s %-5s %-10s"
     print(print_format % (
         _('Binary'),
         _('Host'),
         _('Zone'),
         _('Status'),
         _('State'),
         _('Updated At'))
     )
     for svc in services:
         alive = utils.service_is_up(svc)
         art = ":-)" if alive else "XXX"
         status = 'enabled'
         if svc['disabled']:
             status = 'disabled'
         print(print_format % (
             svc['binary'],
             svc['host'].partition('.')[0],
             svc['availability_zone']['name'],
             status,
             art,
             svc['updated_at'],
         ))
コード例 #3
0
ファイル: manage.py プロジェクト: ajarr/manila
    def list(self, zone=None):
        """Show a list of all physical hosts. Filter by zone.

        args: [zone]
        """
        print("%-25s\t%-15s" % (_("host"), _("zone")))
        ctxt = context.get_admin_context()
        services = db.service_get_all(ctxt)
        if zone:
            services = [s for s in services if s["availability_zone"]["name"] == zone]
        hosts = []
        for srv in services:
            if not [h for h in hosts if h["host"] == srv["host"]]:
                hosts.append(srv)

        for h in hosts:
            print("%-25s\t%-15s" % (h["host"], h["availability_zone"]["name"]))
コード例 #4
0
    def list(self, zone=None):
        """Show a list of all physical hosts. Filter by zone.

        args: [zone]
        """
        print("%-25s\t%-15s" % (_('host'), _('zone')))
        ctxt = context.get_admin_context()
        services = db.service_get_all(ctxt)
        if zone:
            services = [
                s for s in services if s['availability_zone']['name'] == zone
            ]
        hosts = []
        for srv in services:
            if not [h for h in hosts if h['host'] == srv['host']]:
                hosts.append(srv)

        for h in hosts:
            print("%-25s\t%-15s" % (h['host'], h['availability_zone']['name']))
コード例 #5
0
 def list(self):
     """Show a list of all manila services."""
     ctxt = context.get_admin_context()
     services = db.service_get_all(ctxt)
     print_format = "%-16s %-36s %-16s %-10s %-5s %-10s"
     print(print_format % (_('Binary'), _('Host'), _('Zone'), _('Status'),
                           _('State'), _('Updated At')))
     for svc in services:
         alive = utils.service_is_up(svc)
         art = ":-)" if alive else "XXX"
         status = 'enabled'
         if svc['disabled']:
             status = 'disabled'
         print(print_format % (
             svc['binary'],
             svc['host'].partition('.')[0],
             svc['availability_zone']['name'],
             status,
             art,
             svc['updated_at'],
         ))
コード例 #6
0
ファイル: services.py プロジェクト: pombredanne/manila
    def index(self, req):
        """
        Return a list of all running services. Filter by host & service name.
        """
        context = req.environ["manila.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}
コード例 #7
0
ファイル: manage.py プロジェクト: ajarr/manila
 def list(self):
     """Show a list of all manila services."""
     ctxt = context.get_admin_context()
     services = db.service_get_all(ctxt)
     print_format = "%-16s %-36s %-16s %-10s %-5s %-10s"
     print(print_format % (_("Binary"), _("Host"), _("Zone"), _("Status"), _("State"), _("Updated At")))
     for svc in services:
         alive = utils.service_is_up(svc)
         art = ":-)" if alive else "XXX"
         status = "enabled"
         if svc["disabled"]:
             status = "disabled"
         print(
             print_format
             % (
                 svc["binary"],
                 svc["host"].partition(".")[0],
                 svc["availability_zone"]["name"],
                 status,
                 art,
                 svc["updated_at"],
             )
         )