diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:02:00 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:02:00 +0000 |
commit | fb6e2972318a5d63365e66c35c000a6d2e096501 (patch) | |
tree | 35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /lock_machine.py | |
parent | 2186a2d2b9783318bc8226b3eff1fd114f03a8c4 (diff) | |
parent | b75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff) | |
download | toolchain-utils-fb6e2972318a5d63365e66c35c000a6d2e096501.tar.gz |
Snap for 8426163 from b75f321fc8978b92ce3db6886ccb966768f0c7a8 to mainline-tzdata2-releaseandroid-mainline-12.0.0_r112aml_tz2_305400500aml_tz2_305400300aml_tz2_305400100aml_tz2_304500300aml_tz2_303900110aml_tz2_303900102aml_tz2_303800002aml_tz2_303800001aml_tz2_303200001android12-mainline-tzdata2-releaseaml_tz2_305400100
Change-Id: If223f5dd2285da8941d62bcf5daf8e53ec9908ad
Diffstat (limited to 'lock_machine.py')
-rwxr-xr-x | lock_machine.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lock_machine.py b/lock_machine.py index 776fe545..06c0e80c 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 = 'skylab' + SKYLAB_PATH = '/usr/local/bin/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 = 1439 + LEASE_MINS = 1440 SKYLAB_CREDENTIAL = ('/usr/local/google/home/mobiletc-prebuild' '/sheriff_utils/credentials/skylab' @@ -378,19 +378,12 @@ 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) - # 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 ' \ + cmd = (('%s query --swarming https://chromeos-swarming.appspot.com ' \ "%s 'bots/list?is_dead=FALSE&dimensions=dut_name:%s'") % \ (swarming, credential, machine.rstrip('.cros'))) - exit_code, stdout, stderr = self.ce.RunCommandWOutput(cmd) - if exit_code: - raise ValueError( - 'Querying bots failed (2); stdout: %r; stderr: %r' % (stdout, stderr)) - + ret_tup = self.ce.RunCommandWOutput(cmd) # The command will return a json output as stdout. If machine not in skylab # stdout will look like this: # { @@ -399,7 +392,10 @@ class LockManager(object): # } # Otherwise there will be a tuple starting with 'items', we simply detect # this keyword for result. - return 'items' in stdout + if 'items' not in ret_tup[1]: + return False + else: + return True def LeaseSkylabMachine(self, machine): """Run command to lease dut from skylab. @@ -522,6 +518,12 @@ 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 |