api

package
v0.0.0-...-c537dde Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GceImage_Status_name = map[int32]string{
		0: "UNKNOWN",
		1: "READY",
		2: "PENDING",
		3: "FAILED",
		4: "DELETING",
		5: "NOT_FOUND",
	}
	GceImage_Status_value = map[string]int32{
		"UNKNOWN":   0,
		"READY":     1,
		"PENDING":   2,
		"FAILED":    3,
		"DELETING":  4,
		"NOT_FOUND": 5,
	}
)

Enum value maps for GceImage_Status.

View Source
var (
	ProviderId_name = map[int32]string{
		0: "UNKNOWN",
		1: "GCLOUD",
		2: "CLOUDSDK",
		3: "VM_LEASER",
	}
	ProviderId_value = map[string]int32{
		"UNKNOWN":   0,
		"GCLOUD":    1,
		"CLOUDSDK":  2,
		"VM_LEASER": 3,
	}
)

Enum value maps for ProviderId.

View Source
var (
	Config_VmLeaserBackend_Environment_name = map[int32]string{
		0: "ENV_LOCAL",
		1: "ENV_STAGING",
		2: "ENV_PRODUCTION",
	}
	Config_VmLeaserBackend_Environment_value = map[string]int32{
		"ENV_LOCAL":      0,
		"ENV_STAGING":    1,
		"ENV_PRODUCTION": 2,
	}
)

Enum value maps for Config_VmLeaserBackend_Environment.

View Source
var File_go_chromium_org_infra_libs_vmlab_api_image_proto protoreflect.FileDescriptor
View Source
var File_go_chromium_org_infra_libs_vmlab_api_instance_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AddressPort

type AddressPort struct {

	// An accessible address: IP, domain, or instance name if in the same network.
	Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	// Port number for SSH.
	Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
	// contains filtered or unexported fields
}

AddressPort represents the SSH address of an VMInstance.

func (*AddressPort) Descriptor deprecated

func (*AddressPort) Descriptor() ([]byte, []int)

Deprecated: Use AddressPort.ProtoReflect.Descriptor instead.

func (*AddressPort) GetAddress

func (x *AddressPort) GetAddress() string

func (*AddressPort) GetPort

func (x *AddressPort) GetPort() int32

func (*AddressPort) ProtoMessage

func (*AddressPort) ProtoMessage()

func (*AddressPort) ProtoReflect

func (x *AddressPort) ProtoReflect() protoreflect.Message

func (*AddressPort) Reset

func (x *AddressPort) Reset()

func (*AddressPort) String

func (x *AddressPort) String() string

type Config

type Config struct {

	// Types that are valid to be assigned to Backend:
	//
	//	*Config_GcloudBackend
	//	*Config_VmLeaserBackend_
	Backend isConfig_Backend `protobuf_oneof:"backend"`
	// contains filtered or unexported fields
}

TODO(b/250961857): finalize fields and add documentation Configuration to specify how to create an instance.

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetBackend

func (x *Config) GetBackend() isConfig_Backend

func (*Config) GetGcloudBackend

func (x *Config) GetGcloudBackend() *Config_GCloudBackend

func (*Config) GetVmLeaserBackend

func (x *Config) GetVmLeaserBackend() *Config_VmLeaserBackend

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type Config_GCloudBackend

