[autotest] [atomic] Remove atomic groups RPC
BUG=chromium:681906
TEST=Run unittest suite
Change-Id: I7b46a4390000a3ed6500b2db0f893b7dfaa04ce6
Reviewed-on: https://chromium-review.googlesource.com/435566
Commit-Ready: Allen Li <[email protected]>
Tested-by: Allen Li <[email protected]>
Reviewed-by: Richard Barnette <[email protected]>
diff --git a/apache/conf/django-directives b/apache/conf/django-directives
index bc2d412..aca3984 100644
--- a/apache/conf/django-directives
+++ b/apache/conf/django-directives
@@ -29,7 +29,7 @@
RewriteCond /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin -d
RewriteRule ^/afe/server/admin/admin/(css|img|js)(.*) /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2
RewriteCond /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin/$2/$3
#
# Django < 1.4 installed by utils/build_externals.py
@@ -37,7 +37,7 @@
RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/media -d
RewriteRule ^/media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/media/$1/$2
RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/media -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/admin/$2/$3
#
# Django >= 1.4 installed by utils/build_externals.py
@@ -48,7 +48,7 @@
RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d
RewriteRule ^/afe/server/admin/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$1/$2
RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$2/$3
#
# Python 2.7 and django >= 1.4 installed by distributions packages
@@ -56,7 +56,7 @@
RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin -d
RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2
RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$2/$3
#
# Python 2.7 and django < 1.4 installed by distributions packages
@@ -64,7 +64,7 @@
RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/media -d
RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/media/$1/$2
RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/media -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/admin/$2/$3
#
# Python 2.6 and django < 1.4 installed by distributions packages
@@ -72,7 +72,7 @@
RewriteCond /usr/lib/python2.6/site-packages/django/contrib/admin/media -d
RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/contrib/admin/media/$1/$2
RewriteCond /usr/lib/python2.6/site-packages/django/contrib/admin/media -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/contrib/admin/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/contrib/admin/admin/$2/$3
#
# Python 2.5 and django < 1.4 installed by distributions packages
@@ -80,7 +80,7 @@
RewriteCond /usr/lib/python2.5/site-packages/django/contrib/admin/media -d
RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.5/site-packages/django/contrib/admin/media/$1/$2
RewriteCond /usr/lib/python2.5/site-packages/django/contrib/admin/media -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.5/site-packages/django/contrib/admin/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.5/site-packages/django/contrib/admin/admin/$2/$3
#
# Python 2.4 and django < 1.4 installed by distributions packages
@@ -88,7 +88,7 @@
RewriteCond /usr/lib/python2.4/site-packages/django/contrib/admin/media -d
RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/media/$1/$2
RewriteCond /usr/lib/python2.4/site-packages/django/contrib/admin/media -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/admin/$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/admin/$2/$3
#
# Generic Python shared dir and django < 1.4 installed by Debian like packages
@@ -96,7 +96,7 @@
RewriteCond /usr/share/pyshared/django/contrib/admin/media -d
RewriteRule ^/media/(css|img|js)(.*) /usr/share/pyshared/django/contrib/admin/media/$1/$2
RewriteCond /usr/share/pyshared/django/contrib/admin/media -d
-RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/share/pyshared/django/contrib/admin/media$2/$3
+RewriteRule ^/afe/server/admin/afe/(aclgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/share/pyshared/django/contrib/admin/media$2/$3
#
# Configuration for mod_wsgi
diff --git a/cli/host_unittest.py b/cli/host_unittest.py
index 7011252..55f6d55 100755
--- a/cli/host_unittest.py
+++ b/cli/host_unittest.py
@@ -198,7 +198,7 @@
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True', 'None'],
out_words_no=['host0', 'host2',
- 'label1', 'label4', 'False'])
+ 'label1', 'False'])
def test_execute_list_filter_two_hosts(self):
@@ -225,14 +225,14 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'False'])
mfile.clean()
@@ -250,13 +250,13 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['Ready', 'plat1',
- 'label3', 'label4', 'True', 'None'],
+ 'label3', 'True', 'None'],
out_words_no=['host1', 'False'],
err_words_ok=['host1'])
mfile.clean()
@@ -296,14 +296,14 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'False'])
@@ -337,15 +337,14 @@
u'id': 4}])],
out_words_ok=['host1', 'host3', 'Ready', 'plat0',
'label2', 'label3', 'plat2', 'None'],
- out_words_no=['host2', 'label4', 'False', 'plat1'])
+ out_words_no=['host2', 'False', 'plat1'])
def test_execute_list_filter_three_labels(self):
self.run_cmd(argv=['atest', 'host', 'list',
- '-b', 'label3,label2, label4'],
+ '-b', 'label3,label2'],
rpcs=[('get_hosts', {'multiple_labels': ['label2',
- 'label3',
- 'label4']},
+ 'label3']},
True,
[{u'status': u'Ready',
u'hostname': u'host2',
@@ -353,14 +352,13 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label2', u'label4',
- u'plat1'],
+ u'labels': [u'label3', u'label2', u'plat1'],
u'invalid': False,
u'platform': u'plat1',
u'shard': None,
u'id': 3}])],
out_words_ok=['host2', 'plat1',
- 'label2', 'label3', 'label4', 'None'],
+ 'label2', 'label3', 'None'],
out_words_no=['host1', 'host3'])
@@ -377,13 +375,12 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label2', u'label4',
- u'plat1'],
+ u'labels': [u'label3', u'label2', u'plat1'],
u'invalid': 0,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host2', 'plat1',
- 'label2', 'label3', 'label4', 'None'],
+ 'label2', 'label3', 'None'],
out_words_no=['host1', 'host3'])
@@ -396,7 +393,7 @@
[])],
out_words_ok=[],
out_words_no=['host1', 'host2', 'host3',
- 'label2', 'label3', 'label4'])
+ 'label2', 'label3'])
def test_execute_list_filter_label_and_hosts(self):
@@ -422,14 +419,14 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'False'])
@@ -467,14 +464,14 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'False'])
@@ -502,14 +499,14 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'False'])
@@ -562,14 +559,14 @@
u'locked_by': 'user0',
u'lock_reason': u'',
u'lock_time': u'2008-07-23 12:54:15',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'True',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'False'])
@@ -595,14 +592,14 @@
u'locked_by': 'user0',
u'lock_time': u'2008-07-23 12:54:15',
u'lock_reason': u'',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
u'id': 3}])],
out_words_ok=['host1', 'Ready', 'plat1',
'label2', 'label3', 'False',
- 'host2', 'label4', 'None'],
+ 'host2', 'None'],
out_words_no=['host0', 'label1', 'True'])
@@ -619,7 +616,7 @@
u'locked_by': 'user0',
u'lock_reason': u'',
u'protection': 'No protection',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'shard': None,
u'platform': u'plat1',
@@ -795,7 +792,7 @@
u'locked_by': 'user0',
u'lock_reason': u'',
u'protection': 'No protection',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'platform': u'plat1',
u'id': 3,
@@ -880,7 +877,7 @@
u'locked_by': 'user0',
u'lock_reason': u'',
u'protection': 'No protection',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'platform': u'plat1',
u'id': 3,
@@ -1033,7 +1030,7 @@
u'locked': True,
u'lock_time': u'2008-07-23 12:54:15',
u'locked_by': 'user0',
- u'labels': [u'label3', u'label4', u'plat1'],
+ u'labels': [u'label3', u'plat1'],
u'invalid': False,
u'platform': u'plat1',
u'id': 3},
diff --git a/frontend/afe/admin.py b/frontend/afe/admin.py
index 5124750..8c0ae41 100644
--- a/frontend/afe/admin.py
+++ b/frontend/afe/admin.py
@@ -2,7 +2,6 @@
from django import forms
from django.contrib import admin, messages
-from django.db import models as dbmodels
from django.forms.util import flatatt
from django.utils.encoding import smart_str
from django.utils.safestring import mark_safe
@@ -61,11 +60,8 @@
class LabelAdmin(SiteAdmin):
- list_display = ('name', 'atomic_group', 'kernel_config')
- # Avoid a bug with the admin interface showing a select box pointed at an
- # AtomicGroup when this field is intentionally NULL such that editing a
- # label via the admin UI unintentionally sets an atomicgroup.
- raw_id_fields = ('atomic_group',)
+ list_display = ('name', 'kernel_config')
+ raw_id_fields = ()
form = LabelForm
diff --git a/frontend/afe/doctests/001_rpc_test.txt b/frontend/afe/doctests/001_rpc_test.txt
index 89e29d6..931b741 100644
--- a/frontend/afe/doctests/001_rpc_test.txt
+++ b/frontend/afe/doctests/001_rpc_test.txt
@@ -112,7 +112,6 @@
... 'synch_id': None,
... 'status': 'Ready',
... 'labels': [],
-... 'atomic_group': None,
... 'acls': ['Everyone'],
... 'platform': None,
... 'attributes': {},
@@ -556,7 +555,6 @@
... hosts=['host2'],
... synch_count=1)
>>> info = rpc_interface.get_info_for_clone(job_id, False)
->>> info['atomic_group_name']
>>> info['meta_host_counts']
{}
>>> info['job']['dependencies']
@@ -607,249 +605,3 @@
>>> data = rpc_interface.get_acl_groups(name='Everyone')[0]
>>> sorted(data['hosts'])
[u'host1', u'host2']
-
-# atomic groups
-# #############
-
-# Add an atomic group and associate some labels and new hosts with it.
->>> mini_rack_group_id = rpc_interface.add_atomic_group(
-... name='mini rack',
-... max_number_of_machines=10,
-... description='a partial rack-o-machines')
-
->>> label_id = rpc_interface.add_label(name='one-label')
->>> rpc_interface.modify_label(label_id, atomic_group='mini rack')
->>> labels = rpc_interface.get_labels(id=label_id)
->>> assert labels[0]['atomic_group']['id'] == mini_rack_group_id, labels
->>> rpc_interface.modify_label(label_id, atomic_group=None)
->>> labels = rpc_interface.get_labels(id=label_id)
->>> assert not labels[0]['atomic_group'], labels
->>> rpc_interface.modify_label(label_id, atomic_group='mini rack')
->>> labels = rpc_interface.get_labels(id=label_id)
->>> assert labels[0]['atomic_group']['id'] == mini_rack_group_id, labels
->>> data = rpc_interface.get_labels(atomic_group__name='mini rack')
->>> assert len(data) == 1
->>> assert data[0]['name'] == 'one-label', data
->>> assert data[0]['atomic_group']['id'] == mini_rack_group_id, data
-
->>> data = rpc_interface.get_atomic_groups()
->>> assert len(data) == 1
->>> assert data[0]['id'] == mini_rack_group_id, data
->>> assert data[0]['max_number_of_machines'] == 10, data
->>> assert data[0]['description'] == 'a partial rack-o-machines', data
-
->>> rpc_interface.modify_atomic_group(1, max_number_of_machines=8)
->>> data = rpc_interface.get_atomic_groups()
->>> assert data[0]['max_number_of_machines'] == 8, data
-
->>> unused = rpc_interface.add_host(hostname='ahost1')
->>> unused = rpc_interface.add_host(hostname='ahost2')
->>> unused = rpc_interface.add_host(hostname='ah3-blue')
->>> unused = rpc_interface.add_host(hostname='ah4-blue')
->>> two_id = rpc_interface.add_label(name='two-label')
->>> rpc_interface.label_add_hosts(
-... id=two_id, hosts=['ahost1', 'ahost2', 'ah3-blue', 'ah4-blue'])
->>> unused = rpc_interface.add_label(name='red-label')
->>> blue_id = rpc_interface.add_label(name='blue-label')
->>> rpc_interface.label_add_hosts(id=blue_id, hosts=['ah3-blue', 'ah4-blue'])
-
->>> rpc_interface.atomic_group_add_labels(mini_rack_group_id,
-... ['one-label', 'two-label',
-... 'red-label'])
->>> ag_labels = rpc_interface.get_labels(atomic_group__name='mini rack')
->>> len(ag_labels)
-3
->>> hosts_in_two = rpc_interface.get_hosts(multiple_labels=['two-label'])
->>> list(sorted(h['hostname'] for h in hosts_in_two))
-[u'ah3-blue', u'ah4-blue', u'ahost1', u'ahost2']
->>> rpc_interface.atomic_group_remove_labels(mini_rack_group_id, ['red-label'])
->>> ag_labels = rpc_interface.get_labels(atomic_group__name='mini rack')
->>> sorted(label['name'] for label in ag_labels)
-[u'one-label', u'two-label']
-
->>> host_list = rpc_interface.get_hosts()
->>> hosts_by_name = {}
->>> for host in host_list:
-... hosts_by_name[host['hostname']] = host
-...
->>> hosts_by_name['host1']['atomic_group']
->>> hosts_by_name['ahost1']['atomic_group']
-u'mini rack'
->>> hosts_by_name['ah3-blue']['atomic_group']
-u'mini rack'
->>> host_list = rpc_interface.get_hosts(labels__atomic_group__name='mini rack')
->>> list(sorted(h['hostname'] for h in host_list))
-[u'ah3-blue', u'ah4-blue', u'ahost1', u'ahost2']
-
-
-
-## Test creation of a job in an atomic group without specifying any
-## hosts or meta_hosts.
-
->>> job_id = rpc_interface.create_job(
-... name='atomic_sleeptest', priority=30,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server', synch_count=1,
-... atomic_group_name='mini rack')
-
-## Test creation of a job in an atomic group by specifying the atomic group
-## name as a meta_host rather than explicitly using the atomic_group_name
-## parameter.
-
->>> job_id = rpc_interface.create_job(
-... name='atomic_sleeptest', priority=30,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server', synch_count=1,
-... meta_hosts=['mini rack'])
->>> job_id = rpc_interface.create_job(
-... name='atomic_sleeptest', priority=30,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server', synch_count=1,
-... meta_hosts=['mini rack'],
-... atomic_group_name='Different')
-Traceback (most recent call last):
-ValidationError: {'meta_hosts': 'Label "mini rack" not found. If assumed to be an atomic group it would conflict with the supplied atomic group "Different".'}
-
-## Test job creation with an atomic group.
-
-# fail to create a job in an atomic group. one_time_hosts not allowed.
->>> rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... one_time_hosts=['hostX', 'hostY'],
-... synch_count=2,
-... atomic_group_name='mini rack')
-Traceback (most recent call last):
-ValidationError: {'one_time_hosts': 'One time hosts cannot be used with an Atomic Group.'}
-
-# fail to create a job in an atomic group. Synch count larger than max
->>> rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... synch_count=25,
-... atomic_group_name='mini rack')
-Traceback (most recent call last):
-ValidationError: {'atomic_group_name': 'You have requested a synch_count (25) greater than the maximum machines in the requested Atomic Group (8).'}
-
-# fail to create a job in an atomic group. not enough hosts due to host list.
->>> rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... hosts=['ahost1', 'ahost2'],
-... synch_count=3,
-... atomic_group_name='mini rack')
-Traceback (most recent call last):
-ValidationError: {'hosts': 'only 2 hosts provided for job with synch_count = 3'}
-
-# fail to create a job in an atomic group. hosts not in atomic group.
->>> rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... hosts=['host1', 'host2'],
-... synch_count=2,
-... atomic_group_name='mini rack')
-Traceback (most recent call last):
-ValidationError: {'hosts': u'Hosts "host1, host2" are not in Atomic Group "mini rack"'}
-
-# fail to create a job in an atomic group. not enough hosts due to meta_hosts.
->>> rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... meta_hosts=['blue-label'],
-... synch_count=4,
-... atomic_group_name='mini rack')
-Traceback (most recent call last):
-ValidationError: {'atomic_group_name': u'Insufficient hosts in Atomic Group "mini rack" with the supplied dependencies and meta_hosts.'}
-
-# fail to create a job in an atomic group. not enough hosts.
->>> rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... synch_count=5,
-... atomic_group_name='mini rack')
-Traceback (most recent call last):
-ValidationError: {'atomic_group_name': u'Insufficient hosts in Atomic Group "mini rack" with the supplied dependencies and meta_hosts.'}
-
-# create a job in an atomic group.
->>> job_id = rpc_interface.create_job(name='my_atomic_job',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server',
-... hosts=['ahost1', 'ahost2'],
-... meta_hosts=['blue-label'],
-... synch_count=4,
-... atomic_group_name='mini rack')
-
->>> data = rpc_interface.get_host_queue_entries(job__id=job_id)
->>> data[0]['atomic_group']['id']
-1
-
-# create a job using hosts in an atomic group but forget to specify the group.
->>> rpc_interface.create_job(name='poke_foo',
-... priority=10,
-... control_file=cf_info_pi['control_file'],
-... control_type='Client',
-... hosts=['ahost1', 'ahost2'])
-Traceback (most recent call last):
-ValidationError: {'hosts': u'Host(s) "ahost1, ahost2" are atomic group hosts but no atomic group was specified for this job.'}
-
-# Create a job using a label in an atomic group as the meta-host but forget
-# to specify the group. The frontend should figure this out for us.
->>> job_id = rpc_interface.create_job(name='created_without_explicit_ag',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Client',
-... meta_hosts=['two-label'])
-
->>> job_id = rpc_interface.create_job(
-... name='atomic_sleeptest', priority=30,
-... control_file=cf_info_pi['control_file'],
-... control_type='Server', synch_count=1,
-... meta_hosts=['two-label'],
-... dependencies=['blue-label'])
->>> peon_user = models.User(login='peon_user')
->>> peon_user.access_level = 0
->>> from autotest_lib.client.common_lib.test_utils import mock
->>> god = mock.mock_god()
->>> god.stub_function(models.User, "current_user")
->>> models.User.current_user.expect_call().and_return(peon_user)
->>> rpc_interface.abort_host_queue_entries(job__id=job_id)
-Traceback (most recent call last):
-AclAccessViolation: You cannot abort the following job entries: 8-debug_user/two-label
->>> god.check_playback()
->>> god.unstub_all()
-
->>> rpc_interface.create_job(name='never_run2',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Client',
-... meta_hosts=['blue-label'],
-... dependencies=['two-label'])
-Traceback (most recent call last):
-ValidationError: {'atomic_group_name': "Dependency u'two-label' requires an atomic group but no atomic_group_name or meta_host in an atomic group was specified for this job."}
-
->>> invisible_group_id = rpc_interface.add_atomic_group(
-... name='invisible rack',
-... max_number_of_machines=3,
-... description='a hidden rack-o-machines')
->>> rpc_interface.atomic_group_add_labels(invisible_group_id,
-... ['blue-label'])
->>> rpc_interface.create_job(name='never_run3',
-... priority=50,
-... control_file=cf_info_pi['control_file'],
-... control_type='Client',
-... meta_hosts=['two-label'],
-... atomic_group_name='invisible rack')
-Traceback (most recent call last):
-ValidationError: {'atomic_group_name': "meta_hosts or dependency u'two-label' requires atomic group u'mini rack' instead of the supplied atomic_group_name=u'invisible rack'."}
-
-# we're done testing atomic groups, clean up
->>> rpc_interface.delete_atomic_group(invisible_group_id)
->>> rpc_interface.delete_atomic_group(mini_rack_group_id)
->>> assert len(rpc_interface.get_atomic_groups()) == 0
diff --git a/frontend/afe/frontend_test_utils.py b/frontend/afe/frontend_test_utils.py
index 6ff7041..92ae9d1 100644
--- a/frontend/afe/frontend_test_utils.py
+++ b/frontend/afe/frontend_test_utils.py
@@ -27,41 +27,25 @@
models.AclGroup.smart_get('Everyone').hosts = []
self.labels = [models.Label.objects.create(name=name) for name in
- ('label1', 'label2', 'label3', 'label4', 'label5',
- 'label6', 'label7', 'label8', 'unused')]
+ ('label1', 'label2', 'label3',
+ 'label6', 'label7', 'unused')]
platform = models.Label.objects.create(name='myplatform', platform=True)
for host in self.hosts:
host.labels.add(platform)
- atomic_group1 = models.AtomicGroup.objects.create(
- name='atomic1', max_number_of_machines=2)
- atomic_group2 = models.AtomicGroup.objects.create(
- name='atomic2', max_number_of_machines=2)
+ self.label1, self.label2, self.label3, self.label6, self.label7, _ \
+ = self.labels
- self.label3 = self.labels[2]
self.label3.only_if_needed = True
self.label3.save()
- self.label4 = self.labels[3]
- self.label4.atomic_group = atomic_group1
- self.label4.save()
- self.label5 = self.labels[4]
- self.label5.atomic_group = atomic_group1
- self.label5.save()
- self.hosts[0].labels.add(self.labels[0]) # label1
- self.hosts[1].labels.add(self.labels[1]) # label2
- self.label6 = self.labels[5]
- self.label7 = self.labels[6]
- self.label8 = self.labels[7]
- self.label8.atomic_group = atomic_group2
- self.label8.save()
+ self.hosts[0].labels.add(self.label1)
+ self.hosts[1].labels.add(self.label2)
for hostnum in xrange(4,7): # host5..host7
- self.hosts[hostnum].labels.add(self.label4) # an atomic group lavel
- self.hosts[hostnum].labels.add(self.label6) # a normal label
+ self.hosts[hostnum].labels.add(self.label6)
self.hosts[6].labels.add(self.label7)
for hostnum in xrange(7,9): # host8..host9
- self.hosts[hostnum].labels.add(self.label5) # an atomic group lavel
- self.hosts[hostnum].labels.add(self.label6) # a normal label
+ self.hosts[hostnum].labels.add(self.label6)
self.hosts[hostnum].labels.add(self.label7)
@@ -82,7 +66,7 @@
def _create_job(self, hosts=[], metahosts=[], priority=0, active=False,
- synchronous=False, atomic_group=None, hostless=False,
+ synchronous=False, hostless=False,
drone_set=None, control_file='control',
parameterized_job=None, owner='autotest_system',
parent_job_id=None):
@@ -97,12 +81,8 @@
@param active - bool, mark this job as running or not in the database?
@param synchronous - bool, if True use synch_count=2 otherwise use
synch_count=1.
- @param atomic_group - An atomic group id for this job to schedule on
- or None if atomic scheduling is not required. Each metahost
- becomes a request to schedule an entire atomic group.
- This does not support creating an active atomic group job.
@param hostless - if True, this job is intended to be hostless (in that
- case, hosts, metahosts, and atomic_group must all be empty)
+ case, hosts, and metahosts must all be empty)
@param owner - The owner of the job. Aclgroups from which a job can
acquire hosts change with the aclgroups of the owners.
@param parent_job_id - The id of a parent_job. If a job with the id
@@ -117,7 +97,6 @@
drone_set = (models.DroneSet.default_drone_set_name()
and models.DroneSet.get_default())
- assert not (atomic_group and active) # TODO(gps): support this
synch_count = synchronous and 2 or 1
created_on = datetime.datetime(2008, 1, 1)
status = models.HostQueueEntry.Status.QUEUED
@@ -141,22 +120,14 @@
for host_id in hosts:
models.HostQueueEntry.objects.create(job=job, host_id=host_id,
- status=status,
- atomic_group_id=atomic_group)
+ status=status)
models.IneligibleHostQueue.objects.create(job=job, host_id=host_id)
for label_id in metahosts:
models.HostQueueEntry.objects.create(job=job, meta_host_id=label_id,
- status=status,
- atomic_group_id=atomic_group)
- if atomic_group and not (metahosts or hosts):
- # Create a single HQE to request the atomic group of hosts even if
- # no metahosts or hosts are supplied.
- models.HostQueueEntry.objects.create(job=job,
- status=status,
- atomic_group_id=atomic_group)
+ status=status)
if hostless:
- assert not (hosts or metahosts or atomic_group)
+ assert not (hosts or metahosts)
models.HostQueueEntry.objects.create(job=job, status=status)
return job
diff --git a/frontend/afe/moblab_rpc_interface.py b/frontend/afe/moblab_rpc_interface.py
index da513ad..d73aea8 100644
--- a/frontend/afe/moblab_rpc_interface.py
+++ b/frontend/afe/moblab_rpc_interface.py
@@ -503,7 +503,7 @@
leases = _get_dhcp_dut_leases()
# Get a list of the AFE configured DUT's
- hosts = list(rpc_utils.get_host_query((), False, False, True, {}))
+ hosts = list(rpc_utils.get_host_query((), False, True, {}))
models.Host.objects.populate_relationships(hosts, models.Label,
'label_list')
configured_duts = {}
@@ -600,14 +600,14 @@
def _get_connected_dut_labels(requested_label, only_first_label=True):
""" Query the DUT's attached to the moblab and return a filtered list of labels.
-
+
@param requested_label: the label name you are requesting.
@param only_first_label: if the device has the same label name multiple times only
return the first label value in the list.
@return: A de-duped list of requested dut labels attached to the moblab.
"""
- hosts = list(rpc_utils.get_host_query((), False, False, True, {}))
+ hosts = list(rpc_utils.get_host_query((), False, True, {}))
if not hosts:
return []
models.Host.objects.populate_relationships(hosts, models.Label,
diff --git a/frontend/afe/models.py b/frontend/afe/models.py
index 097c514..866936a 100644
--- a/frontend/afe/models.py
+++ b/frontend/afe/models.py
@@ -124,16 +124,14 @@
self.test_set.clear()
- def enqueue_job(self, job, atomic_group=None, is_template=False):
+ def enqueue_job(self, job, is_template=False):
"""Enqueue a job on any host of this label.
@param job: A job to enqueue.
- @param atomic_group: The associated atomic group.
@param is_template: Whether the status should be "Template".
"""
queue_entry = HostQueueEntry.create(meta_host=self, job=job,
- is_template=is_template,
- atomic_group=atomic_group)
+ is_template=is_template)
queue_entry.save()
@@ -627,16 +625,14 @@
logging.info(self.hostname + ' -> ' + self.status)
- def enqueue_job(self, job, atomic_group=None, is_template=False):
+ def enqueue_job(self, job, is_template=False):
"""Enqueue a job on this host.
@param job: A job to enqueue.
- @param atomic_group: The associated atomic group.
@param is_template: Whther the status should be "Template".
"""
queue_entry = HostQueueEntry.create(host=self, job=job,
- is_template=is_template,
- atomic_group=atomic_group)
+ is_template=is_template)
# allow recovery of dead hosts from the frontend
if not self.active_queue_entry() and self.is_dead():
self.status = Host.Status.READY
@@ -1572,27 +1568,20 @@
super(Job, self).save(*args, **kwargs)
- def queue(self, hosts, atomic_group=None, is_template=False):
+ def queue(self, hosts, is_template=False):
"""Enqueue a job on the given hosts.
@param hosts: The hosts to use.
- @param atomic_group: The associated atomic group.
@param is_template: Whether the status should be "Template".
"""
if not hosts:
- if atomic_group:
- # No hosts or labels are required to queue an atomic group
- # Job. However, if they are given, we respect them below.
- atomic_group.enqueue_job(self, is_template=is_template)
- else:
- # hostless job
- entry = HostQueueEntry.create(job=self, is_template=is_template)
- entry.save()
+ # hostless job
+ entry = HostQueueEntry.create(job=self, is_template=is_template)
+ entry.save()
return
for host in hosts:
- host.enqueue_job(self, atomic_group=atomic_group,
- is_template=is_template)
+ host.enqueue_job(self, is_template=is_template)
def user(self):
@@ -1756,7 +1745,7 @@
@classmethod
- def create(cls, job, host=None, meta_host=None, atomic_group=None,
+ def create(cls, job, host=None, meta_host=None,
is_template=False):
"""Creates a new host queue entry.
@@ -1764,7 +1753,6 @@
@param job: The associated job.
@param host: The associated host.
@param meta_host: The associated meta host.
- @param atomic_group: The associated atomic group.
@param is_template: Whether the status should be "Template".
"""
if is_template:
@@ -1772,8 +1760,7 @@
else:
status = cls.Status.QUEUED
- return cls(job=job, host=host, meta_host=meta_host,
- atomic_group=atomic_group, status=status)
+ return cls(job=job, host=host, meta_host=meta_host, status=status)
def save(self, *args, **kwargs):
@@ -1793,16 +1780,13 @@
def host_or_metahost_name(self):
"""Returns the first non-None name found in priority order.
- The priority order checked is: (1) host name; (2) meta host name; and
- (3) atomic group name.
+ The priority order checked is: (1) host name; (2) meta host name
"""
if self.host:
return self.host.hostname
- elif self.meta_host:
- return self.meta_host.name
else:
- assert self.atomic_group, "no host, meta_host or atomic group!"
- return self.atomic_group.name
+ assert self.meta_host
+ return self.meta_host.name
def _set_active_and_complete(self):
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index c1a015b..f7f8021 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -274,38 +274,7 @@
labels = models.Label.query_objects(filter_data)
for exclude_filter in exclude_filters:
labels = labels.exclude(**exclude_filter)
- return rpc_utils.prepare_rows_as_nested_dicts(labels, ('atomic_group',))
-
-
-# atomic groups
-
-def add_atomic_group(name, max_number_of_machines=None, description=None):
- return models.AtomicGroup.add_object(
- name=name, max_number_of_machines=max_number_of_machines,
- description=description).id
-
-
-def modify_atomic_group(id, **data):
- models.AtomicGroup.smart_get(id).update_object(data)
-
-
-def delete_atomic_group(id):
- models.AtomicGroup.smart_get(id).delete()
-
-
-def atomic_group_add_labels(id, labels):
- label_objs = models.Label.smart_get_bulk(labels)
- models.AtomicGroup.smart_get(id).label_set.add(*label_objs)
-
-
-def atomic_group_remove_labels(id, labels):
- label_objs = models.Label.smart_get_bulk(labels)
- models.AtomicGroup.smart_get(id).label_set.remove(*label_objs)
-
-
-def get_atomic_groups(**filter_data):
- return rpc_utils.prepare_for_serialization(
- models.AtomicGroup.list_objects(filter_data))
+ return rpc_utils.prepare_rows_as_nested_dicts(labels, ())
# hosts
@@ -509,7 +478,7 @@
@param host_filter_data: filter data to apply to Hosts to choose hosts to
act upon
"""
- hosts = rpc_utils.get_host_query((), False, False, True, host_filter_data)
+ hosts = rpc_utils.get_host_query((), False, True, host_filter_data)
hosts = list(hosts)
models.Host.objects.populate_relationships(hosts, models.HostAttribute,
'attribute_list')
@@ -546,22 +515,18 @@
def get_hosts(multiple_labels=(), exclude_only_if_needed_labels=False,
- exclude_atomic_group_hosts=False, valid_only=True,
- include_current_job=False, **filter_data):
+ valid_only=True, include_current_job=False, **filter_data):
"""Get a list of dictionaries which contains the information of hosts.
@param multiple_labels: match hosts in all of the labels given. Should
be a list of label names.
@param exclude_only_if_needed_labels: Exclude hosts with at least one
"only_if_needed" label applied.
- @param exclude_atomic_group_hosts: Exclude hosts that have one or more
- atomic group labels associated with them.
@param include_current_job: Set to True to include ids of currently running
job and special task.
"""
hosts = rpc_utils.get_host_query(multiple_labels,
exclude_only_if_needed_labels,
- exclude_atomic_group_hosts,
valid_only, filter_data)
hosts = list(hosts)
models.Host.objects.populate_relationships(hosts, models.Label,
@@ -574,8 +539,7 @@
for host_obj in hosts:
host_dict = host_obj.get_object_dict()
host_dict['labels'] = [label.name for label in host_obj.label_list]
- host_dict['platform'], host_dict['atomic_group'] = (rpc_utils.
- find_platform_and_atomic_group(host_obj))
+ host_dict['platform'] = rpc_utils.find_platform(host_obj)
host_dict['acls'] = [acl.name for acl in host_obj.acl_list]
host_dict['attributes'] = dict((attribute.attribute, attribute.value)
for attribute in host_obj.attribute_list)
@@ -598,8 +562,7 @@
def get_num_hosts(multiple_labels=(), exclude_only_if_needed_labels=False,
- exclude_atomic_group_hosts=False, valid_only=True,
- **filter_data):
+ valid_only=True, **filter_data):
"""
Same parameters as get_hosts().
@@ -607,7 +570,6 @@
"""
hosts = rpc_utils.get_host_query(multiple_labels,
exclude_only_if_needed_labels,
- exclude_atomic_group_hosts,
valid_only, filter_data)
return hosts.count()
@@ -806,7 +768,6 @@
hosts=(),
meta_hosts=(),
one_time_hosts=(),
- atomic_group_name=None,
synch_count=None,
is_template=False,
timeout=None,
@@ -887,7 +848,6 @@
hosts=hosts,
meta_hosts=meta_hosts,
one_time_hosts=one_time_hosts,
- atomic_group_name=atomic_group_name,
synch_count=synch_count,
is_template=is_template,
timeout=timeout,
@@ -972,7 +932,6 @@
hosts=(),
meta_hosts=(),
one_time_hosts=(),
- atomic_group_name=None,
synch_count=None,
is_template=False,
timeout=None,
@@ -1022,7 +981,6 @@
@param meta_hosts List where each entry is a label name, and for each entry
one host will be chosen from that label to run the job on.
@param one_time_hosts List of hosts not in the database to run the job on.
- @param atomic_group_name The name of an atomic group to schedule the job on.
@param drone_set The name of the drone set to run this test on.
@param image OS image to install before running job.
@param parent_job_id id of a job considered to be parent of created job.
@@ -1052,7 +1010,6 @@
hosts=hosts,
meta_hosts=meta_hosts,
one_time_hosts=one_time_hosts,
- atomic_group_name=atomic_group_name,
synch_count=synch_count,
is_template=is_template,
timeout=timeout,
@@ -1305,10 +1262,6 @@
meta_host_counts=meta_host_counts,
hosts=host_dicts)
info['job']['dependencies'] = job_info['dependencies']
- if job_info['atomic_group']:
- info['atomic_group_name'] = (job_info['atomic_group']).name
- else:
- info['atomic_group_name'] = None
info['hostless'] = job_info['hostless']
info['drone_set'] = job.drone_set and job.drone_set.name
@@ -1376,7 +1329,7 @@
**filter_data)
return rpc_utils.prepare_rows_as_nested_dicts(
models.HostQueueEntry.query_objects(filter_data),
- ('host', 'atomic_group', 'job'))
+ ('host', 'job'))
def get_num_host_queue_entries(start_time=None, end_time=None, **filter_data):
@@ -1654,7 +1607,6 @@
users: Sorted list of all users.
labels: Sorted list of labels not start with 'cros-version' and
'fw-version'.
- atomic_groups: Sorted list of all atomic groups.
tests: Sorted list of all tests.
profilers: Sorted list of all profilers.
current_user: Logged-in username.
@@ -1692,7 +1644,6 @@
label_exclude_filters,
sort_by=['-platform', 'name'])
- result['atomic_groups'] = get_atomic_groups(sort_by=['name'])
result['tests'] = get_tests(sort_by=['name'])
result['profilers'] = get_profilers(sort_by=['name'])
result['current_user'] = rpc_utils.prepare_for_serialization(
diff --git a/frontend/afe/rpc_interface_unittest.py b/frontend/afe/rpc_interface_unittest.py
index 89a7144..85d8ee4 100755
--- a/frontend/afe/rpc_interface_unittest.py
+++ b/frontend/afe/rpc_interface_unittest.py
@@ -46,10 +46,6 @@
def test_validation(self):
- # non-number for a numeric field
- self.assertRaises(model_logic.ValidationError,
- rpc_interface.add_atomic_group, name='foo',
- max_number_of_machines='bar')
# omit a required field
self.assertRaises(model_logic.ValidationError, rpc_interface.add_label,
name=None)
@@ -87,7 +83,6 @@
host = hosts[0]
self.assertEquals(sorted(host['labels']), ['label1', 'myplatform'])
self.assertEquals(host['platform'], 'myplatform')
- self.assertEquals(host['atomic_group'], None)
self.assertEquals(host['acls'], ['my_acl'])
self.assertEquals(host['attributes'], {})
@@ -106,23 +101,6 @@
self._check_hostnames(hosts, ['host2'])
- def test_get_hosts_exclude_atomic_group_hosts(self):
- hosts = rpc_interface.get_hosts(
- exclude_atomic_group_hosts=True,
- hostname__in=['host4', 'host5', 'host6'])
- self._check_hostnames(hosts, ['host4'])
-
-
- def test_get_hosts_exclude_both(self):
- self.hosts[0].labels.add(self.label3)
-
- hosts = rpc_interface.get_hosts(
- hostname__in=['host1', 'host2', 'host5'],
- exclude_only_if_needed_labels=True,
- exclude_atomic_group_hosts=True)
- self._check_hostnames(hosts, ['host2'])
-
-
def test_job_keyvals(self):
keyval_dict = {'mykey': 'myvalue'}
job_id = rpc_interface.create_job(name='test',
@@ -262,7 +240,6 @@
self.assertEquals(len(queue_entries), 1)
self.assertEquals(queue_entries[0].host, None)
self.assertEquals(queue_entries[0].meta_host, None)
- self.assertEquals(queue_entries[0].atomic_group, None)
def _setup_special_tasks(self):
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index b98ecc0..ea2eac8 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -198,7 +198,7 @@
def get_host_query(multiple_labels, exclude_only_if_needed_labels,
- exclude_atomic_group_hosts, valid_only, filter_data):
+ valid_only, filter_data):
if valid_only:
query = models.Host.valid_objects.all()
else:
@@ -216,20 +216,6 @@
join_condition=('afe_hosts_labels_exclude_OIN.label_id IN (%s)'
% only_if_needed_ids),
suffix='_exclude_OIN', exclude=True)
-
- if exclude_atomic_group_hosts:
- atomic_group_labels = models.Label.valid_objects.filter(
- atomic_group__isnull=False)
- if atomic_group_labels.count() > 0:
- atomic_group_label_ids = ','.join(
- str(atomic_group['id'])
- for atomic_group in atomic_group_labels.values('id'))
- query = models.Host.objects.add_join(
- query, 'afe_hosts_labels', join_key='host_id',
- join_condition=(
- 'afe_hosts_labels_exclude_AG.label_id IN (%s)'
- % atomic_group_label_ids),
- suffix='_exclude_AG', exclude=True)
try:
assert 'extra_args' not in filter_data
filter_data['extra_args'] = extra_host_filters(multiple_labels)
@@ -387,82 +373,6 @@
execution_count, queue_entry.job.synch_count)})
-def check_atomic_group_create_job(synch_count, host_objects, metahost_objects,
- dependencies, atomic_group):
- """
- Attempt to reject create_job requests with an atomic group that
- will be impossible to schedule. The checks are not perfect but
- should catch the most obvious issues.
-
- @param synch_count - The job's minimum synch count.
- @param host_objects - A list of models.Host instances.
- @param metahost_objects - A list of models.Label instances.
- @param dependencies - A list of job dependency label names.
- @param labels_by_name - A dictionary mapping label names to models.Label
- instance. Used to look up instances for dependencies.
-
- @raises model_logic.ValidationError - When an issue is found.
- """
- if synch_count and synch_count > atomic_group.max_number_of_machines:
- raise model_logic.ValidationError(
- {'atomic_group_name' :
- 'You have requested a synch_count (%d) greater than the '
- 'maximum machines in the requested Atomic Group (%d).' %
- (synch_count, atomic_group.max_number_of_machines)})
-
- # If specific host objects were supplied with an atomic group, verify
- # that there are enough to satisfy the synch_count.
- minimum_required = synch_count or 1
- if (host_objects and not metahost_objects and
- len(host_objects) < minimum_required):
- raise model_logic.ValidationError(
- {'hosts':
- 'only %d hosts provided for job with synch_count = %d' %
- (len(host_objects), synch_count)})
-
- # Check that the atomic group has a hope of running this job
- # given any supplied metahosts and dependancies that may limit.
-
- # Get a set of hostnames in the atomic group.
- possible_hosts = set()
- for label in atomic_group.label_set.all():
- possible_hosts.update(h.hostname for h in label.host_set.all())
-
- # Filter out hosts that don't match all of the job dependency labels.
- for label in models.Label.objects.filter(name__in=dependencies):
- hosts_in_label = (h.hostname for h in label.host_set.all())
- possible_hosts.intersection_update(hosts_in_label)
-
- if not host_objects and not metahost_objects:
- # No hosts or metahosts are required to queue an atomic group Job.
- # However, if they are given, we respect them below.
- host_set = possible_hosts
- else:
- host_set = set(host.hostname for host in host_objects)
- unusable_host_set = host_set.difference(possible_hosts)
- if unusable_host_set:
- raise model_logic.ValidationError(
- {'hosts': 'Hosts "%s" are not in Atomic Group "%s"' %
- (', '.join(sorted(unusable_host_set)), atomic_group.name)})
-
- # Lookup hosts provided by each meta host and merge them into the
- # host_set for final counting.
- for meta_host in metahost_objects:
- meta_possible = possible_hosts.copy()
- hosts_in_meta_host = (h.hostname for h in meta_host.host_set.all())
- meta_possible.intersection_update(hosts_in_meta_host)
-
- # Count all hosts that this meta_host will provide.
- host_set.update(meta_possible)
-
- if len(host_set) < minimum_required:
- raise model_logic.ValidationError(
- {'atomic_group_name':
- 'Insufficient hosts in Atomic Group "%s" with the'
- ' supplied dependencies and meta_hosts.' %
- (atomic_group.name,)})
-
-
def check_modify_host(update_data):
"""
Sanity check modify_host* requests.
@@ -530,7 +440,6 @@
hosts = []
one_time_hosts = []
meta_hosts = []
- atomic_group = None
hostless = False
queue_entries = job.hostqueueentry_set.all()
@@ -552,15 +461,6 @@
else:
hostless = True
- if atomic_group is None:
- if queue_entry.atomic_group is not None:
- atomic_group = queue_entry.atomic_group
- else:
- assert atomic_group.name == queue_entry.atomic_group.name, (
- 'DB inconsistency. HostQueueEntries with multiple atomic'
- ' groups on job %s: %s != %s' % (
- id, atomic_group.name, queue_entry.atomic_group.name))
-
meta_host_counts = _get_metahost_counts(meta_hosts)
info = dict(dependencies=[label.name for label
@@ -569,7 +469,6 @@
meta_hosts=meta_hosts,
meta_host_counts=meta_host_counts,
one_time_hosts=one_time_hosts,
- atomic_group=atomic_group,
hostless=hostless)
return info
@@ -585,32 +484,16 @@
% ', '.join(duplicate_hostnames)})
-def create_new_job(owner, options, host_objects, metahost_objects,
- atomic_group=None):
+def create_new_job(owner, options, host_objects, metahost_objects):
all_host_objects = host_objects + metahost_objects
dependencies = options.get('dependencies', [])
synch_count = options.get('synch_count')
- if atomic_group:
- check_atomic_group_create_job(
- synch_count, host_objects, metahost_objects,
- dependencies, atomic_group)
- else:
- if synch_count is not None and synch_count > len(all_host_objects):
- raise model_logic.ValidationError(
- {'hosts':
- 'only %d hosts provided for job with synch_count = %d' %
- (len(all_host_objects), synch_count)})
- atomic_hosts = models.Host.objects.filter(
- id__in=[host.id for host in host_objects],
- labels__atomic_group=True)
- unusable_host_names = [host.hostname for host in atomic_hosts]
- if unusable_host_names:
- raise model_logic.ValidationError(
- {'hosts':
- 'Host(s) "%s" are atomic group hosts but no '
- 'atomic group was specified for this job.' %
- (', '.join(unusable_host_names),)})
+ if synch_count is not None and synch_count > len(all_host_objects):
+ raise model_logic.ValidationError(
+ {'hosts':
+ 'only %d hosts provided for job with synch_count = %d' %
+ (len(all_host_objects), synch_count)})
check_for_duplicate_hosts(host_objects)
@@ -628,24 +511,9 @@
options['dependencies'] = list(
models.Label.objects.filter(name__in=dependencies))
- for label in metahost_objects + options['dependencies']:
- if label.atomic_group and not atomic_group:
- raise model_logic.ValidationError(
- {'atomic_group_name':
- 'Dependency %r requires an atomic group but no '
- 'atomic_group_name or meta_host in an atomic group was '
- 'specified for this job.' % label.name})
- elif (label.atomic_group and
- label.atomic_group.name != atomic_group.name):
- raise model_logic.ValidationError(
- {'atomic_group_name':
- 'meta_hosts or dependency %r requires atomic group '
- '%r instead of the supplied atomic_group_name=%r.' %
- (label.name, label.atomic_group.name, atomic_group.name)})
-
job = models.Job.create(owner=owner, options=options,
hosts=all_host_objects)
- job.queue(all_host_objects, atomic_group=atomic_group,
+ job.queue(all_host_objects,
is_template=options.get('is_template', False))
return job.id
@@ -683,12 +551,12 @@
return False
-def find_platform_and_atomic_group(host):
+def find_platform(host):
"""
- Figure out the platform name and atomic group name for the given host
+ Figure out the platform name for the given host
object. If none, the return value for either will be None.
- @returns (platform name, atomic group name) for the given host.
+ @returns platform name for the given host.
"""
platforms = [label.name for label in host.label_list if label.platform]
if not platforms:
@@ -698,16 +566,7 @@
if len(platforms) > 1:
raise ValueError('Host %s has more than one platform: %s' %
(host.hostname, ', '.join(platforms)))
- for label in host.label_list:
- if label.atomic_group:
- atomic_group_name = label.atomic_group.name
- break
- else:
- atomic_group_name = None
- # Don't check for multiple atomic groups on a host here. That is an
- # error but should not trip up the RPC interface. monitor_db_cleanup
- # deals with it. This just returns the first one found.
- return platform, atomic_group_name
+ return platform
# support for get_host_queue_entries_and_special_tasks()
@@ -883,7 +742,6 @@
hosts=(),
meta_hosts=(),
one_time_hosts=(),
- atomic_group_name=None,
synch_count=None,
is_template=False,
timeout=None,
@@ -908,8 +766,7 @@
Common code between creating "standard" jobs and creating parameterized jobs
"""
# input validation
- host_args_passed = any((
- hosts, meta_hosts, one_time_hosts, atomic_group_name))
+ host_args_passed = any((hosts, meta_hosts, one_time_hosts))
if hostless:
if host_args_passed:
raise model_logic.ValidationError({
@@ -921,20 +778,10 @@
elif not host_args_passed:
raise model_logic.ValidationError({
'arguments' : "For host jobs, you must pass at least one of"
- " 'hosts', 'meta_hosts', 'one_time_hosts',"
- " 'atomic_group_name'."
+ " 'hosts', 'meta_hosts', 'one_time_hosts'."
})
-
- atomic_groups_by_name = {
- group.name: group for group in models.AtomicGroup.objects.all()
- }
label_objects = list(models.Label.objects.filter(name__in=meta_hosts))
- # Schedule on an atomic group automagically if one of the labels given
- # is an atomic group label and no explicit atomic_group_name was supplied.
- if not atomic_group_name:
- atomic_group_name = _get_atomic_group_name_from_labels(label_objects)
-
# convert hostnames & meta hosts to host/label objects
host_objects = models.Host.smart_get_bulk(hosts)
_validate_host_job_sharding(host_objects)
@@ -947,32 +794,10 @@
for label_name in meta_hosts:
if label_name in meta_host_labels_by_name:
metahost_objects.append(meta_host_labels_by_name[label_name])
- elif label_name in atomic_groups_by_name:
- # If given a metahost name that isn't a Label, check to
- # see if the user was specifying an Atomic Group instead.
- atomic_group = atomic_groups_by_name[label_name]
- if atomic_group_name and atomic_group_name != atomic_group.name:
- raise model_logic.ValidationError({
- 'meta_hosts': (
- 'Label "%s" not found. If assumed to be an '
- 'atomic group it would conflict with the '
- 'supplied atomic group "%s".' % (
- label_name, atomic_group_name))})
- atomic_group_name = atomic_group.name
else:
raise model_logic.ValidationError(
{'meta_hosts' : 'Label "%s" not found' % label_name})
- # Create and sanity check an AtomicGroup object if requested.
- if atomic_group_name:
- if one_time_hosts:
- raise model_logic.ValidationError(
- {'one_time_hosts':
- 'One time hosts cannot be used with an Atomic Group.'})
- atomic_group = models.AtomicGroup.smart_get(atomic_group_name)
- else:
- atomic_group = None
-
options = dict(name=name,
priority=priority,
control_file=control_file,
@@ -999,18 +824,7 @@
return create_new_job(owner=models.User.current_user().login,
options=options,
host_objects=host_objects,
- metahost_objects=metahost_objects,
- atomic_group=atomic_group)
-
-
-def _get_atomic_group_name_from_labels(label_objects):
- """Get atomic group name from label objects.
-
- @returns: atomic group name string or None
- """
- for label in label_objects:
- if label and label.atomic_group:
- return label.atomic_group.name
+ metahost_objects=metahost_objects)
def _validate_host_job_sharding(host_objects):
@@ -1393,7 +1207,6 @@
hosts = list(get_host_query(
multiple_labels=('pool:%s' % pool, 'board:%s' % board),
exclude_only_if_needed_labels=False,
- exclude_atomic_group_hosts=False,
valid_only=True,
filter_data={},
))
diff --git a/scheduler/scheduler_models_unittest.py b/scheduler/scheduler_models_unittest.py
index 5e0f0ce..83e4d1c 100755
--- a/scheduler/scheduler_models_unittest.py
+++ b/scheduler/scheduler_models_unittest.py
@@ -244,10 +244,10 @@
self._check_hqe_labels(hqe, ['label2'])
- def test_get_labels_dependancies(self):
- hqe = self._create_hqe(dependency_labels=(self.label3, self.label4),
+ def test_get_labels_dependencies(self):
+ hqe = self._create_hqe(dependency_labels=(self.label3,),
metahosts=[1])
- self._check_hqe_labels(hqe, ['label1', 'label3', 'label4'])
+ self._check_hqe_labels(hqe, ['label1', 'label3'])
def setup_abort_test(self, agent_finished=True):