syntax = "proto3";

// protoc --version=libprotoc 3.11.3
// protoc-gen-go --version=v1.3.5
// protoc --go_out=plugins=grpc:.  pkg/hostman/hostdeployer/apis/deploy.proto
package apis;

option go_package = "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis";

message GuestDesc {
  string name = 1;
  string uuid = 2;
  string domain = 3;

  repeated Nic nics = 4;
  repeated Nic nics_standby = 5;
  repeated Disk disks = 6;

  string Hypervisor = 7;
  string hostname = 8;
}

message Disk {
  string disk_id = 1;
  string driver = 2;
  string cache_mode = 3;
  string aio_mode = 4;
  int64 size = 5;
  string template_id = 6;
  string image_path = 7;
  string storage_id = 8;
  bool migrating = 9;
  string target_storage_id = 10;
  string path = 11;
  string format = 12;
  int32 index = 13;
  bool merge_snapshot = 14;
  string fs = 15;
  string mountpoint = 16;
  string dev = 17;
}

message Nic {
  string mac = 1;
  string ip = 2;
  string net = 3;
  string net_id = 4;
  bool virtual = 5;
  string gateway = 6;
  string dns = 7;
  string domain = 8;
  string routes = 9;
  string ifname = 10;
  int32 masklen = 11;
  string driver = 12;
  string bridge = 13;
  string wire_id = 14;
  int32 vlan = 15;
  string interface = 16;
  int32 bw = 17;
  int32 index = 18;
  repeated string virtual_ips = 19;
  string externel_id = 20;
  string team_with = 21;
  bool manual = 22;
  string nic_type = 23;
  bool link_up = 24;
  int64 mtu = 25;
  string name = 26;
  bool is_default = 27;
  string ip6 = 28;
  int32 masklen6 = 29;
  string gateway6 = 30;
}

message VDDKConInfo {
  string host = 1;
  int32 port = 2;
  string user = 3;
  string passwd = 4;
  string vmref = 5;
}

message DeployInfo {
  SSHKeys public_key = 1;
  repeated DeployContent deploys = 2;
  string password = 3;
  bool is_random_password =4;
  bool is_init = 5;
  bool enable_tty = 6;
  bool default_root_user = 7;
  bool windows_default_admin_user = 8;
  bool enable_cloud_init = 9;
  string login_account = 10;
  Telegraf telegraf = 11;
  string user_data = 12;
}

message Telegraf {
  string telegraf_conf = 1;
}

message SSHKeys {
  string public_key = 1;
  string delete_public_key = 2;
  string admin_public_key = 3;
  string project_public_key = 4;
}

message DeployContent {
  string path = 1;
  string content = 2;
  string action = 3;
}

message Empty {
}

message DeployGuestFsResponse {
  string distro = 1;
  string version = 2;
  string arch = 3;
  string language = 4;
  string os = 5;
  string account = 6;
  string key = 7;
  bool telegraf_deployed = 8;
  string current_version = 9;
}

message DiskInfo {
  string path = 1;
  string encrypt_password = 2;
  string encrypt_format = 3;
  string encrypt_alg = 4;
  string disk_id = 5;
}

message DeployParams {
  DiskInfo disk_info = 1;
  GuestDesc guest_desc = 2;
  DeployInfo deploy_info = 3;
  VDDKConInfo vddk_info = 4;
}

message ResizeFsParams {
  DiskInfo disk_info = 1;
  string hypervisor = 2;
  VDDKConInfo vddk_info = 3;
  GuestDesc guest_desc = 4;
}

message FsExt4Features {
  bool CaseInsensitive = 1;
  int32 ReservedBlocksPercentage = 2;
}

message FsF2fsFeatures {
  bool CaseInsensitive = 1;
  int32 OverprovisionRatioPercentage = 2;
}

message FsFeatures {
  FsExt4Features ext4 = 1;
  FsF2fsFeatures f2fs = 2;
}

message FormatFsParams {
  DiskInfo disk_info = 1;
  string fs_format = 2;
  string uuid = 3;
  FsFeatures fs_features = 4;
}

message ReleaseInfo {
  string distro = 1;
  string version = 2;
  string arch = 3;
  string language = 4;
  string current_version = 5;
}

message SaveToGlanceParams {
  DiskInfo disk_info = 1;
  bool compress = 2;
}

message SaveToGlanceResponse {
  string os_info = 1;
  ReleaseInfo release_info = 2;
}

message ProbeImageInfoPramas {
  DiskInfo disk_info = 1;
}

message ImageInfo {
  ReleaseInfo os_info = 1;
  string os_type = 2;
  bool is_uefi_support = 3;
  bool is_lvm_partition = 4;
  bool is_readonly = 5;
  string physical_partition_type = 6;
  bool is_installed_cloud_init = 7;
  bool is_bios_support = 8;
}

message EsxiDiskInfo {
  string disk_path = 1;
}

message ConnectEsxiDisksParams {
  VDDKConInfo vddk_info = 1;
  repeated EsxiDiskInfo access_info = 2;
}

message EsxiDisksConnectionInfo {
  repeated EsxiDiskInfo disks = 1;
}


// cdrom, scsi cdrom, hard drive, scsi, pci
message BootDevices {
  int32 BootOrder = 1;
  int32 DevType = 2;
  int32 AttachOrder = 3;
}

message OvmfBootOrderParams {
  string OvmfVarsPath = 1;
  repeated BootDevices devs = 2;
}

service DeployAgent {
  rpc DeployGuestFs (DeployParams) returns (DeployGuestFsResponse);
  rpc ResizeFs (ResizeFsParams) returns (Empty);
  rpc FormatFs (FormatFsParams) returns (Empty);
  rpc SaveToGlance (SaveToGlanceParams) returns (SaveToGlanceResponse);
  rpc ProbeImageInfo(ProbeImageInfoPramas) returns (ImageInfo);
  rpc ConnectEsxiDisks(ConnectEsxiDisksParams) returns (EsxiDisksConnectionInfo);
  rpc DisconnectEsxiDisks(EsxiDisksConnectionInfo) returns (Empty);
  rpc SetOvmfBootOrder(OvmfBootOrderParams) returns (Empty);
}
