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 """Raises an error if path does not have at least gb GB free. |
| 232 |
| 233 @param path The path to check for free disk space. |
| 234 @param gb A floating point number to compare with a granularity |
| 235 of 1 MB. |
| 236 |
| 237 1000 based SI units are used. |
| 238 |
| 239 @raises AutoservDiskFullHostError if path has less than gb GB free. |
| 240 """ |
| 241 one_mb = 10**6 # Bytes (SI unit). |
| 242 mb_per_gb = 1000.0 |
232 logging.info('Checking for >= %s GB of space under %s on machine %s', | 243 logging.info('Checking for >= %s GB of space under %s on machine %s', |
233 gb, path, self.hostname) | 244 gb, path, self.hostname) |
234 df = self.run('df -PB %d %s | tail -1' % (10**9, path)).stdout.split() | 245 df = self.run('df -PB %d %s | tail -1' % (one_mb, path)).stdout.split() |
235 free_space_gb = int(df[3]) | 246 free_space_gb = int(df[3])/mb_per_gb |
236 if free_space_gb < gb: | 247 if free_space_gb < gb: |
237 raise error.AutoservDiskFullHostError(path, gb, free_space_gb) | 248 raise error.AutoservDiskFullHostError(path, gb, free_space_gb) |
238 else: | 249 else: |
239 logging.info('Found %s GB >= %s GB of space under %s on machine %s', | 250 logging.info('Found %s GB >= %s GB of space under %s on machine %s', |
240 free_space_gb, gb, path, self.hostname) | 251 free_space_gb, gb, path, self.hostname) |
241 | 252 |
242 | 253 |
243 def get_open_func(self, use_cache=True): | 254 def get_open_func(self, use_cache=True): |
244 """ | 255 """ |
245 Defines and returns a function that may be used instead of built-in | 256 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... |
689 | 700 |
690 # remove all the vmlinux and System.map files left over | 701 # remove all the vmlinux and System.map files left over |
691 for f in (unused_vmlinux | unused_system_map): | 702 for f in (unused_vmlinux | unused_system_map): |
692 self.run('rm -f', args=(f,), | 703 self.run('rm -f', args=(f,), |
693 ignore_status=True, timeout=120) | 704 ignore_status=True, timeout=120) |
694 | 705 |
695 # remove all unused module directories | 706 # remove all unused module directories |
696 # the regex match should keep us safe from removing the wrong files | 707 # the regex match should keep us safe from removing the wrong files |
697 for moddir in unused_moddirs: | 708 for moddir in unused_moddirs: |
698 self.run('rm -fr', args=(moddir,), ignore_status=True) | 709 self.run('rm -fr', args=(moddir,), ignore_status=True) |
OLD | NEW |