type Config_GCloudBackend struct {

	// GCP project id. Mandatory
	Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
	// GCE zone. Mandatory.
	Zone string `protobuf:"bytes,2,opt,name=zone,proto3" json:"zone,omitempty"`
	// GCE machine type. Mandatory.
	MachineType string `protobuf:"bytes,3,opt,name=machine_type,json=machineType,proto3" json:"machine_type,omitempty"`
	// A custom prefix to instance name. Mandatory.
	InstancePrefix string `protobuf:"bytes,4,opt,name=instance_prefix,json=instancePrefix,proto3" json:"instance_prefix,omitempty"`
	// Network, must be consistent to zone. Optional, fallback to default.
	Network string `protobuf:"bytes,7,opt,name=network,proto3" json:"network,omitempty"`
	// Subnet of network. Optional, fallback to default.
	Subnet string `protobuf:"bytes,8,opt,name=subnet,proto3" json:"subnet,omitempty"`
	// A boolean flag whether to request a public IPv4 address.
	// If requested, ssh target will be the public IPv4 address, otherwise it
	// will be the GCE internal IP address.
	PublicIp bool `protobuf:"varint,5,opt,name=public_ip,json=publicIp,proto3" json:"public_ip,omitempty"`
	// A boolean flag to determine what ip address to return in ssh target.
	// Default is false and the public_ip flag is used for that decision.
	// If true, ssh target will be the GCE internal IP address regardless of
	// whether public_ip is requested.
	AlwaysSshInternalIp bool `protobuf:"varint,9,opt,name=always_ssh_internal_ip,json=alwaysSshInternalIp,proto3" json:"always_ssh_internal_ip,omitempty"`
	// GCE Image to be used to create instance. Mandatory.
	Image *GceImage `protobuf:"bytes,6,opt,name=image,proto3" json:"image,omitempty"`
	// contains filtered or unexported fields
}

Gcloud properties. Most properties are passed through to the corresponding flags of gcloud. A mandatory field is required when the config is used to create an instance.

func (*Config_GCloudBackend) Descriptor deprecated

func (*Config_GCloudBackend) Descriptor() ([]byte, []int)

Deprecated: Use Config_GCloudBackend.ProtoReflect.Descriptor instead.

func (*Config_GCloudBackend) GetAlwaysSshInternalIp

func (x *Config_GCloudBackend) GetAlwaysSshInternalIp() bool

func (*Config_GCloudBackend) GetImage

func (x *Config_GCloudBackend) GetImage() *GceImage

func (*Config_GCloudBackend) GetInstancePrefix

func (x *Config_GCloudBackend) GetInstancePrefix() string

func (*Config_GCloudBackend) GetMachineType

func (x *Config_GCloudBackend) GetMachineType() string

func (*Config_GCloudBackend) GetNetwork

func (x *Config_GCloudBackend) GetNetwork() string

func (*Config_GCloudBackend) GetProject

func (x *Config_GCloudBackend) GetProject() string

func (*Config_GCloudBackend) GetPublicIp

func (x *Config_GCloudBackend) GetPublicIp() bool

func (*Config_GCloudBackend) GetSubnet

func (x *Config_GCloudBackend) GetSubnet() string

func (*Config_GCloudBackend) GetZone

func (x *Config_GCloudBackend) GetZone() string

func (*Config_GCloudBackend) ProtoMessage

func (*Config_GCloudBackend) ProtoMessage()

func (*Config_GCloudBackend) ProtoReflect

func (x *Config_GCloudBackend) ProtoReflect() protoreflect.Message

func (*Config_GCloudBackend) Reset

func (x *Config_GCloudBackend) Reset()

func (*Config_GCloudBackend) String

func (x *Config_GCloudBackend) String() string

type Config_GcloudBackend

type Config_GcloudBackend struct {
	GcloudBackend *Config_GCloudBackend `protobuf:"bytes,1,opt,name=gcloud_backend,json=gcloudBackend,proto3,oneof"`
}

type Config_VmLeaserBackend

type Config_VmLeaserBackend struct {
	Env Config_VmLeaserBackend_Environment `protobuf:"varint,3,opt,name=env,proto3,enum=vmlab.api.Config_VmLeaserBackend_Environment" json:"env,omitempty"`
	// The populated fields will specify the requirements for operations on a VM
	// lease. Required.
	VmRequirements *api.VMRequirements `protobuf:"bytes,1,opt,name=vm_requirements,json=vmRequirements,proto3" json:"vm_requirements,omitempty"`
	// Duration of a VM lease. Optional, fallback to service default.
	// This will put a ceiling on time wasted if the client dies.
	LeaseDuration *durationpb.Duration `protobuf:"bytes,2,opt,name=lease_duration,json=leaseDuration,proto3" json:"lease_duration,omitempty"`
	// contains filtered or unexported fields
}

