Commit 3fca97f4 authored by nednguyen's avatar nednguyen Committed by Commit bot

(Telemetry) Rename Device.device_id to Device.guid

BUG=413637

Review URL: https://codereview.chromium.org/564173002

Cr-Commit-Position: refs/heads/master@{#294651}
parent 09dc114c
......@@ -61,20 +61,20 @@ def GetPlatformForDevice(device, logging=real_logging):
Args:
device: a device.Device instance.
"""
if device.device_id not in _remote_platforms:
if device.guid not in _remote_platforms:
try:
if isinstance(device, cros_device.CrOSDevice):
cri = cros_interface.CrOSInterface(
device.host_name, device.ssh_identity)
cri.TryLogin()
_remote_platforms[device.device_id] = (
_remote_platforms[device.guid] = (
Platform(cros_platform_backend.CrosPlatformBackend(cri)))
else:
raise ValueError('Unsupported device type')
except:
logging.error('Fail to create platform instance for %s.', device.name)
raise
return _remote_platforms[device.device_id]
return _remote_platforms[device.guid]
class Platform(object):
......
......@@ -9,7 +9,8 @@ from telemetry.core.platform import device
class CrOSDevice(device.Device):
def __init__(self, host_name, ssh_identity=None):
super(CrOSDevice, self).__init__(
name='ChromeOs with host %s' % host_name, device_id=host_name)
name='ChromeOs with host %s' % host_name,
guid='cros:%s' % host_name)
assert host_name
self._host_name = host_name
self._ssh_identity = ssh_identity
......
......@@ -11,22 +11,22 @@ class Device(object):
Attributes:
name: A device name string in human-understandable term.
device_id: A unique id of the device. Subclass of device must specify this
guid: A unique id of the device. Subclass of device must specify this
id properly so that device objects to a same actual device must have same
device_id.
guid.
"""
def __init__(self, name, device_id):
def __init__(self, name, guid):
self._name = name
self._device_id = device_id
self._guid = guid
@property
def name(self):
return self._name
@property
def device_id(self):
return self._device_id
def guid(self):
return self._guid
@classmethod
def GetAllConnectedDevices(cls, logging=real_logging):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment