diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-17 19:05:20 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-17 19:05:20 +0000 |
commit | 1fc276040d574012e4f46891409fa93b6f0fec11 (patch) | |
tree | 73936aba47fe1dc71e9cc05af9747036e935608c /lock_machine.py | |
parent | b75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff) | |
parent | 4e4201457e5f51a132101c611c79ccff9f713c8b (diff) | |
download | toolchain-utils-android12-mainline-mediaprovider-release.tar.gz |
Snap for 7468467 from 4e4201457e5f51a132101c611c79ccff9f713c8b to mainline-mediaprovider-releaseandroid-mainline-12.0.0_r90android-mainline-12.0.0_r76android-mainline-12.0.0_r48android-mainline-12.0.0_r31android-mainline-12.0.0_r121android-mainline-12.0.0_r11android-mainline-12.0.0_r106aml_mpr_311911090android12-mainline-mediaprovider-release
Change-Id: I025bd1851bc27970c5b4ef6a391e3e8edb26d9b4
Diffstat (limited to 'lock_machine.py')
-rwxr-xr-x | lock_machine.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lock_machine.py b/lock_machine.py index 06c0e80c..776fe545 100755 --- a/lock_machine.py +++ b/lock_machine.py @@ -53,11 +53,11 @@ class LockManager(object): machines, using appropriate locking mechanisms for each. """ - SKYLAB_PATH = '/usr/local/bin/skylab' + SKYLAB_PATH = 'skylab' # TODO(zhizhouy): lease time may needs to be dynamically adjusted. For now we # set it long enough to cover the period to finish nightly rotation tests. - LEASE_MINS = 1440 + LEASE_MINS = 1439 SKYLAB_CREDENTIAL = ('/usr/local/google/home/mobiletc-prebuild' '/sheriff_utils/credentials/skylab' @@ -378,12 +378,19 @@ class LockManager(object): if os.path.exists(self.SKYLAB_CREDENTIAL): credential = '--auth-service-account-json %s' % self.SKYLAB_CREDENTIAL swarming = os.path.join(self.chromeos_root, self.SWARMING) - cmd = (('%s query --swarming https://chromeos-swarming.appspot.com ' \ + # TODO(zhizhouy): Swarming script doesn't support python3 so explicitly + # launch it with python2 until migrated. + cmd = (('python2 %s ' \ + 'query --swarming https://chromeos-swarming.appspot.com ' \ "%s 'bots/list?is_dead=FALSE&dimensions=dut_name:%s'") % \ (swarming, credential, machine.rstrip('.cros'))) - ret_tup = self.ce.RunCommandWOutput(cmd) + exit_code, stdout, stderr = self.ce.RunCommandWOutput(cmd) + if exit_code: + raise ValueError( + 'Querying bots failed (2); stdout: %r; stderr: %r' % (stdout, stderr)) + # The command will return a json output as stdout. If machine not in skylab # stdout will look like this: # { @@ -392,10 +399,7 @@ class LockManager(object): # } # Otherwise there will be a tuple starting with 'items', we simply detect # this keyword for result. - if 'items' not in ret_tup[1]: - return False - else: - return True + return 'items' in stdout def LeaseSkylabMachine(self, machine): """Run command to lease dut from skylab. @@ -518,12 +522,6 @@ def Main(argv): lock_manager.CheckMachineLocks(machine_states, cmd) lock_manager.UpdateMachines(False) - elif cmd == 'add': - lock_manager.AddMachinesToLocalServer() - - elif cmd == 'remove': - lock_manager.RemoveMachinesFromLocalServer() - return 0 |