VM Leaser properties. The fields will be passed to VM Leaser service for VM creation and deletion. Required fields must be passed.

NEXT TAG: 4

func (*Config_VmLeaserBackend) Descriptor deprecated

func (*Config_VmLeaserBackend) Descriptor() ([]byte, []int)

Deprecated: Use Config_VmLeaserBackend.ProtoReflect.Descriptor instead.

func (*Config_VmLeaserBackend) GetEnv

func (*Config_VmLeaserBackend) GetLeaseDuration

func (x *Config_VmLeaserBackend) GetLeaseDuration() *durationpb.Duration

func (*Config_VmLeaserBackend) GetVmRequirements

func (x *Config_VmLeaserBackend) GetVmRequirements() *api.VMRequirements

func (*Config_VmLeaserBackend) ProtoMessage

func (*Config_VmLeaserBackend) ProtoMessage()

func (*Config_VmLeaserBackend) ProtoReflect

func (x *Config_VmLeaserBackend) ProtoReflect() protoreflect.Message

func (*Config_VmLeaserBackend) Reset

func (x *Config_VmLeaserBackend) Reset()

func (*Config_VmLeaserBackend) String

func (x *Config_VmLeaserBackend) String() string

type Config_VmLeaserBackend_

type Config_VmLeaserBackend_ struct {
	VmLeaserBackend *Config_VmLeaserBackend `protobuf:"bytes,2,opt,name=vm_leaser_backend,json=vmLeaserBackend,proto3,oneof"`
}

type Config_VmLeaserBackend_Environment

type Config_VmLeaserBackend_Environment int32

The VM Leaser environment to connect to.

const (
	Config_VmLeaserBackend_ENV_LOCAL      Config_VmLeaserBackend_Environment = 0
	Config_VmLeaserBackend_ENV_STAGING    Config_VmLeaserBackend_Environment = 1
	Config_VmLeaserBackend_ENV_PRODUCTION Config_VmLeaserBackend_Environment = 2
)

func (Config_VmLeaserBackend_Environment) Descriptor

func (Config_VmLeaserBackend_Environment) Enum

func (Config_VmLeaserBackend_Environment) EnumDescriptor deprecated

func (Config_VmLeaserBackend_Environment) EnumDescriptor() ([]byte, []int)

Deprecated: Use Config_VmLeaserBackend_Environment.Descriptor instead.

func (Config_VmLeaserBackend_Environment) Number

func (Config_VmLeaserBackend_Environment) String

func (Config_VmLeaserBackend_Environment) Type

type CreateVmInstanceRequest

type CreateVmInstanceRequest struct {

	// Configuration of the backend to start the instance.
	Config *Config `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
	// Optional tags to be associated to the instance.
	Tags map[string]string `` /* 135-byte string literal not displayed */
	// contains filtered or unexported fields
}

Request for the InstanceApi.Create endpoint.

func (*CreateVmInstanceRequest) Descriptor deprecated

func (*CreateVmInstanceRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateVmInstanceRequest.ProtoReflect.Descriptor instead.

func (*CreateVmInstanceRequest) GetConfig

func (x *CreateVmInstanceRequest) GetConfig() *Config

func (*CreateVmInstanceRequest) GetTags

func (x *CreateVmInstanceRequest) GetTags() map[string]string

func (*CreateVmInstanceRequest) ProtoMessage

func (*CreateVmInstanceRequest) ProtoMessage()

func (*CreateVmInstanceRequest) ProtoReflect

func (x *CreateVmInstanceRequest) ProtoReflect() protoreflect.Message

func (*CreateVmInstanceRequest) Reset

func (x *CreateVmInstanceRequest) Reset()

func (*CreateVmInstanceRequest) String

func (x *CreateVmInstanceRequest) String() string

func (*CreateVmInstanceRequest) ValidateVmLeaserBackend

func (r *CreateVmInstanceRequest) ValidateVmLeaserBackend() error

ValidateVmLeaserBackend validates inputs of CreateVmInstanceRequest to be used with VmLeaserBackend.

type GceImage

type GceImage struct {

	// Name of GCP project. E.g. betty-cloud-prototype
	Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
	// Name of GCE image.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Readiness of GCE image.
	Status GceImage_Status `protobuf:"varint,3,opt,name=status,proto3,enum=vmlab.api.GceImage_Status" json:"status,omitempty"`
	// GCS URL of source image to be imported.
	Source string `protobuf:"bytes,4,opt,name=source,proto3" json:"source,omitempty"`
	// Labels of the image, including build-type, board, milestone.
	Labels map[string]string `` /* 139-byte string literal not displayed */
	// Description of the image which contains source image in GS bucket.
	Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"`
	// Timestamp when the image is created in UTC.
	TimeCreated *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=timeCreated,proto3" json:"timeCreated,omitempty"`
	// contains filtered or unexported fields
}

