[autotest] Remove atest cli support for specifying a test kernel.

The `atest job create` command provided a -k option for specifying
a kernel to be tested.  The option was a non-functional legacy not
applicable to Chrome OS.

This deletes the legacy atest CLI code.  The underlying RPC calls
and features made obsolete by this change will be removed in
subsequent CLs.

BUG=None
TEST=run `atest job create` in a local Autotest instance, plus unit tests

Change-Id: I882f96bf940f9de8af1ffd502e7b3f59e6fdddb5
Reviewed-on: https://chromium-review.googlesource.com/346058
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/cli/host_unittest.py b/cli/host_unittest.py
index 252c20a..8a824b4 100755
--- a/cli/host_unittest.py
+++ b/cli/host_unittest.py
@@ -4,7 +4,9 @@
 
 """Test for host."""
 
-import unittest, os, sys
+# pylint: disable=missing-docstring
+
+import unittest, sys
 
 import common
 from autotest_lib.cli import cli_mock, host
@@ -1021,10 +1023,6 @@
                               u'job': {u'control_file':
                                        (u"def step_init():\n"
                                         "\tjob.next_step([step_test])\n"
-                                        "\ttestkernel = job.kernel("
-                                        "'kernel-smp-2.6.xyz.x86_64.rpm')\n"
-                                        "\ttestkernel.install()\n"
-                                        "\ttestkernel.boot()\n\n"
                                         "def step_test():\n"
                                         "\tjob.run_test('kernbench')\n\n"),
                                        u'name': u'kernel-smp-2.6.xyz.x86_64',
@@ -1111,10 +1109,6 @@
                               u'job': {u'control_file':
                                        (u"def step_init():\n"
                                         "\tjob.next_step([step_test])\n"
-                                        "\ttestkernel = job.kernel("
-                                        "'kernel-smp-2.6.xyz.x86_64.rpm')\n"
-                                        "\ttestkernel.install()\n"
-                                        "\ttestkernel.boot()\n\n"
                                         "def step_test():\n"
                                         "\tjob.run_test('kernbench')\n\n"),
                                        u'name': u'kernel-smp-2.6.xyz.x86_64',
@@ -1170,10 +1164,6 @@
                               u'job': {u'control_file':
                                        (u"def step_init():\n"
                                         "\tjob.next_step([step_test])\n"
-                                        "\ttestkernel = job.kernel("
-                                        "'kernel-smp-2.6.xyz.x86_64.rpm')\n"
-                                        "\ttestkernel.install()\n"
-                                        "\ttestkernel.boot()\n\n"
                                         "def step_test():\n"
                                         "\tjob.run_test('kernbench')\n\n"),
                                        u'name': u'kernel-smp-2.6.xyz.x86_64',
@@ -1238,10 +1228,6 @@
                               u'job': {u'control_file':
                                        (u"def step_init():\n"
                                         "\tjob.next_step([step_test])\n"
-                                        "\ttestkernel = job.kernel("
-                                        "'kernel-smp-2.6.xyz.x86_64.rpm')\n"
-                                        "\ttestkernel.install()\n"
-                                        "\ttestkernel.boot()\n\n"
                                         "def step_test():\n"
                                         "\tjob.run_test('kernbench')\n\n"),
                                        u'name': u'kernel-smp-2.6.xyz.x86_64',
diff --git a/cli/job.py b/cli/job.py
index 6277f38..b61537e 100644
--- a/cli/job.py
+++ b/cli/job.py
@@ -16,7 +16,9 @@
 See topic_common.py for a High Level Design and Algorithm.
 """
 
-import getpass, os, pwd, re, socket, sys
+# pylint: disable=missing-docstring
+
+import getpass, re
 from autotest_lib.cli import topic_common, action_common
 from autotest_lib.client.common_lib import control_data
 
@@ -356,7 +358,7 @@
 class job_create(job_create_or_clone):
     """atest job create [--priority <Low|Medium|High|Urgent>]
     [--synch_count] [--control-file </path/to/cfile>]
-    [--on-server] [--test <test1,test2>] [--kernel <http://kernel>]
+    [--on-server] [--test <test1,test2>]
     [--mlist </path/to/machinelist>] [--machine <host1 host2 host3>]
     [--labels <list of labels of machines to run on>]
     [--reboot_before <option>] [--reboot_after <option>]
@@ -386,13 +388,6 @@
         self.parser.add_option('-t', '--test',
                                help='List of tests to run')
 
-        self.parser.add_option('-k', '--kernel', help='A comma separated list'
-                               ' of kernel versions/URLs/filenames to run the'
-                               ' job on')
-        self.parser.add_option('--kernel-cmdline', help='A string that will be'
-                               ' given as cmdline to the booted kernel(s)'
-                               ' specified by the -k option')
-
         self.parser.add_option('-d', '--dependencies', help='Comma separated '
                                'list of labels this job is dependent on.',
                                default='')
@@ -435,21 +430,6 @@
                                default=False, action='store_true')
 
 
-    @staticmethod
-    def _get_kernel_data(kernel_list, cmdline):
-        # the RPC supports cmdline per kernel version in a dictionary
-        kernels = []
-        for version in re.split(r'[, ]+', kernel_list):
-            if not version:
-                continue
-            kernel_info = {'version': version}
-            if cmdline:
-                kernel_info['cmdline'] = cmdline
-            kernels.append(kernel_info)
-
-        return kernels
-
-
     def parse(self):
         deps_info = topic_common.item_parse_info(attribute_name='dependencies',
                                                  inline_option='dependencies')
@@ -467,9 +447,6 @@
         if options.control_file and options.test:
             self.invalid_syntax('Can only specify one of --control-file or '
                                 '--test, not both.')
-        if options.kernel:
-            self.ctrl_file_data['kernel'] = self._get_kernel_data(
-                    options.kernel, options.kernel_cmdline)
         if options.control_file:
             try:
                 control_file_f = open(options.control_file)
@@ -480,12 +457,7 @@
             except IOError:
                 self.generic_error('Unable to read from specified '
                                    'control-file: %s' % options.control_file)
-            if options.kernel:
-                # execute() will pass this to the AFE server to wrap this
-                # control file up to include the kernel installation steps.
-                self.ctrl_file_data['client_control_file'] = control_file_data
-            else:
-                self.data['control_file'] = control_file_data
+            self.data['control_file'] = control_file_data
         if options.test:
             if options.server:
                 self.invalid_syntax('If you specify tests, then the '
@@ -530,22 +502,10 @@
 
     def execute(self):
         if self.ctrl_file_data:
-            uploading_kernel = 'kernel' in self.ctrl_file_data
-            if uploading_kernel:
-                default_timeout = socket.getdefaulttimeout()
-                socket.setdefaulttimeout(topic_common.UPLOAD_SOCKET_TIMEOUT)
-                print 'Uploading Kernel: this may take a while...',
-                sys.stdout.flush()
-            try:
-                cf_info = self.execute_rpc(op='generate_control_file',
-                                           item=self.jobname,
-                                           **self.ctrl_file_data)
-            finally:
-                if uploading_kernel:
-                    socket.setdefaulttimeout(default_timeout)
+            cf_info = self.execute_rpc(op='generate_control_file',
+                                       item=self.jobname,
+                                       **self.ctrl_file_data)
 
-            if uploading_kernel:
-                print 'Done'
             self.data['control_file'] = cf_info['control_file']
             if 'synch_count' not in self.data:
                 self.data['synch_count'] = cf_info['synch_count']
diff --git a/cli/job_unittest.py b/cli/job_unittest.py
index bac0ceb..712d48a 100755
--- a/cli/job_unittest.py
+++ b/cli/job_unittest.py
@@ -5,10 +5,12 @@
 
 """Tests for job."""
 
-import copy, getpass, unittest, sys, os
+# pylint: disable=missing-docstring
+
+import copy, getpass, unittest, sys
 
 import common
-from autotest_lib.cli import cli_mock, topic_common, job
+from autotest_lib.cli import cli_mock, job
 from autotest_lib.client.common_lib.test_utils import mock
 from autotest_lib.client.common_lib import control_data
 
@@ -143,7 +145,7 @@
                                                  'running': None},
                             True,
                             [{u'status_counts': {u'Completed': 1},
-                              u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n    job.next_step([step_test])\n    testkernel = job.kernel(\'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\')\n    \n    testkernel.install()\n    testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\',                             seconds = 1)',
+                              u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n    job.next_step([step_test])\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\',                             seconds = 1)',
                               u'name': u'mytest',
                               u'control_type': CLIENT,
                               u'run_verify': 1,
@@ -164,7 +166,7 @@
                                                  'running': None},
                             True,
                             [{u'status_counts': {u'Completed': 1},
-                              u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n    job.next_step([step_test])\n    testkernel = job.kernel(\'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\')\n    \n    testkernel.install()\n    testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\',                             seconds = 1)',
+                              u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n    job.next_step([step_test])\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\',                             seconds = 1)',
                               u'name': u'mytest',
                               u'control_type': CLIENT,
                               u'run_verify': 1,
@@ -186,7 +188,7 @@
                                                  'running': None},
                             True,
                             [{u'status_counts': {u'Completed': 1},
-                              u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n    job.next_step([step_test])\n    testkernel = job.kernel(\'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\')\n    \n    testkernel.install()\n    testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\',                             seconds = 1)',
+                              u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n    job.next_step([step_test])\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\',                             seconds = 1)',
                               u'name': u'mytest',
                               u'control_type': CLIENT,
                               u'run_verify': 1,
@@ -729,7 +731,7 @@
 class job_create_unittest(cli_mock.cli_unittest):
     ctrl_file = '\ndef step_init():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n  TIME =\n    "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n\n    TEST_TYPE = "client"\n \n    DOC = """\n    This test simply sleeps for 1\n    second by default.  It\'s a good way to test\n    profilers and double check\n    that autotest is working.\n The seconds argument can also be modified to\n    make the machine sleep for as\n    long as needed.\n    """\n   \n\n    job.run_test(\'sleeptest\', seconds = 1)'
 
-    kernel_ctrl_file = 'kernel = \'kernel\'\ndef step_init():\n    job.next_step([step_test])\n    testkernel = job.kernel(\'kernel\')\n    \n    testkernel.install()\n    testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\', seconds = 1)'
+    kernel_ctrl_file = 'kernel = \'kernel\'\ndef step_init():\n    job.next_step([step_test])\n\ndef step_test():\n    job.next_step(\'step0\')\n\ndef step0():\n    AUTHOR = "Autotest Team"\n    NAME = "Sleeptest"\n    TIME = "SHORT"\n    TEST_CATEGORY = "Functional"\n    TEST_CLASS = "General"\n    TEST_TYPE = "client"\n    \n    DOC = """\n    This test simply sleeps for 1 second by default.  It\'s a good way to test\n    profilers and double check that autotest is working.\n    The seconds argument can also be modified to make the machine sleep for as\n    long as needed.\n    """\n    \n    job.run_test(\'sleeptest\', seconds = 1)'
 
     trivial_ctrl_file = 'print "Hello"\n'
 
@@ -787,27 +789,6 @@
         file_temp.clean()
 
 
-    def test_execute_create_job_with_control_and_kernel(self):
-        data = self.data.copy()
-        data['control_file'] = '# Made up control "file" for unittest.'
-        file_temp = cli_mock.create_file(self.trivial_ctrl_file)
-        self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name,
-                           '-k', 'Kernel', 'test_job0', '-m', 'host0',
-                           '--ignore_site_file'],
-                     rpcs=[('generate_control_file',
-                            {'client_control_file': self.trivial_ctrl_file,
-                             'kernel': [{'version': 'Kernel'}]},
-                            True,
-                            {'control_file': data['control_file'],
-                             'synch_count': 1,
-                             'is_server': False,
-                             'dependencies': []}),
-                           ('create_job', data, True, 42)],
-                     out_words_ok=['test_job0', 'Created',
-                                   'Uploading', 'Done'])
-        file_temp.clean()
-
-
     def test_execute_create_job_with_control_and_email(self):
         data = self.data.copy()
         data['email_list'] = 'em'
@@ -896,76 +877,6 @@
                      out_words_no=['Uploading', 'Done'])
 
 
-    def test_execute_create_job_with_kernel(self):
-        data = self.data.copy()
-        data['control_file'] = self.kernel_ctrl_file
-        self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest',
-                           '-k', 'kernel', 'test_job0', '-m', 'host0',
-                           '--ignore_site_file'],
-                     rpcs=[('generate_control_file',
-                            {'tests': ['sleeptest'],
-                             'kernel': [{'version': 'kernel'}]
-                             },
-                            True,
-                            {'control_file' : self.kernel_ctrl_file,
-                             'synch_count' : 1,
-                             'is_server' : False,
-                             'dependencies' : []}),
-                           ('create_job', data, True, 180)],
-                     out_words_ok=['test_job0', 'Created',
-                                   'Uploading', 'Done'])
-
-
-    def test_execute_create_job_with_kernels_and_cmdline(self):
-        data = self.data.copy()
-        data['control_file'] = self.kernel_ctrl_file
-        self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest',
-                           '-k', 'kernel1,kernel2', '--kernel-cmdline',
-                           'arg1 arg2', 'test_job0', '-m', 'host0',
-                           '--ignore_site_file'],
-                     rpcs=[('generate_control_file',
-                            {'tests': ['sleeptest'],
-                             'kernel': [{'version': 'kernel1',
-                                         'cmdline': 'arg1 arg2'},
-                                        {'version': 'kernel2',
-                                         'cmdline': 'arg1 arg2'}]
-                             },
-                            True,
-                            {'control_file' : self.kernel_ctrl_file,
-                             'synch_count' : 1,
-                             'is_server' : False,
-                             'dependencies' : []}),
-                           ('create_job', data, True, 180)],
-                     out_words_ok=['test_job0', 'Created',
-                                   'Uploading', 'Done'])
-
-
-    def test_execute_create_job_with_kernel_spaces(self):
-        data = self.data.copy()
-        data['control_file'] = self.kernel_ctrl_file
-        data['name'] = 'test job	with  spaces'
-        self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest',
-                           '-k', 'kernel', 'test job	with  spaces',
-                           '-m', 'host0', '--ignore_site_file'],
-                     rpcs=[('generate_control_file',
-                            {'tests': ['sleeptest'],
-                             'kernel': [{'version': 'kernel'}]
-                             },
-                            True,
-                            {'control_file' : self.kernel_ctrl_file,
-                             'synch_count' : 1,
-                             'is_server' : False,
-                             'dependencies' : []}),
-                           ('create_job', data, True, 180)],
-                     # This is actually 7 spaces, the extra single quote that
-                     # gets displayed before "test" causes the tab completion
-                     # to move to the next 8 char boundary which is 7 characters
-                     # away. Hence the 7 spaces in out_words_ok.
-                     # The tab has been converted by print.
-                     out_words_ok=['test job       with  spaces', 'Created',
-                                   'id', '180'])
-
-
     def test_execute_create_job_no_args(self):
         testjob = job.job_create()
         sys.argv = ['atest', 'job', 'create', '--ignore_site_file']
@@ -1004,18 +915,6 @@
         self.god.check_playback()
 
 
-    def test_execute_create_job_cfile_and_kernel(self):
-        testjob = job.job_create()
-        sys.argv = ['atest', 'job', 'create', '-f', 'control_file', '-k',
-                    'kernel', 'test_job0', '-m', 'host0', '--ignore_site_file']
-        self.god.mock_io()
-        (sys.exit.expect_call(mock.anything_comparator())
-         .and_raises(cli_mock.ExitException))
-        self.assertRaises(cli_mock.ExitException, testjob.parse)
-        self.god.unmock_io()
-        self.god.check_playback()
-
-
     def test_execute_create_job_bad_cfile(self):
         testjob = job.job_create()
         sys.argv = ['atest', 'job', 'create', '-f', 'control_file',