1// Copyright 2022 The ChromiumOS Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5syntax = "proto3"; 6 7package chromiumos.test.api; 8 9option go_package = "go.chromium.org/chromiumos/config/go/test/api"; 10 11import "google/protobuf/duration.proto"; 12import "chromiumos/test/api/device_leasing.proto"; 13import "chromiumos/test/api/image.proto"; 14 15// ProviderId is the ID of various VM service providers: GCloud, VM leaser 16// service etc. 17enum ProviderId { 18 UNKNOWN = 0; 19 GCLOUD = 1; 20 CLOUDSDK = 2; 21 VM_LEASER = 3; 22} 23 24// VMInstance represents a created VM instance. 25message VmInstance { 26 // A unique identifier of the VM that can identify the VM among all configs. 27 string name = 1; 28 // The AddressPort information for SSH. 29 AddressPort ssh = 2; 30 // Configuration used to create the instance. 31 Config config = 3; 32} 33 34// Request for the InstanceApi.Create endpoint. 35message CreateVmInstanceRequest { 36 // Configuration of the backend to start the instance. 37 Config config = 1; 38 // Optional tags to be associated to the instance. 39 map<string, string> tags = 2; 40} 41 42// Request for the InstanceApi.List endpoint. 43message ListVmInstancesRequest { 44 // Configuration of the backend to list the instance. 45 Config config = 2; 46 // Instances with matching tags will be filtered. 47 map<string, string> tag_filters = 1; 48} 49 50// AddressPort represents the SSH address of an VMInstance. 51message AddressPort { 52 // An accessible address: IP, domain, or instance name if in the same network. 53 string address = 1; 54 // Port number for SSH. 55 int32 port = 2; 56} 57 58// TODO(b/250961857): finalize fields and add documentation 59// Configuration to specify how to create an instance. 60message Config { 61 oneof backend { 62 GCloudBackend gcloud_backend = 1; 63 VmLeaserBackend vm_leaser_backend = 2; 64 } 65 66 // Gcloud properties. Most properties are passed through to the corresponding 67 // flags of gcloud. A mandatory field is required when the config is used to 68 // create an instance. 69 message GCloudBackend { 70 // GCP project id. Mandatory 71 string project = 1; 72 // GCE zone. Mandatory. 73 string zone = 2; 74 // GCE machine type. Mandatory. 75 string machine_type = 3; 76 // A custom prefix to instance name. Mandatory. 77 string instance_prefix = 4; 78 // Network, must be consistent to zone. Optional, fallback to default. 79 string network = 7; 80 // Subnet of network. Optional, fallback to default. 81 string subnet= 8; 82 // A boolean flag whether to request a public IPv4 address. 83 // If requested, ssh target will be the public IPv4 address, otherwise it 84 // will be the GCE internal IP address. 85 bool public_ip = 5; 86 // A boolean flag to determine what ip address to return in ssh target. 87 // Default is false and the public_ip flag is used for that decision. 88 // If true, ssh target will be the GCE internal IP address regardless of 89 // whether public_ip is requested. 90 bool always_ssh_internal_ip = 9; 91 // GCE Image to be used to create instance. Mandatory. 92 GceImage image = 6; 93 } 94 95 // VM Leaser properties. The fields will be passed to VM Leaser service for 96 // VM creation and deletion. Required fields must be passed. 97 // 98 // NEXT TAG: 4 99 message VmLeaserBackend { 100 // The VM Leaser environment to connect to. 101 enum Environment { 102 ENV_LOCAL = 0; 103 ENV_STAGING = 1; 104 ENV_PRODUCTION = 2; 105 } 106 Environment env = 3; 107 108 // The populated fields will specify the requirements for operations on a VM 109 // lease. Required. 110 api.VMRequirements vm_requirements = 1; 111 112 // Duration of a VM lease. Optional, fallback to service default. 113 // This will put a ceiling on time wasted if the client dies. 114 google.protobuf.Duration lease_duration = 2; 115 } 116} 117