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

Side by Side Diff: scheduler/drones.py

Issue 6883035: Merge remote branch 'autotest-upstream/master' into autotest-merge (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 8 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): 10 class DroneUnreachable(Exception):
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 def __init__(self, hostname): 115 def __init__(self, hostname):
116 super(_RemoteDrone, self).__init__() 116 super(_RemoteDrone, self).__init__()
117 self.hostname = hostname 117 self.hostname = hostname
118 self._host = drone_utility.create_host(hostname) 118 self._host = drone_utility.create_host(hostname)
119 if not self._host.is_up(): 119 if not self._host.is_up():
120 logging.error('Drone %s is unpingable, kicking out', hostname) 120 logging.error('Drone %s is unpingable, kicking out', hostname)
121 raise DroneUnreachable 121 raise DroneUnreachable
122 self._autotest_install_dir = AUTOTEST_INSTALL_DIR 122 self._autotest_install_dir = AUTOTEST_INSTALL_DIR
123 123
124 124
125 @property
126 def _drone_utility_path(self):
127 return os.path.join(self._autotest_install_dir,
128 'scheduler', 'drone_utility.py')
129
130
125 def set_autotest_install_dir(self, path): 131 def set_autotest_install_dir(self, path):
126 self._autotest_install_dir = path 132 self._autotest_install_dir = path
127 133
128 134
129 def shutdown(self): 135 def shutdown(self):
130 super(_RemoteDrone, self).shutdown() 136 super(_RemoteDrone, self).shutdown()
131 self._host.close() 137 self._host.close()
132 138
133 139
134 def _execute_calls_impl(self, calls): 140 def _execute_calls_impl(self, calls):
135 logging.info("Running drone_utility on %s", self.hostname) 141 logging.info("Running drone_utility on %s", self.hostname)
136 drone_utility_path = os.path.join(self._autotest_install_dir, 142 result = self._host.run('python %s' % self._drone_utility_path,
137 'scheduler', 'drone_utility.py') 143 stdin=cPickle.dumps(calls), stdout_tee=None,
138 result = self._host.run('python %s' % drone_utility_path, 144 connect_timeout=300)
139 stdin=cPickle.dumps(calls), connect_timeout=300)
140
141 try: 145 try:
142 return cPickle.loads(result.stdout) 146 return cPickle.loads(result.stdout)
143 except Exception: # cPickle.loads can throw all kinds of exceptions 147 except Exception: # cPickle.loads can throw all kinds of exceptions
144 logging.critical('Invalid response:\n---\n%s\n---', result.stdout) 148 logging.critical('Invalid response:\n---\n%s\n---', result.stdout)
145 raise 149 raise
146 150
147 151
148 def send_file_to(self, drone, source_path, destination_path, 152 def send_file_to(self, drone, source_path, destination_path,
149 can_fail=False): 153 can_fail=False):
150 if drone.hostname == self.hostname: 154 if drone.hostname == self.hostname:
(...skipping 10 matching lines...) Expand all
161 def get_drone(hostname): 165 def get_drone(hostname):
162 """ 166 """
163 Use this factory method to get drone objects. 167 Use this factory method to get drone objects.
164 """ 168 """
165 if hostname == 'localhost': 169 if hostname == 'localhost':
166 return _LocalDrone() 170 return _LocalDrone()
167 try: 171 try:
168 return _RemoteDrone(hostname) 172 return _RemoteDrone(hostname)
169 except DroneUnreachable: 173 except DroneUnreachable:
170 return None 174 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698