[autotest] make a consistent CONTROL_TYPE enum across the codebase

Prior to this CL, there were a multitude of duplicate defitions of the
two control files types (Client or Server), incluiding a difference
between the afe Job model (1 = Server) and the afe Test model (1 =
Client). This CL introduces enums CONTROL_TYPE and CONTROL_TYPE_NAMES to
control_data, to act as the central and consistent defition across the
codebase. In order to avoid needing to mangle the running Jobs table, we
have adopted the existing Job model convention (1 = Server); the Test
table will be re-written with the new consistent convention during test
import.

BUG=chromium:240643
TEST=All existing unit tests pass;
In local autotest without this patch applied, started a suite. Halfway
through suite, applied this patch, ran test importer, restarted apache,
and restarted scheduler. Suite finished successfully.
Verified manually that Client/Server type control files show up
correctly in afe Create Job view.
DEPLOY=scheduler
DEPLOY=apache
DEPLOY=test_importer

Change-Id: Ia5b2573e1d08d96b3826f2837903ef407dcae303
Reviewed-on: https://gerrit.chromium.org/gerrit/51191
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/frontend/afe/resources.py b/frontend/afe/resources.py
index 83a658b..8c9ced3 100644
--- a/frontend/afe/resources.py
+++ b/frontend/afe/resources.py
@@ -4,6 +4,7 @@
 from autotest_lib.frontend.afe import model_attributes
 from autotest_lib.frontend import thread_local
 from autotest_lib.client.common_lib import host_protections
+from autotest_lib.client.common_lib import control_data
 
 
 class EntryWithInvalid(resource_lib.InstanceEntry):
@@ -379,7 +380,7 @@
         rep.update({'author': self.instance.author,
                     'class': self.instance.test_class,
                     'control_file_type':
-                    model_attributes.TestTypes.get_string(
+                    control_data.CONTROL_TYPE.get_string(
                         self.instance.test_type),
                     'control_file_path': self.instance.path,
                     'sync_count': self.instance.sync_count,
@@ -394,7 +395,7 @@
         cls._check_for_required_fields(input_dict,
                                        ('name', 'control_file_type',
                                         'control_file_path'))
-        test_type = model_attributes.TestTypes.get_value(
+        test_type = control_data.CONTROL_TYPE.get_value(
             input['control_file_type'])
         return models.Test.add_object(name=input_dict['name'],
                                       test_type=test_type,
@@ -470,7 +471,8 @@
     @classmethod
     def execution_info_from_job(cls, job):
         return {'control_file': job.control_file,
-                'is_server': job.control_type == models.Job.ControlType.SERVER,
+                'is_server': 
+                job.control_type == control_data.CONTROL_TYPE.SERVER,
                 'dependencies': [label.name for label
                                  in job.dependency_labels.all()],
                 'machines_per_execution': job.synch_count,
@@ -671,9 +673,9 @@
                                                         'is_server'))
 
         if execution_info['is_server']:
-            control_type = models.Job.ControlType.SERVER
+            control_type = control_data.CONTROL_TYPE.SERVER
         else:
-            control_type = models.Job.ControlType.CLIENT
+            control_type = control_data.CONTROL_TYPE.CLIENT
         options = dict(
                 name=input_dict['name'],
                 priority=input_dict.get('priority', None),