Adds the ability to list atomic labels via 'atest label list --atomicgroup'
Adds ability to parse values from nested dicts to topic_common for the above.

Signed-off-by: Gregory Smith <gps@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3350 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/label.py b/cli/label.py
index 244f795..65ad468 100755
--- a/cli/label.py
+++ b/cli/label.py
@@ -55,7 +55,7 @@
 
 
 class label_list(action_common.atest_list, label):
-    """atest label list [--platform] [--all]
+    """atest label list [--platform] [--all] [--atomicgroup]
     [--valid-only] [--machine <machine>]
     [--blist <file>] [<labels>]"""
     def __init__(self):
@@ -74,6 +74,11 @@
                                      'platform labels'),
                                action='store_true')
 
+        self.parser.add_option('--atomicgroup',
+                               help=('Display only atomic group labels '
+                                     'along with the atomic group name.'),
+                               action='store_true')
+
         self.parser.add_option('-m', '--machine',
                                help='List LABELs of MACHINE',
                                type='string',
@@ -85,9 +90,10 @@
                                                  inline_option='machine')
         (options, leftover) = super(label_list, self).parse([host_info])
 
-        if options.all and options.platform_only:
+        exclusives = [options.all, options.platform_only, options.atomicgroup]
+        if exclusives.count(True) > 1:
             self.invalid_syntax('Only specify one of --all,'
-                                '--platform')
+                                '--platform, --atomicgroup')
 
         if len(self.hosts) > 1:
             self.invalid_syntax(('Only one machine name allowed. '
@@ -95,6 +101,7 @@
                                  'instead.') %
                                 (sys.argv[0], ','.join(self.hosts)))
         self.all = options.all
+        self.atomicgroup = options.atomicgroup
         self.platform_only = options.platform_only
         self.valid_only = options.valid_only
         return (options, leftover)
@@ -125,6 +132,10 @@
             results = [label for label in results
                        if label['platform']]
             keys = ['name', 'invalid']
+        elif self.atomicgroup:
+            results = [label for label in results
+                       if label['atomic_group']]
+            keys = ['name', 'atomic_group.name', 'invalid']
         elif not self.all:
             results = [label for label in results
                        if not label['platform']]