1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6 7from pylib.local.device import local_device_ethernet_environment 8 9SWARMING_SERVER = 'chromeos-swarming.appspot.com' 10 11 12class SkylabEnvironment( 13 local_device_ethernet_environment.LocalDeviceEthernetEnvironment): 14 """ 15 A subclass of LocalDeviceEthernetEnvironment for Skylab devices. 16 """ 17 18 def GetDeviceHostname(self): 19 """Return the hostname based on the bot id. 20 21 Strips the first component of the bot id, e.g. 'cros-clank1' -> 'clank1'. 22 23 Gets the bot id from the SWARMING_BOT_ID envvar, see 24 https://chromium.googlesource.com/infra/luci/luci-py/+/HEAD/appengine/swarming/doc/Magic-Values.md#bot-environment-variables. 25 """ 26 bot_id = os.environ.get('SWARMING_BOT_ID') 27 if not bot_id: 28 raise ValueError( 29 "device_arg is 'swarming' but SWARMING_BOT_ID is not set") 30 31 return bot_id[bot_id.index("-") + 1:] 32