diff options
author | Ryan Beltran <ryanbeltran@chromium.org> | 2022-03-26 00:13:03 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-28 19:22:46 +0000 |
commit | 20d36f9fe54ede6a1d1e7b3f2747ac79235263c6 (patch) | |
tree | 7ebb7e7b18d65a65bf757ba1c9145ec5af892336 /lock_machine.py | |
parent | ff75f0210988450f19d95f99402cf9f848e96b71 (diff) | |
download | toolchain-utils-20d36f9fe54ede6a1d1e7b3f2747ac79235263c6.tar.gz |
lock_machine: use swarming binary instead of .py
This cl moves away from calling swarming.py in favor of direcly invoking
the binary for swarming. The justification for doing so is this:
1) swarming.py in luci-client is now 3 years out of date
2) uprevving luci-client in the manifest could have unforseen impact on
other consumers
BUG=b:221777277
TEST=Verify in chrotomation
Change-Id: I269ef5fb4a450f166bbff50c97a4d545680d028c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3553787
Reviewed-by: Denis Nikitin <denik@chromium.org>
Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org>
Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
Diffstat (limited to 'lock_machine.py')
-rwxr-xr-x | lock_machine.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lock_machine.py b/lock_machine.py index c64d3164..85a0cfa3 100755 --- a/lock_machine.py +++ b/lock_machine.py @@ -62,7 +62,7 @@ class LockManager(object): CROSFLEET_CREDENTIAL = ('/usr/local/google/home/mobiletc-prebuild' '/sheriff_utils/credentials/skylab' '/chromeos-swarming-credential.json') - SWARMING = 'chromite/third_party/swarming.client/swarming.py' + SWARMING = '~/cipd_binaries/swarming' SUCCESS = 0 def __init__(self, @@ -377,11 +377,11 @@ class LockManager(object): """ credential = '' if os.path.exists(self.CROSFLEET_CREDENTIAL): - credential = '--auth-service-account-json %s' % self.CROSFLEET_CREDENTIAL - swarming = os.path.join(self.chromeos_root, self.SWARMING) - cmd = (('python3 %s query --swarming https://chromeos-swarming.appspot.com' - " %s 'bots/list?is_dead=FALSE&dimensions=dut_name:%s'") % - (swarming, credential, machine.rstrip('.cros'))) + credential = '--service-account-json %s' % self.CROSFLEET_CREDENTIAL + server = '--server https://chromeos-swarming.appspot.com' + dimensions = '--dimension dut_name=%s' % machine.rstrip('.cros') + + cmd = f'{self.SWARMING} bots {server} {credential} {dimensions}' exit_code, stdout, stderr = self.ce.RunCommandWOutput(cmd) if exit_code: raise ValueError('Querying bots failed (2); stdout: %r; stderr: %r' % @@ -395,7 +395,7 @@ class LockManager(object): # } # Otherwise there will be a tuple starting with 'items', we simply detect # this keyword for result. - return 'items' in stdout + return stdout != '[]' def LeaseCrosfleetMachine(self, machine): """Run command to lease dut from crosfleet. @@ -424,6 +424,7 @@ class LockManager(object): credential = '' if os.path.exists(self.CROSFLEET_CREDENTIAL): credential = '-service-account-json %s' % self.CROSFLEET_CREDENTIAL + cmd = (('%s dut abandon %s %s') % (self.CROSFLEET_PATH, credential, machine.rstrip('.cros'))) retval = self.ce.RunCommand(cmd) |