GceImage represents an existing GCE image.

func (*GceImage) Descriptor deprecated

func (*GceImage) Descriptor() ([]byte, []int)

Deprecated: Use GceImage.ProtoReflect.Descriptor instead.

func (*GceImage) GetDescription

func (x *GceImage) GetDescription() string

func (*GceImage) GetLabels

func (x *GceImage) GetLabels() map[string]string

func (*GceImage) GetName

func (x *GceImage) GetName() string

func (*GceImage) GetProject

func (x *GceImage) GetProject() string

func (*GceImage) GetSource

func (x *GceImage) GetSource() string

func (*GceImage) GetStatus

func (x *GceImage) GetStatus() GceImage_Status

func (*GceImage) GetTimeCreated

func (x *GceImage) GetTimeCreated() *timestamppb.Timestamp

func (*GceImage) ProtoMessage

func (*GceImage) ProtoMessage()

func (*GceImage) ProtoReflect

func (x *GceImage) ProtoReflect() protoreflect.Message

func (*GceImage) Reset

func (x *GceImage) Reset()

func (*GceImage) String

func (x *GceImage) String() string

type GceImage_Status

type GceImage_Status int32

Status tracks the relevant status of VM lab use case: READY, PENDING, FAILED, DELETING, NOT_FOUND. Unknown statuses are mapped to UNKNOWN.

const (
	GceImage_UNKNOWN   GceImage_Status = 0
	GceImage_READY     GceImage_Status = 1
	GceImage_PENDING   GceImage_Status = 2
	GceImage_FAILED    GceImage_Status = 3
	GceImage_DELETING  GceImage_Status = 4
	GceImage_NOT_FOUND GceImage_Status = 5
)

func (GceImage_Status) Descriptor

func (GceImage_Status) Enum

func (x GceImage_Status) Enum() *GceImage_Status

func (GceImage_Status) EnumDescriptor deprecated

