diff options
author | Zhizhou Yang <zhizhouy@google.com> | 2019-10-07 13:27:37 -0700 |
---|---|---|
committer | Zhizhou Yang <zhizhouy@google.com> | 2019-10-07 22:02:13 +0000 |
commit | 5a53a336ef05cf3c3d35d8c5d89abf1b60dcfed2 (patch) | |
tree | 716345e48c23bc90253acb3208333824c5e5a9de /afe_lock_machine.py | |
parent | e79e32672a6a738b7b25b3e0e0d2f5773bc5be01 (diff) | |
download | toolchain-utils-5a53a336ef05cf3c3d35d8c5d89abf1b60dcfed2.tar.gz |
toolchain-utils: fix an AFE locking bug and reformat status
There is a bug in afe_lock_machine that if a machine is not in toolchain
pool but still managed by afe, locking/unlocking will not perform
correctly. This CL fixes this issue.
Also this CL reformated the output of the machine status and we are now
calling the print status function by default when getting machines
status. An example looks like this:
Machine (Board) Status
--------------- ------
chromeos4-row6-rack2-host13.cros (lulu) unlocked
TEST=Tested with machines in different pools managed by afe.
BUG=chromium:1006434
Change-Id: I3213ae3ca6c153361753ca91686891cc44d8a5a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1846261
Tested-by: Zhizhou Yang <zhizhouy@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: Zhizhou Yang <zhizhouy@google.com>
Diffstat (limited to 'afe_lock_machine.py')
-rwxr-xr-x | afe_lock_machine.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/afe_lock_machine.py b/afe_lock_machine.py index 2f35e9bf..5f3c7fc6 100755 --- a/afe_lock_machine.py +++ b/afe_lock_machine.py @@ -192,13 +192,12 @@ class AFELockManager(object): state: A dictionary of the current state of the machine. machine_type: MachineType to determine where the machine is located. """ + if machine_type == MachineType.AFE and not m.endswith('.cros'): + m += '.cros' if state['locked']: - if (machine_type == MachineType.AFE and - m not in self.toolchain_lab_machines): - m += '.cros' - print('%s (%s)\t%slocked by %s since %s' % - (m, state['board'], '\t\t\t' if machine_type == MachineType.LOCAL - else '', state['locked_by'], state['lock_time'])) + print('%s (%s)\t\t%slocked by %s since %s' % + (m, state['board'], '\t\t' if machine_type == MachineType.LOCAL else + '', state['locked_by'], state['lock_time'])) else: print( '%s (%s)\t\t%sunlocked' % (m, state['board'], '\t\t' if @@ -254,12 +253,8 @@ class AFELockManager(object): if should_lock_machine: kwargs['lock_reason'] = 'toolchain user request (%s)' % self.user - cros_name = machine + '.cros' - if cros_name in self.toolchain_lab_machines: - machine = cros_name - if machine in self.toolchain_lab_machines: - m = machine.split('.')[0] - afe_server = self.afe + m = machine.split('.')[0] + afe_server = self.afe try: afe_server.run( @@ -456,6 +451,8 @@ class AFELockManager(object): values['lock_time'] = '' machine_list[name] = values + self.ListMachineStates(machine_list) + return machine_list def CheckMachineInSkylab(self, machine): |