aboutsummaryrefslogtreecommitdiff
path: root/cros_utils/locks.py
diff options
context:
space:
mode:
Diffstat (limited to 'cros_utils/locks.py')
-rw-r--r--cros_utils/locks.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/cros_utils/locks.py b/cros_utils/locks.py
index 4ecbe0a9..cb96368e 100644
--- a/cros_utils/locks.py
+++ b/cros_utils/locks.py
@@ -1,29 +1,24 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
"""Utilities for locking machines."""
from __future__ import print_function
import time
-import lock_machine
+import afe_lock_machine
import logger
def AcquireLock(machines, chromeos_root, timeout=1200):
- """Acquire lock for machine(s) with timeout."""
+ """Acquire lock for machine(s) with timeout, using AFE server for locking."""
start_time = time.time()
locked = True
sleep_time = min(10, timeout / 10.0)
while True:
try:
- lock_machine.LockManager(machines, False,
- chromeos_root).UpdateMachines(True)
+ afe_lock_machine.AFELockManager(machines, False, chromeos_root,
+ None).UpdateMachines(True)
break
except Exception as e:
if time.time() - start_time > timeout:
@@ -37,13 +32,13 @@ def AcquireLock(machines, chromeos_root, timeout=1200):
def ReleaseLock(machines, chromeos_root):
- """Release locked machine(s)."""
+ """Release locked machine(s), using AFE server for locking."""
unlocked = True
try:
- lock_machine.LockManager(machines, False,
- chromeos_root).UpdateMachines(False)
+ afe_lock_machine.AFELockManager(machines, False, chromeos_root,
+ None).UpdateMachines(False)
except Exception as e:
unlocked = False
- logger.GetLogger().LogWarning(
- 'Could not unlock %s. %s' % (repr(machines), str(e)))
+ logger.GetLogger().LogWarning('Could not unlock %s. %s' %
+ (repr(machines), str(e)))
return unlocked