]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add service list functionality cinder-manage
authorStephen Mulcahy <stephen.mulcahy@hp.com>
Fri, 5 Apr 2013 10:29:13 +0000 (10:29 +0000)
committerStephen Mulcahy <stephen.mulcahy@hp.com>
Tue, 9 Apr 2013 08:15:07 +0000 (08:15 +0000)
Adds functionality similar to nova-manage service list
to cinder-manage.

Change-Id: I9bcd6dcb551dbced2cfd6fcf0e63ffe4bb8754e8

bin/cinder-manage

index de7955d12b92d2fe0955e11476c53a323fa4e460..c358757d2a7504c2426594a2914b421f440bc6ca 100755 (executable)
@@ -681,12 +681,38 @@ class BackupCommands(object):
                          object_count)
 
 
+class ServiceCommands(object):
+    """Methods for managing services."""
+    def list(self):
+        """Show a list of all cinder 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'], status, art,
+                                  svc['updated_at'])
+
+
 CATEGORIES = {
     'backup': BackupCommands,
     'config': ConfigCommands,
     'db': DbCommands,
     'host': HostCommands,
     'logs': GetLogCommands,
+    'service': ServiceCommands,
     'shell': ShellCommands,
     'sm': StorageManagerCommands,
     'version': VersionCommands,