def get_devices(bot=None, endpoints=None, enable_resets=False): # pylint: disable=unused-argument devices = [] if not gce.is_gce(): devices += high.GetLocalDevices( 'swarming', 10000, 10000, as_root=False, enable_resets=enable_resets) if endpoints: devices += high.GetRemoteDevices( 'swarming', endpoints, 10000, 10000, as_root=False) return devices
def get_devices(bot, endpoints=None): devices = [] if not gce.is_gce(): devices += high.GetLocalDevices( 'swarming', 10000, 10000, on_error=bot.post_error if bot else None, as_root=True) if endpoints: devices += high.GetRemoteDevices( 'swarming', endpoints, 10000, 10000, on_error=bot.post_error if bot else None, as_root=True) return devices
def test_get_cpuinfo_amd(self): self.mock_get_metadata.return_value = { 'instance': { 'cpuPlatform': 'AMD Rome' } } self.assertEqual(gce.get_cpuinfo(), { 'name': 'AMD Rome GCE', 'vendor': 'AuthenticAMD' }) def test_get_tags(self): self.assertEqual(gce.get_tags(), ['tag1', 'tag2']) @unittest.skipUnless(gce.is_gce(), 'TestMetadata runs only on GCE machines') class TestMetadata(auto_stub.TestCase): def test_get_metadata_uncached(self): meta = gce.get_metadata_uncached() # assert if all metadata used in gce.py exist. self.assertIsNotNone(meta['instance']['cpuPlatform']) self.assertIsNotNone(meta['instance']['image']) self.assertIsNotNone(meta['instance']['machineType']) self.assertIsNotNone(meta['instance']['serviceAccounts']) self.assertIsNotNone(meta['instance']['tags']) self.assertIsNotNone(meta['instance']['zone']) self.assertIsNotNone(meta['project']['projectId']) def test_wait_for_metadata(self): quit_bit = threading.Event()
# Copyright 2015 The LUCI Authors. All rights reserved. # Use of this source code is governed under the Apache License, Version 2.0 # that can be found in the LICENSE file. """OS abstraction OS specific utility functions.""" # pylint: disable=unnecessary-lambda import sys import six if sys.platform == 'cygwin': from api.platforms import gce from api.platforms import posix from api.platforms import win is_gce = lambda: gce.is_gce() # to reuse gce.is_gce mock, if any if sys.platform == 'darwin': from api.platforms import osx from api.platforms import posix is_gce = lambda: False if sys.platform == 'win32': from api.platforms import gce from api.platforms import win is_gce = lambda: gce.is_gce() # to reuse gce.is_gce mock, if any if sys.platform.startswith('linux'): try: if six.PY2: from api.platforms import android