OLD | NEW |
1 # Copyright 2009 Google Inc. Released under the GPL v2 | 1 # Copyright 2009 Google Inc. Released under the GPL v2 |
2 | 2 |
3 """ | 3 """ |
4 This module defines the base classes for the Host hierarchy. | 4 This module defines the base classes for the Host hierarchy. |
5 | 5 |
6 Implementation details: | 6 Implementation details: |
7 You should import the "hosts" package instead of importing each type of host. | 7 You should import the "hosts" package instead of importing each type of host. |
8 | 8 |
9 Host: a machine on which you can run programs | 9 Host: a machine on which you can run programs |
10 """ | 10 """ |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 def verify_connectivity(self): | 222 def verify_connectivity(self): |
223 pass | 223 pass |
224 | 224 |
225 | 225 |
226 def verify_software(self): | 226 def verify_software(self): |
227 pass | 227 pass |
228 | 228 |
229 | 229 |
230 def check_diskspace(self, path, gb): | 230 def check_diskspace(self, path, gb): |
| 231 # Note: 1 GB = 10**9 bytes (SI unit). |
231 logging.info('Checking for >= %s GB of space under %s on machine %s', | 232 logging.info('Checking for >= %s GB of space under %s on machine %s', |
232 gb, path, self.hostname) | 233 gb, path, self.hostname) |
233 df = self.run('df -mP %s | tail -1' % path).stdout.split() | 234 df = self.run('df -PB %d %s | tail -1' % (10**9, path)).stdout.split() |
234 free_space_gb = int(df[3])/1000.0 | 235 free_space_gb = int(df[3]) |
235 if free_space_gb < gb: | 236 if free_space_gb < gb: |
236 raise error.AutoservDiskFullHostError(path, gb, free_space_gb) | 237 raise error.AutoservDiskFullHostError(path, gb, free_space_gb) |
237 else: | 238 else: |
238 logging.info('Found %s GB >= %s GB of space under %s on machine %s', | 239 logging.info('Found %s GB >= %s GB of space under %s on machine %s', |
239 free_space_gb, gb, path, self.hostname) | 240 free_space_gb, gb, path, self.hostname) |
240 | 241 |
241 | 242 |
242 def get_open_func(self, use_cache=True): | 243 def get_open_func(self, use_cache=True): |
243 """ | 244 """ |
244 Defines and returns a function that may be used instead of built-in | 245 Defines and returns a function that may be used instead of built-in |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 | 689 |
689 # remove all the vmlinux and System.map files left over | 690 # remove all the vmlinux and System.map files left over |
690 for f in (unused_vmlinux | unused_system_map): | 691 for f in (unused_vmlinux | unused_system_map): |
691 self.run('rm -f', args=(f,), | 692 self.run('rm -f', args=(f,), |
692 ignore_status=True, timeout=120) | 693 ignore_status=True, timeout=120) |
693 | 694 |
694 # remove all unused module directories | 695 # remove all unused module directories |
695 # the regex match should keep us safe from removing the wrong files | 696 # the regex match should keep us safe from removing the wrong files |
696 for moddir in unused_moddirs: | 697 for moddir in unused_moddirs: |
697 self.run('rm -fr', args=(moddir,), ignore_status=True) | 698 self.run('rm -fr', args=(moddir,), ignore_status=True) |
OLD | NEW |