- Expose the lock_time and protection fields in host stat.
- Allow users to set the protection level through the CLI.
Risk(Low): Changes affect host_stat and host_mod.  Verified working.
Visibility(Medium): Users will notice new functionality in the CLI

Signed-off-by: Ryan Kubiak <rkubiak@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2303 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/host.py b/cli/host.py
index ea57261..626abbd 100755
--- a/cli/host.py
+++ b/cli/host.py
@@ -188,7 +188,8 @@
             print '-'*5
             self.print_fields(stats,
                               keys=['hostname', 'platform',
-                                    'status', 'locked', 'locked_by'])
+                                    'status', 'locked', 'locked_by',
+                                    'lock_time', 'protection',])
             self.print_by_ids(acls, 'ACLs', line_before=True)
             labels = self._cleanup_labels(labels)
             self.print_by_ids(labels, 'Labels', line_before=True)
@@ -270,13 +271,18 @@
         self.parser.add_option('-d', '--dead',
                                help='Mark this host dead',
                                action='store_true')
-
         self.parser.add_option('-l', '--lock',
                                help='Lock hosts',
                                action='store_true')
         self.parser.add_option('-u', '--unlock',
                                help='Unlock hosts',
                                action='store_true')
+        self.parser.add_option('-p', '--protection', type='choice',
+                               help='Set the protection level on a host.  Must '
+                               'be one of: "Repair filesystem only", '
+                               '"No protection", or "Do not repair"',
+                               choices=('No protection', 'Do not repair',
+                                        'Repair filesystem only'))
 
 
     def parse(self):
@@ -296,6 +302,9 @@
             self.data['status'] = 'Dead'
             self.messages.append('Set status to Dead for host')
 
+        if options.protection:
+            self.data['protection'] = options.protection
+
         if len(self.data) == 0:
             self.invalid_syntax('No modification requested')
         return (options, leftover)
diff --git a/cli/host_unittest.py b/cli/host_unittest.py
index b9a87f9..3bcff12 100755
--- a/cli/host_unittest.py
+++ b/cli/host_unittest.py
@@ -396,6 +396,7 @@
                               u'locked': 1,
                               u'lock_time': u'2008-07-23 12:54:15',
                               u'locked_by': 'user0',
+                              u'protection': 'No protection',
                               u'labels': [u'label3', u'label4', u'plat1'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -408,6 +409,7 @@
                               u'locked': 0,
                               u'locked_by': 'user0',
                               u'lock_time': u'2008-07-23 12:54:15',
+                              u'protection': u'No protection',
                               u'labels': [u'label0', u'plat0'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -468,6 +470,7 @@
                               u'locked': 0,
                               u'locked_by': 'user0',
                               u'lock_time': u'2008-07-23 12:54:15',
+                              u'protection': u'No protection',
                               u'labels': [u'label0', u'plat0'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -517,6 +520,7 @@
                               u'locked': 0,
                               u'locked_by': 'user0',
                               u'lock_time': u'2008-07-23 12:54:15',
+                              u'protection': u'No protection',
                               u'labels': [u'label0', u'plat0'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -564,6 +568,7 @@
                               u'locked': 1,
                               u'lock_time': u'2008-07-23 12:54:15',
                               u'locked_by': 'user0',
+                              u'protection': 'No protection',
                               u'labels': [u'label3', u'label4', u'plat1'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -574,6 +579,7 @@
                               u'locked': 0,
                               u'locked_by': 'user0',
                               u'lock_time': u'2008-07-23 12:54:15',
+                              u'protection': u'No protection',
                               u'labels': [u'label0', u'plat0'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -632,6 +638,7 @@
                               u'locked': 0,
                               u'locked_by': 'user0',
                               u'lock_time': u'2008-07-23 12:54:15',
+                              u'protection': u'No protection',
                               u'labels': [u'label0', u'plat0'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -644,6 +651,7 @@
                               u'locked': 1,
                               u'lock_time': u'2008-07-23 12:54:15',
                               u'locked_by': 'user0',
+                              u'protection': 'No protection',
                               u'labels': [u'label3', u'label4', u'plat1'],
                               u'invalid': 0,
                               u'synch_id': None,
@@ -723,7 +731,7 @@
                               u'kernel_config': u''}])],
                      out_words_ok=['host0', 'host1', 'newhost0',
                                    'plat0', 'plat1',
-                                   'Everyone', 'acl0', 'label0'])
+                                   'Everyone', 'acl10', 'label0'])
 
 
 class host_jobs_unittest(cli_mock.cli_unittest):
diff --git a/cli/topic_common.py b/cli/topic_common.py
index bbec3f6..3eb9270 100755
--- a/cli/topic_common.py
+++ b/cli/topic_common.py
@@ -66,6 +66,7 @@
                     'status': 'Status',
                     'locked': 'Locked',
                     'locked_by': 'Locked by',
+                    'lock_time': 'Locked time',
                     'labels': 'Labels',
                     'description': 'Description',
                     'hosts': 'Hosts',
@@ -90,6 +91,7 @@
                     'synch_type': 'Synch Type',
                     'control_file': 'Control File',
                     'only_if_needed': 'Use only if needed',
+                    'protection': 'Protection',
                     }
 
 # In the failure, tag that will replace the item.