Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: scheduler/drones.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 import cPickle, os, tempfile, logging 1 import cPickle, os, tempfile, logging
2 import common 2 import common
3 from autotest_lib.scheduler import drone_utility, email_manager 3 from autotest_lib.scheduler import drone_utility, email_manager
4 from autotest_lib.client.common_lib import error, global_config 4 from autotest_lib.client.common_lib import error, global_config
5 5
6 6
7 AUTOTEST_INSTALL_DIR = global_config.global_config.get_config_value('SCHEDULER', 7 AUTOTEST_INSTALL_DIR = global_config.global_config.get_config_value('SCHEDULER',
8 'drone_installation_directory') 8 'drone_installation_directory')
9 9
10 class DroneUnreachable(Exception):
11 """The drone is non-sshable."""
12 pass
13
14
10 class _AbstractDrone(object): 15 class _AbstractDrone(object):
11 """ 16 """
12 Attributes: 17 Attributes:
13 * allowed_users: set of usernames allowed to use this drone. if None, 18 * allowed_users: set of usernames allowed to use this drone. if None,
14 any user can use this drone. 19 any user can use this drone.
15 """ 20 """
16 def __init__(self): 21 def __init__(self):
17 self._calls = [] 22 self._calls = []
18 self.hostname = None 23 self.hostname = None
19 self.enabled = True 24 self.enabled = True
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 else: 109 else:
105 self.queue_call('send_file_to', drone.hostname, source_path, 110 self.queue_call('send_file_to', drone.hostname, source_path,
106 destination_path, can_fail) 111 destination_path, can_fail)
107 112
108 113
109 class _RemoteDrone(_AbstractDrone): 114 class _RemoteDrone(_AbstractDrone):
110 def __init__(self, hostname): 115 def __init__(self, hostname):
111 super(_RemoteDrone, self).__init__() 116 super(_RemoteDrone, self).__init__()
112 self.hostname = hostname 117 self.hostname = hostname
113 self._host = drone_utility.create_host(hostname) 118 self._host = drone_utility.create_host(hostname)
119 if not self._host.is_up():
120 logging.error('Drone %s is unpingable, kicking out', hostname)
121 raise DroneUnreachable
114 self._autotest_install_dir = AUTOTEST_INSTALL_DIR 122 self._autotest_install_dir = AUTOTEST_INSTALL_DIR
115 123
116 124
117 def set_autotest_install_dir(self, path): 125 def set_autotest_install_dir(self, path):
118 self._autotest_install_dir = path 126 self._autotest_install_dir = path
119 127
120 128
121 def shutdown(self): 129 def shutdown(self):
122 super(_RemoteDrone, self).shutdown() 130 super(_RemoteDrone, self).shutdown()
123 self._host.close() 131 self._host.close()
(...skipping 25 matching lines...) Expand all
149 self.queue_call('send_file_to', drone.hostname, source_path, 157 self.queue_call('send_file_to', drone.hostname, source_path,
150 destination_path, can_fail) 158 destination_path, can_fail)
151 159
152 160
153 def get_drone(hostname): 161 def get_drone(hostname):
154 """ 162 """
155 Use this factory method to get drone objects. 163 Use this factory method to get drone objects.
156 """ 164 """
157 if hostname == 'localhost': 165 if hostname == 'localhost':
158 return _LocalDrone() 166 return _LocalDrone()
159 return _RemoteDrone(hostname) 167 try:
168 return _RemoteDrone(hostname)
169 except DroneUnreachable:
170 return None
OLDNEW
« cli/job.py ('K') | « scheduler/drone_manager.py ('k') | scheduler/metahost_scheduler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698