func (GceImage_Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use GceImage_Status.Descriptor instead.

func (GceImage_Status) Number

func (GceImage_Status) String

func (x GceImage_Status) String() string

func (GceImage_Status) Type

type ImageApi

type ImageApi interface {
	// GetImage treats imported image as cache keyed by builderPath. On cache-miss
	// the method will try to import image. When wait is true, the method will
	// poll the image until the image is READY, or error, or timeout. When wait is
	// false, the current status of the image is returned immediately.
	// go/cros-image-importer
	GetImage(builderPath string, wait bool) (*GceImage, error)
	// ListImages returns a list of VM images in the hard-coded GCP project in
	// cloudsdk.go. Pass empty string to `filter` to return all images. To
	// filter results specify `filter` with format described in GCP API doc:
	// https://cloud.google.com/compute/docs/reference/rest/v1/images/list
	ListImages(filter string) ([]*GceImage, error)
	// DeleteImage deletes a VM image with name `imageName` from the hard-coded
	// GCP project in cloudsdk.go. When wait is true, it will wait until the
	// delete operation is finished.
	DeleteImage(imageName string, wait bool) error
}

ImageApi is the VM image management API that all providers implement. This is a MVP integration that will be replaced by cloud native approach once relevant GCP services are available for internal use: go/cros-vm-cloud-native-image-sync

type InstanceApi

type InstanceApi interface {
	// Create leases a new VM instance.
	Create(context.Context, *CreateVmInstanceRequest) (*VmInstance, error)
	// Delete releases an existing VM instance.
	Delete(context.Context, *VmInstance) error
	// List existing VM instances that match the request.
	List(context.Context, *ListVmInstancesRequest) ([]*VmInstance, error)
}

InstanceApi is the VM instance management API that all providers implement.

type ListVmInstancesRequest

type ListVmInstancesRequest struct {

	// Configuration of the backend to list the instance.
	Config *Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
	// Instances with matching tags will be filtered.
	TagFilters map[string]string `` /* 165-byte string literal not displayed */
	// contains filtered or unexported fields
}

Request for the InstanceApi.List endpoint.

func (*ListVmInstancesRequest) Descriptor deprecated

func (*ListVmInstancesRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListVmInstancesRequest.ProtoReflect.Descriptor instead.

func (*ListVmInstancesRequest) GetConfig

func (x *ListVmInstancesRequest) GetConfig() *Config

func (*ListVmInstancesRequest) GetTagFilters

func (x *ListVmInstancesRequest) GetTagFilters() map[string]string

func (*ListVmInstancesRequest) ProtoMessage

func (*ListVmInstancesRequest) ProtoMessage()

func (*ListVmInstancesRequest) ProtoReflect

func (x *ListVmInstancesRequest) ProtoReflect() protoreflect.Message

func (*ListVmInstancesRequest) Reset

func (x *ListVmInstancesRequest) Reset()

func (*ListVmInstancesRequest) String

func (x *ListVmInstancesRequest) String() string

type ProviderId

type ProviderId int32

ProviderId is the ID of various VM service providers: GCloud, VM leaser service etc.

const (
	ProviderId_UNKNOWN   ProviderId = 0
	ProviderId_GCLOUD    ProviderId = 1
	ProviderId_CLOUDSDK  ProviderId = 2
	ProviderId_VM_LEASER ProviderId = 3
)

func (ProviderId) Descriptor

func (ProviderId) Descriptor() protoreflect.EnumDescriptor

func (ProviderId) Enum

func (x ProviderId) Enum() *ProviderId

func (ProviderId) EnumDescriptor deprecated

func (ProviderId) EnumDescriptor() ([]byte, []int)

Deprecated: Use ProviderId.Descriptor instead.

func (ProviderId) Number

func (x ProviderId) Number() protoreflect.EnumNumber

func (ProviderId) String

func (x ProviderId) String() string

func (ProviderId) Type

type VmInstance

type VmInstance struct {

	// A unique identifier of the VM that can identify the VM among all configs.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The AddressPort information for SSH.
	Ssh *AddressPort `protobuf:"bytes,2,opt,name=ssh,proto3" json:"ssh,omitempty"`
	// Configuration used to create the instance.
	Config *Config `protobuf:"bytes,3,opt,name=config,proto3" json:"config,omitempty"`
	// GceRegion is the region that the VM was instantiated in.
	GceRegion string `protobuf:"bytes,4,opt,name=gce_region,json=gceRegion,proto3" json:"gce_region,omitempty"`
	// contains filtered or unexported fields
}

VMInstance represents a created VM instance.

func (*VmInstance) Descriptor deprecated

func (*VmInstance) Descriptor() ([]byte, []int)

Deprecated: Use VmInstance.ProtoReflect.Descriptor instead.

func (*VmInstance) GetConfig

func (x *VmInstance) GetConfig() *Config

func (*VmInstance) GetGceRegion

func (x *VmInstance) GetGceRegion() string

func (*VmInstance) GetName

func (x *VmInstance) GetName() string

func (*VmInstance) GetSsh

func (x *VmInstance) GetSsh() *AddressPort

func (*VmInstance) ProtoMessage

func (*VmInstance) ProtoMessage()

func (*VmInstance) ProtoReflect

func (x *VmInstance) ProtoReflect() protoreflect.Message

func (*VmInstance) Reset

func (x *VmInstance) Reset()

func (*VmInstance) String

func (x *VmInstance) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL