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

Side by Side Diff: scripts/slave/recipe_modules/skia/ssh_flavor.py

Issue 1128823007: Skia recipes: Move Android and ChromeOS config info in from slaves.cfg (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 import collections
6 import default_flavor 7 import default_flavor
7 import posixpath 8 import posixpath
8 9
9 10
10 """Utils for running tests remotely over SSH.""" 11 """Utils for running tests remotely over SSH."""
11 12
12 13
13 DEFAULT_PORT = '22' 14 DEFAULT_PORT = '22'
14 DEFAULT_USER = 'chrome-bot' 15 DEFAULT_USER = 'chrome-bot'
15 16
16 17
18 SlaveInfo = collections.namedtuple('SlaveInfo',
19 'ssh_user ssh_host ssh_port')
20
21 SLAVE_INFO = {
22 'skiabot-shuttle-ubuntu12-003':
23 SlaveInfo('root', '192.168.1.123', DEFAULT_PORT),
24 'skiabot-shuttle-ubuntu12-004':
25 SlaveInfo('root', '192.168.1.134', DEFAULT_PORT),
26 'default':
27 SlaveInfo('nouser', 'noip', 'noport'),
28 }
29
30
17 class SSHFlavorUtils(default_flavor.DefaultFlavorUtils): 31 class SSHFlavorUtils(default_flavor.DefaultFlavorUtils):
18 def __init__(self, *args, **kwargs): 32 def __init__(self, *args, **kwargs):
19 super(SSHFlavorUtils, self).__init__(*args, **kwargs) 33 super(SSHFlavorUtils, self).__init__(*args, **kwargs)
20 self._host = None 34 slave_info = SLAVE_INFO.get(self._skia_api.c.SLAVE_NAME,
21 self._port = None 35 SLAVE_INFO['default'])
22 self._user = None 36 self._host = slave_info.ssh_host
37 self._port = slave_info.ssh_port
38 self._user = slave_info.ssh_user
23 39
24 @property 40 @property
25 def host(self): 41 def host(self):
26 if not self._host:
27 self._host = self._skia_api.c.slave_cfg['ssh_host']
28 return self._host 42 return self._host
29 43
30 @property 44 @property
31 def port(self): 45 def port(self):
32 if not self._port:
33 self._port = self._skia_api.c.slave_cfg.get('ssh_port', DEFAULT_PORT)
34 return self._port 46 return self._port
35 47
36 @property 48 @property
37 def user(self): 49 def user(self):
38 if not self._user:
39 self._user = self._skia_api.c.slave_cfg.get('ssh_user', DEFAULT_USER)
40 return self._user 50 return self._user
41 51
42 def ssh(self, name, cmd, **kwargs): 52 def ssh(self, name, cmd, **kwargs):
43 """Run the given SSH command.""" 53 """Run the given SSH command."""
44 ssh_cmd = ['ssh'] 54 ssh_cmd = ['ssh']
45 if self.port: 55 if self.port:
46 ssh_cmd.extend(['-p', self.port]) 56 ssh_cmd.extend(['-p', self.port])
47 dest = self.host 57 dest = self.host
48 if self.user: 58 if self.user:
49 dest = self.user + '@' + dest 59 dest = self.user + '@' + dest
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 self.ssh(name='read %s' % self._skia_api.m.path.basename(path), 134 self.ssh(name='read %s' % self._skia_api.m.path.basename(path),
125 cmd=['cat', path], 135 cmd=['cat', path],
126 stdout=self._skia_api.m.raw_io.output()).stdout.rstrip() 136 stdout=self._skia_api.m.raw_io.output()).stdout.rstrip()
127 137
128 def remove_file_on_device(self, path, *args, **kwargs): 138 def remove_file_on_device(self, path, *args, **kwargs):
129 """Delete the given file.""" 139 """Delete the given file."""
130 return self.ssh(name='rm %s' % self._skia_api.m.path.basename(path), 140 return self.ssh(name='rm %s' % self._skia_api.m.path.basename(path),
131 cmd=['rm', '-f', path], 141 cmd=['rm', '-f', path],
132 *args, 142 *args,
133 **kwargs) 143 **kwargs)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698