GceManager
public class GceManager
extends Object
java.lang.Object |
↳ | com.android.tradefed.device.cloud.GceManager |
管理 GCE 调用以启动/停止并从 GCE 收集日志的助手。
概括
公共构造函数 |
---|
GceManager ( DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo) Ctor |
GceManager ( DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, testResourceBuildInfos) GceManager ( DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, testResourceBuildInfos) 此构造函数已弃用。使用其他构造函数,我们暂时保留它是为了向后兼容。 |
GceManager ( DeviceDescriptor deviceDesc, TestDeviceOptions deviceOptions, IBuildInfo buildInfo, String gceInstanceName, String gceHost) Ctor,可用于提供要直接使用的 GCE 实例名称的变体。 |
公共方法 |
---|
static boolean | AcloudShutdown ( TestDeviceOptions options, IRunUtil runUtil, String instanceName, String hostname, boolean isIpPreconfigured) 实际 Acloud 运行以关闭虚拟设备。 |
void | cleanUp () |
static File | getBugreportzWithSsh ( GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil) 使用 ssh 从设备获取 bugreportz 以避免任何 adb 连接潜在问题。 |
static String | getInstanceSerialLog ( GceAvdInfo infos, File avdConfigFile, File jsonKeyFile, IRunUtil runUtil) 读取 Gce Avd 实例串行日志的当前内容。 |
static File | getNestedDeviceSshBugreportz ( GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil) 通过 ssh 获取嵌套实例的错误报告。 |
static boolean | logNestedRemoteFile ( ITestLogger logger, GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, String remoteFilePath, LogDataType type) 从嵌套实例中获取远程文件并记录它。 |
static boolean | logNestedRemoteFile ( ITestLogger logger, GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, String remoteFilePath, LogDataType type, String baseName) 从嵌套实例中获取远程文件并记录它。 |
void | logSerialOutput ( GceAvdInfo infos, ITestLogger logger) 记录GceAvdInfo 描述的设备的串行输出。 |
static CommandResult | remoteSshCommandExecution ( GceAvdInfo gceAvd, TestDeviceOptions options, IRunUtil runUtil, long timeoutMs, String... command) 在实例上通过 ssh 执行远程命令。 |
boolean | shutdownGce () 关闭与startGce() 关联的 Gce 实例。 |
GceAvdInfo | startGce (String ipDevice, String user, Integer offset, MultiMap <String, String> attributes, ITestLogger logger) 尝试使用 Acloud 或 Oxygen 启动 gce 实例。 |
GceAvdInfo | startGce () |
GceAvdInfo | startGce (String ipDevice, MultiMap <String, String> attributes) 尝试启动 gce 实例。 |
GceAvdInfo | startGce (String ipDevice, String user, Integer offset, MultiMap <String, String> attributes) 尝试使用 Acloud 或 Oxygen 启动 gce 实例。 |
| startMultiDevicesGce ( buildInfos) startMultiDevicesGce ( buildInfos) 此方法已弃用。更新 master 分支后删除它。 |
| startMultiDevicesGce ( buildInfos, MultiMap <String, String> attributes) startMultiDevicesGce ( buildInfos, MultiMap <String, String> attributes) 尝试使用 Oxygen 启动多设备 gce 实例。 |
受保护的方法 |
---|
| buildGceCmd (File reportFile, IBuildInfo b, String ipDevice, String user, Integer offset, MultiMap <String, String> attributes) 构建并返回启动 GCE 的命令。 |
static | buildShutdownCommand (File config, TestDeviceOptions options, String instanceName, String hostname, boolean isIpPreconfigured) |
String | extractInstanceName (String bootupLogs) 从 gce 引导日志中检索实例名称。 |
领域
GCE_HOSTNAME_KEY
public static final String GCE_HOSTNAME_KEY
GCE_INSTANCE_CLEANED_KEY
public static final String GCE_INSTANCE_CLEANED_KEY
GCE_INSTANCE_NAME_KEY
public static final String GCE_INSTANCE_NAME_KEY
public static final String GCE_IP_PRECONFIGURED_KEY
公共构造函数
GceManager
public GceManager (DeviceDescriptor deviceDesc,
TestDeviceOptions deviceOptions,
IBuildInfo buildInfo,
testResourceBuildInfos)
此构造函数已弃用。
使用其他构造函数,我们暂时保留它是为了向后兼容。
参数 |
---|
deviceDesc | DeviceDescriptor |
deviceOptions | TestDeviceOptions |
buildInfo | IBuildInfo |
testResourceBuildInfos | |
公共方法
Acloud关机
public static boolean AcloudShutdown (TestDeviceOptions options,
IRunUtil runUtil,
String instanceName,
String hostname,
boolean isIpPreconfigured)
实际 Acloud 运行以关闭虚拟设备。
参数 |
---|
options | TestDeviceOptions :Acloud 选项的TestDeviceOptions |
runUtil | IRunUtil :运行 Acloud 的IRunUtil |
instanceName | String :要关闭的实例。 |
hostname | String : 实例的主机名,仅用于 Oxygen cuttlefish。 |
isIpPreconfigured | boolean :AVD 是否是在具有预配置 IP 的远程设备上创建的 |
清理
public void cleanUp ()
getBugreportzWithSsh
public static File getBugreportzWithSsh (GceAvdInfo gceAvd,
TestDeviceOptions options,
IRunUtil runUtil)
使用 ssh 从设备获取 bugreportz 以避免任何 adb 连接潜在问题。
退货 |
---|
File | 指向 zip 错误报告的文件,如果出现问题则为 null。 |
getInstanceSerialLog
public static String getInstanceSerialLog (GceAvdInfo infos,
File avdConfigFile,
File jsonKeyFile,
IRunUtil runUtil)
读取 Gce Avd 实例串行日志的当前内容。
参数 |
---|
infos | GceAvdInfo :描述实例的GceAvdInfo 。 |
avdConfigFile | File :avd 配置文件 |
jsonKeyFile | File :服务帐户 json 密钥文件。 |
runUtil | IRunUtil :用于执行命令的IRunUtil 。 |
退货 |
---|
String | 串行日志输出,如果出现问题则为 null。 |
getNestedDeviceSshBugreportz
public static File getNestedDeviceSshBugreportz (GceAvdInfo gceAvd,
TestDeviceOptions options,
IRunUtil runUtil)
通过 ssh 获取嵌套实例的错误报告。这需要在嵌套的虚拟实例中请求 adb。
退货 |
---|
File | 指向 zip 错误报告的文件,如果出现问题则为 null。 |
关闭Gce
public boolean shutdownGce ()
关闭与startGce()
关联的 Gce 实例。
退货 |
---|
boolean | 如果 gce shutdown 被请求为非阻塞,则返回 true。 |
开始
public GceAvdInfo startGce (String ipDevice,
String user,
Integer offset,
MultiMap<String, String> attributes,
ITestLogger logger)
尝试使用 Acloud 或 Oxygen 启动 gce 实例。
参数 |
---|
ipDevice | String : 运行 AVD 的 GCE 实例的初始 IP,如果不适用则为null |
user | String : AVD的主机运行用户,不适用则为null |
offset | Integer : 主机中 AVD 的设备编号偏移量,如果不适用则为null |
attributes | MultiMap :与当前调用关联的属性,用于将适用信息向下传递到 GCE 实例以作为 VM 元数据添加 |
logger | ITestLogger :用于记录设备启动日志的ITestLogger 。 |
开始
public GceAvdInfo startGce (String ipDevice,
MultiMap<String, String> attributes)
尝试启动 gce 实例。
参数 |
---|
ipDevice | String : 运行 AVD 的 GCE 实例的初始 IP,如果不适用则为null |
attributes | MultiMap :与当前调用关联的属性,用于将适用信息向下传递到 GCE 实例以作为 VM 元数据添加 |
开始
public GceAvdInfo startGce (String ipDevice,
String user,
Integer offset,
MultiMap<String, String> attributes)
尝试使用 Acloud 或 Oxygen 启动 gce 实例。
参数 |
---|
ipDevice | String : 运行 AVD 的 GCE 实例的初始 IP,如果不适用则为null |
user | String : AVD的主机运行用户,不适用则为null |
offset | Integer : 主机中 AVD 的设备编号偏移量,如果不适用则为null |
attributes | MultiMap :与当前调用关联的属性,用于将适用信息向下传递到 GCE 实例以作为 VM 元数据添加 |
启动MultiDevicesGce
public startMultiDevicesGce ( buildInfos)
此方法已弃用。
更新 master 分支后删除它。
启动MultiDevicesGce
public startMultiDevicesGce ( buildInfos,
MultiMap<String, String> attributes)
尝试使用 Oxygen 启动多设备 gce 实例。
受保护的方法
构建GceCmd
protected buildGceCmd (File reportFile,
IBuildInfo b,
String ipDevice,
String user,
Integer offset,
MultiMap<String, String> attributes)
构建并返回启动 GCE 的命令。暴露测试。
参数 |
---|
reportFile | File |
b | IBuildInfo |
ipDevice | String |
user | String |
offset | Integer |
attributes | MultiMap |
建立关机命令
protected static buildShutdownCommand (File config,
TestDeviceOptions options,
String instanceName,
String hostname,
boolean isIpPreconfigured)
参数 |
---|
config | File |
options | TestDeviceOptions |
instanceName | String |
hostname | String |
isIpPreconfigured | boolean |
protected String extractInstanceName (String bootupLogs)
从 gce 引导日志中检索实例名称。搜索“名称”:“gce- ' 模式来提取它的名称。我们从日志而不是结果文件中提取,因为在 gce 启动失败时,尝试的实例名称不会显示在 json 中。