github.com/Cloud-Foundations/Dominator@v0.3.4/proto/hypervisor/messages.go (about) 1 package hypervisor 2 3 import ( 4 "net" 5 "time" 6 7 "github.com/Cloud-Foundations/Dominator/lib/filesystem" 8 "github.com/Cloud-Foundations/Dominator/lib/filter" 9 "github.com/Cloud-Foundations/Dominator/lib/tags" 10 ) 11 12 const ( 13 ConsoleNone = 0 14 ConsoleDummy = 1 15 ConsoleVNC = 2 16 17 StateStarting = 0 18 StateRunning = 1 19 StateFailedToStart = 2 20 StateStopping = 3 21 StateStopped = 4 22 StateDestroying = 5 23 StateMigrating = 6 24 StateExporting = 7 25 StateCrashed = 8 26 StateDebugging = 9 27 28 VolumeFormatRaw = 0 29 VolumeFormatQCOW2 = 1 30 31 VolumeTypePersistent = 0 32 VolumeTypeMemory = 1 33 ) 34 35 type AcknowledgeVmRequest struct { 36 IpAddress net.IP 37 } 38 39 type AcknowledgeVmResponse struct { 40 Error string 41 } 42 43 type Address struct { 44 IpAddress net.IP `json:",omitempty"` 45 MacAddress string 46 } 47 48 type AddressList []Address 49 50 type AddVmVolumesRequest struct { 51 IpAddress net.IP 52 VolumeSizes []uint64 53 } 54 55 type AddVmVolumesResponse struct { 56 Error string 57 } 58 59 type BecomePrimaryVmOwnerRequest struct { 60 IpAddress net.IP 61 } 62 63 type BecomePrimaryVmOwnerResponse struct { 64 Error string 65 } 66 67 type ChangeAddressPoolRequest struct { 68 AddressesToAdd []Address // Will be added to free pool. 69 AddressesToRemove []Address // Will be removed from free pool. 70 MaximumFreeAddresses map[string]uint // Key: subnet ID. 71 } 72 73 type ChangeAddressPoolResponse struct { 74 Error string 75 } 76 77 type ChangeOwnersRequest struct { 78 OwnerGroups []string `json:",omitempty"` 79 OwnerUsers []string `json:",omitempty"` 80 } 81 82 type ChangeOwnersResponse struct { 83 Error string 84 } 85 86 type ChangeVmConsoleTypeRequest struct { 87 ConsoleType ConsoleType 88 IpAddress net.IP 89 } 90 91 type ChangeVmConsoleTypeResponse struct { 92 Error string 93 } 94 95 type ChangeVmDestroyProtectionRequest struct { 96 DestroyProtection bool 97 IpAddress net.IP 98 } 99 100 type ChangeVmDestroyProtectionResponse struct { 101 Error string 102 } 103 104 type ChangeVmOwnerUsersRequest struct { 105 IpAddress net.IP 106 OwnerUsers []string 107 } 108 109 type ChangeVmOwnerUsersResponse struct { 110 Error string 111 } 112 113 type ChangeVmSizeRequest struct { 114 IpAddress net.IP 115 MemoryInMiB uint64 116 MilliCPUs uint 117 VirtualCPUs uint 118 } 119 120 type ChangeVmSizeResponse struct { 121 Error string 122 } 123 124 type ChangeVmTagsRequest struct { 125 IpAddress net.IP 126 Tags tags.Tags 127 } 128 129 type ChangeVmTagsResponse struct { 130 Error string 131 } 132 133 type ChangeVmVolumeSizeRequest struct { 134 IpAddress net.IP 135 VolumeIndex uint 136 VolumeSize uint64 137 } 138 139 type ChangeVmVolumeSizeResponse struct { 140 Error string 141 } 142 143 type CommitImportedVmRequest struct { 144 IpAddress net.IP 145 } 146 147 type CommitImportedVmResponse struct { 148 Error string 149 } 150 151 // The ConnectToVmConsole RPC is fully streamed. After the request/response, 152 // the connection/client is hijacked and each side of the connection will send 153 // a stream of bytes. 154 type ConnectToVmConsoleRequest struct { 155 IpAddress net.IP 156 } 157 158 type ConnectToVmConsoleResponse struct { 159 Error string 160 } 161 162 // The ConnectToVmManger RPC is fully streamed. After the request/response, 163 // the connection/client is hijacked and each side of the connection will send 164 // a stream of bytes. 165 type ConnectToVmManagerRequest struct { 166 IpAddress net.IP 167 } 168 169 type ConnectToVmManagerResponse struct { 170 Error string 171 } 172 173 // The ConnectToVmSerialPort RPC is fully streamed. After the request/response, 174 // the connection/client is hijacked and each side of the connection will send 175 // a stream of bytes. 176 type ConnectToVmSerialPortRequest struct { 177 IpAddress net.IP 178 PortNumber uint 179 } 180 181 type ConnectToVmSerialPortResponse struct { 182 Error string 183 } 184 185 type ConsoleType uint 186 187 type CopyVmRequest struct { 188 AccessToken []byte 189 IpAddress net.IP 190 SkipMemoryCheck bool 191 SourceHypervisor string 192 VmInfo 193 } 194 195 type CopyVmResponse struct { // Multiple responses are sent. 196 Error string 197 Final bool // If true, this is the final response. 198 IpAddress net.IP 199 ProgressMessage string 200 } 201 202 type CreateVmRequest struct { 203 DhcpTimeout time.Duration // <0: no DHCP; 0: no wait; >0 DHPC wait. 204 DoNotStart bool 205 EnableNetboot bool 206 IdentityCertificate []byte // PEM encoded. 207 IdentityKey []byte // PEM encoded. 208 ImageDataSize uint64 209 ImageTimeout time.Duration 210 MinimumFreeBytes uint64 211 OverlayDirectories []string 212 OverlayFiles map[string][]byte 213 RoundupPower uint64 214 SecondaryVolumes []Volume 215 SecondaryVolumesData bool // Exclusive of SecondaryVolumesInit. 216 SecondaryVolumesInit []VolumeInitialisationInfo 217 SkipBootloader bool 218 SkipMemoryCheck bool 219 UserDataSize uint64 220 VmInfo 221 } // The following data are streamed afterwards in the following order: 222 // RAW image data (length=ImageDataSize) 223 // user data (length=UserDataSize) 224 // secondary volumes (if SecondaryVolumesData is true) 225 226 type CreateVmResponse struct { // Multiple responses are sent. 227 DhcpTimedOut bool 228 Final bool // If true, this is the final response. 229 IpAddress net.IP 230 ProgressMessage string 231 Error string 232 } 233 234 type DebugVmImageRequest struct { 235 DhcpTimeout time.Duration // <0: no DHCP; 0: no wait; >0 DHPC wait. 236 ImageDataSize uint64 237 ImageName string 238 ImageTimeout time.Duration 239 ImageURL string 240 IpAddress net.IP 241 MinimumFreeBytes uint64 242 OverlayFiles map[string][]byte 243 RoundupPower uint64 244 } // The following data are streamed afterwards in the following order: 245 // RAW image data (length=ImageDataSize) 246 247 type DebugVmImageResponse struct { // Multiple responses are sent. 248 DhcpTimedOut bool 249 Final bool // If true, this is the final response. 250 ProgressMessage string 251 Error string 252 } 253 254 type DeleteVmVolumeRequest struct { 255 AccessToken []byte 256 IpAddress net.IP 257 VolumeIndex uint 258 } 259 260 type DeleteVmVolumeResponse struct { 261 Error string 262 } 263 264 type DestroyVmRequest struct { 265 AccessToken []byte 266 IpAddress net.IP 267 } 268 269 type DestroyVmResponse struct { 270 Error string 271 } 272 273 type DiscardVmAccessTokenRequest struct { 274 AccessToken []byte 275 IpAddress net.IP 276 } 277 278 type DiscardVmAccessTokenResponse struct { 279 Error string 280 } 281 282 type DiscardVmOldImageRequest struct { 283 IpAddress net.IP 284 } 285 286 type DiscardVmOldImageResponse struct { 287 Error string 288 } 289 290 type DiscardVmOldUserDataRequest struct { 291 IpAddress net.IP 292 } 293 294 type DiscardVmOldUserDataResponse struct { 295 Error string 296 } 297 298 type DiscardVmSnapshotRequest struct { 299 IpAddress net.IP 300 } 301 302 type DiscardVmSnapshotResponse struct { 303 Error string 304 } 305 306 type ExportLocalVmInfo struct { 307 Bridges []string 308 LocalVmInfo 309 } 310 311 type ExportLocalVmRequest struct { 312 IpAddress net.IP 313 VerificationCookie []byte `json:",omitempty"` 314 } 315 316 type ExportLocalVmResponse struct { 317 Error string 318 VmInfo ExportLocalVmInfo 319 } 320 321 type GetCapacityRequest struct{} 322 323 type GetCapacityResponse struct { 324 MemoryInMiB uint64 `json:",omitempty"` 325 NumCPUs uint `json:",omitempty"` 326 TotalVolumeBytes uint64 `json:",omitempty"` 327 } 328 329 type GetRootCookiePathRequest struct{} 330 331 type GetRootCookiePathResponse struct { 332 Error string 333 Path string 334 } 335 336 // The GetUpdates() RPC is fully streamed. 337 // The client may or may not send GetUpdatesRequest messages to the server. 338 // The server sends a stream of Update messages. 339 340 type GetUpdatesRequest struct { 341 RegisterExternalLeasesRequest *RegisterExternalLeasesRequest 342 } 343 344 type Update struct { 345 HaveAddressPool bool `json:",omitempty"` 346 AddressPool []Address `json:",omitempty"` // Used & free. 347 HaveDisabled bool `json:",omitempty"` 348 Disabled bool `json:",omitempty"` 349 MemoryInMiB *uint64 `json:",omitempty"` 350 NumCPUs *uint `json:",omitempty"` 351 NumFreeAddresses map[string]uint `json:",omitempty"` // Key: subnet ID. 352 HealthStatus string `json:",omitempty"` 353 HaveSerialNumber bool `json:",omitempty"` 354 SerialNumber string `json:",omitempty"` 355 HaveSubnets bool `json:",omitempty"` 356 Subnets []Subnet `json:",omitempty"` 357 TotalVolumeBytes *uint64 `json:",omitempty"` 358 HaveVMs bool `json:",omitempty"` 359 VMs map[string]*VmInfo `json:",omitempty"` // Key: IP address. 360 } 361 362 type GetVmAccessTokenRequest struct { 363 IpAddress net.IP 364 Lifetime time.Duration 365 } 366 367 type GetVmAccessTokenResponse struct { 368 Token []byte `json:",omitempty"` 369 Error string 370 } 371 372 type GetVmInfoRequest struct { 373 IpAddress net.IP 374 } 375 376 type GetVmInfoResponse struct { 377 VmInfo VmInfo 378 Error string 379 } 380 381 type GetVmLastPatchLogRequest struct { 382 IpAddress net.IP 383 } 384 385 type GetVmLastPatchLogResponse struct { 386 Error string 387 Length uint64 388 PatchTime time.Time 389 } // Data (length=Length) are streamed afterwards. 390 391 type GetVmUserDataRequest struct { 392 AccessToken []byte 393 IpAddress net.IP 394 } 395 396 type GetVmUserDataResponse struct { 397 Error string 398 Length uint64 399 } // Data (length=Length) are streamed afterwards. 400 401 // The GetVmVolume() RPC is followed by the proto/rsync.GetBlocks message. 402 403 type GetVmVolumeRequest struct { 404 AccessToken []byte 405 GetExtraFiles bool 406 IgnoreExtraFiles bool 407 IpAddress net.IP 408 VolumeIndex uint 409 } 410 411 type GetVmVolumeResponse struct { 412 Error string 413 ExtraFiles map[string][]byte // May contain "kernel", "initrd" and such. 414 } 415 416 type HoldLockRequest struct { 417 Timeout time.Duration 418 WriteLock bool 419 } 420 421 type HoldLockResponse struct { 422 Error string 423 } 424 425 type HoldVmLockRequest struct { 426 IpAddress net.IP 427 Timeout time.Duration 428 WriteLock bool 429 } 430 431 type HoldVmLockResponse struct { 432 Error string 433 } 434 435 type ListSubnetsRequest struct { 436 Sort bool 437 } 438 439 type ListSubnetsResponse struct { 440 Error string 441 Subnets []Subnet `json:",omitempty"` 442 } 443 444 type ImportLocalVmRequest struct { 445 SkipMemoryCheck bool 446 VerificationCookie []byte `json:",omitempty"` 447 VmInfo 448 VolumeFilenames []string 449 } 450 451 type ImportLocalVmResponse struct { 452 Error string 453 } 454 455 type ListVMsRequest struct { 456 IgnoreStateMask uint64 457 OwnerGroups []string 458 OwnerUsers []string 459 Sort bool 460 VmTagsToMatch tags.MatchTags // Empty: match all tags. 461 } 462 463 type ListVMsResponse struct { 464 IpAddresses []net.IP 465 } 466 467 type ListVolumeDirectoriesRequest struct{} 468 469 type ListVolumeDirectoriesResponse struct { 470 Directories []string 471 Error string 472 } 473 474 type LocalVolume struct { 475 DirectoryToCleanup string 476 Filename string 477 } 478 479 type LocalVmInfo struct { 480 VmInfo 481 VolumeLocations []LocalVolume 482 } 483 484 type MigrateVmRequest struct { 485 AccessToken []byte 486 DhcpTimeout time.Duration 487 IpAddress net.IP 488 SkipMemoryCheck bool 489 SourceHypervisor string 490 } 491 492 type MigrateVmResponse struct { // Multiple responses are sent. 493 Error string 494 Final bool // If true, this is the final response. 495 ProgressMessage string 496 RequestCommit bool 497 } 498 499 type MigrateVmResponseResponse struct { 500 Commit bool 501 } 502 503 type NetbootMachineRequest struct { 504 Address Address 505 Files map[string][]byte 506 FilesExpiration time.Duration 507 Hostname string 508 NumAcknowledgementsToWaitFor uint 509 OfferExpiration time.Duration 510 Subnet *Subnet 511 WaitTimeout time.Duration 512 } 513 514 type NetbootMachineResponse struct { 515 Error string 516 } 517 518 type PatchVmImageRequest struct { 519 ImageName string 520 ImageTimeout time.Duration 521 IpAddress net.IP 522 SkipBackup bool 523 } 524 525 type PatchVmImageResponse struct { // Multiple responses are sent. 526 Final bool // If true, this is the final response. 527 ProgressMessage string 528 Error string 529 } 530 531 type PowerOffRequest struct { 532 StopVMs bool // true: attempt to stop VMs; false: running VMs block poweroff 533 } 534 535 type PowerOffResponse struct { 536 Error string 537 } 538 539 type PrepareVmForMigrationRequest struct { 540 AccessToken []byte 541 Enable bool 542 IpAddress net.IP 543 } 544 545 type PrepareVmForMigrationResponse struct { 546 Error string 547 } 548 549 type ProbeVmPortRequest struct { 550 IpAddress net.IP 551 PortNumber uint 552 Timeout time.Duration 553 } 554 555 type ProbeVmPortResponse struct { 556 PortIsOpen bool 557 Error string 558 } 559 560 type RebootVmRequest struct { 561 DhcpTimeout time.Duration 562 IpAddress net.IP 563 } 564 565 type RebootVmResponse struct { 566 DhcpTimedOut bool 567 Error string 568 } 569 570 type RegisterExternalLeasesRequest struct { 571 Addresses AddressList 572 Hostnames []string `json:",omitempty"` 573 } 574 575 type RegisterExternalLeasesResponse struct { 576 Error string 577 } 578 579 type ReplaceVmCredentialsRequest struct { 580 IdentityCertificate []byte // PEM encoded. 581 IdentityKey []byte // PEM encoded. 582 IpAddress net.IP 583 } 584 585 type ReplaceVmCredentialsResponse struct { 586 Error string 587 } 588 589 type ReplaceVmImageRequest struct { 590 DhcpTimeout time.Duration 591 ImageDataSize uint64 592 ImageName string `json:",omitempty"` 593 ImageTimeout time.Duration 594 ImageURL string `json:",omitempty"` 595 IpAddress net.IP 596 MinimumFreeBytes uint64 597 OverlayFiles map[string][]byte 598 RoundupPower uint64 599 SkipBackup bool 600 SkipBootloader bool 601 } // RAW image data (length=ImageDataSize) is streamed afterwards. 602 603 type ReplaceVmImageResponse struct { // Multiple responses are sent. 604 DhcpTimedOut bool 605 Final bool // If true, this is the final response. 606 ProgressMessage string 607 Error string 608 } 609 610 type ReplaceVmUserDataRequest struct { 611 IpAddress net.IP 612 Size uint64 613 } // User data (length=Size) are streamed afterwards. 614 615 type ReplaceVmUserDataResponse struct { 616 Error string 617 } 618 619 type RestoreVmFromSnapshotRequest struct { 620 IpAddress net.IP 621 ForceIfNotStopped bool 622 } 623 624 type RestoreVmFromSnapshotResponse struct { 625 Error string 626 } 627 628 type RestoreVmImageRequest struct { 629 IpAddress net.IP 630 } 631 632 type RestoreVmImageResponse struct { 633 Error string 634 } 635 636 type RestoreVmUserDataRequest struct { 637 IpAddress net.IP 638 } 639 640 type RestoreVmUserDataResponse struct { 641 Error string 642 } 643 644 type ReorderVmVolumesRequest struct { 645 AccessToken []byte 646 IpAddress net.IP 647 VolumeIndices []uint 648 } 649 650 type ReorderVmVolumesResponse struct { 651 Error string 652 } 653 654 type ScanVmRootRequest struct { 655 IpAddress net.IP 656 Filter *filter.Filter 657 } 658 659 type ScanVmRootResponse struct { 660 Error string 661 FileSystem *filesystem.FileSystem 662 } 663 664 type SetDisabledStateRequest struct { 665 Disable bool 666 } 667 668 type SetDisabledStateResponse struct { 669 Error string 670 } 671 672 type SnapshotVmRequest struct { 673 IpAddress net.IP 674 ForceIfNotStopped bool 675 RootOnly bool 676 } 677 678 type SnapshotVmResponse struct { 679 Error string 680 } 681 682 type StartVmRequest struct { 683 AccessToken []byte 684 DhcpTimeout time.Duration 685 IpAddress net.IP 686 } 687 688 type StartVmResponse struct { 689 DhcpTimedOut bool 690 Error string 691 } 692 693 type StopVmRequest struct { 694 AccessToken []byte 695 IpAddress net.IP 696 } 697 698 type StopVmResponse struct { 699 Error string 700 } 701 702 type State uint 703 704 type Subnet struct { 705 Id string 706 IpGateway net.IP 707 IpMask net.IP // net.IPMask can't be JSON {en,de}coded. 708 DomainName string `json:",omitempty"` 709 DomainNameServers []net.IP 710 DisableMetadata bool `json:",omitempty"` 711 Manage bool `json:",omitempty"` 712 VlanId uint `json:",omitempty"` 713 AllowedGroups []string `json:",omitempty"` 714 AllowedUsers []string `json:",omitempty"` 715 FirstDynamicIP net.IP `json:",omitempty"` 716 LastDynamicIP net.IP `json:",omitempty"` 717 } 718 719 type TraceVmMetadataRequest struct { 720 IpAddress net.IP 721 } 722 723 type TraceVmMetadataResponse struct { 724 Error string 725 } // A stream of strings (trace paths) follow. 726 727 type UpdateSubnetsRequest struct { 728 Add []Subnet 729 Change []Subnet 730 Delete []string 731 } 732 733 type UpdateSubnetsResponse struct { 734 Error string 735 } 736 737 type VmInfo struct { 738 Address Address 739 ChangedStateOn time.Time `json:",omitempty"` 740 ConsoleType ConsoleType `json:",omitempty"` 741 CreatedOn time.Time `json:",omitempty"` 742 DestroyOnPowerdown bool `json:",omitempty"` 743 DestroyProtection bool `json:",omitempty"` 744 DisableVirtIO bool `json:",omitempty"` 745 ExtraKernelOptions string `json:",omitempty"` 746 Hostname string `json:",omitempty"` 747 IdentityExpires time.Time `json:",omitempty"` 748 IdentityName string `json:",omitempty"` 749 ImageName string `json:",omitempty"` 750 ImageURL string `json:",omitempty"` 751 MemoryInMiB uint64 752 MilliCPUs uint 753 OwnerGroups []string `json:",omitempty"` 754 OwnerUsers []string `json:",omitempty"` 755 SpreadVolumes bool `json:",omitempty"` 756 State State 757 SecondaryAddresses []Address `json:",omitempty"` 758 SecondarySubnetIDs []string `json:",omitempty"` 759 SubnetId string `json:",omitempty"` 760 Tags tags.Tags `json:",omitempty"` 761 Uncommitted bool `json:",omitempty"` 762 VirtualCPUs uint `json:",omitempty"` 763 Volumes []Volume `json:",omitempty"` 764 } 765 766 type Volume struct { 767 Format VolumeFormat 768 Size uint64 769 Type VolumeType 770 } 771 772 type VolumeFormat uint 773 774 type VolumeInitialisationInfo struct { 775 BytesPerInode uint64 776 Label string 777 ReservedBlocksPercentage uint16 778 } 779 780 type VolumeType uint 781 782 // The WatchDhcp() RPC is fully streamed. 783 // The client sends a single WatchDhcpRequest message. 784 // The server sends a stream of WatchDhcpResponse messages until there is an 785 // error. 786 787 type WatchDhcpRequest struct { 788 Interface string // Default: watch all available interfaces. 789 MaxPackets uint64 // Zero means infinite. 790 } 791 792 type WatchDhcpResponse struct { 793 Error string 794 Interface string 795 Packet []byte 796 }