github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/params/storage.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package params 5 6 import "github.com/juju/juju/storage" 7 8 // MachineBlockDevices holds a machine tag and the block devices present 9 // on that machine. 10 type MachineBlockDevices struct { 11 Machine string `json:"machine"` 12 BlockDevices []storage.BlockDevice `json:"block-devices,omitempty"` 13 } 14 15 // SetMachineBlockDevices holds the arguments for recording the block 16 // devices present on a set of machines. 17 type SetMachineBlockDevices struct { 18 MachineBlockDevices []MachineBlockDevices `json:"machine-block-devices"` 19 } 20 21 // BlockDeviceResult holds the result of an API call to retrieve details 22 // of a block device. 23 type BlockDeviceResult struct { 24 Result storage.BlockDevice `json:"result"` 25 Error *Error `json:"error,omitempty"` 26 } 27 28 // BlockDeviceResults holds the result of an API call to retrieve details 29 // of multiple block devices. 30 type BlockDeviceResults struct { 31 Results []BlockDeviceResult `json:"results,omitempty"` 32 } 33 34 // BlockDevicesResult holds the result of an API call to retrieve details 35 // of all block devices relating to some entity. 36 type BlockDevicesResult struct { 37 Result []storage.BlockDevice `json:"result"` 38 Error *Error `json:"error,omitempty"` 39 } 40 41 // BlockDevicseResults holds the result of an API call to retrieve details 42 // of all block devices relating to some entities. 43 type BlockDevicesResults struct { 44 Results []BlockDevicesResult `json:"results,omitempty"` 45 } 46 47 // StorageInstance describes a storage instance. 48 type StorageInstance struct { 49 StorageTag string `json:"storage-tag"` 50 OwnerTag string `json:"owner-tag"` 51 Kind StorageKind `json:"kind"` 52 } 53 54 // StorageKind is the kind of a storage instance. 55 type StorageKind int 56 57 const ( 58 StorageKindUnknown StorageKind = iota 59 StorageKindBlock 60 StorageKindFilesystem 61 ) 62 63 // String returns representation of StorageKind for readability. 64 func (k *StorageKind) String() string { 65 switch *k { 66 case StorageKindBlock: 67 return "block" 68 case StorageKindFilesystem: 69 return "filesystem" 70 default: 71 return "unknown" 72 } 73 } 74 75 // StorageInstanceResult holds the result of an API call to retrieve details 76 // of a storage instance. 77 type StorageInstanceResult struct { 78 Result StorageInstance `json:"result"` 79 Error *Error `json:"error,omitempty"` 80 } 81 82 // StorageInstanceResults holds the result of an API call to retrieve details 83 // of multiple storage instances. 84 type StorageInstanceResults struct { 85 Results []StorageInstanceResult `json:"results,omitempty"` 86 } 87 88 // StorageAttachment describes a unit's attached storage instance. 89 type StorageAttachment struct { 90 StorageTag string `json:"storage-tag"` 91 OwnerTag string `json:"owner-tag"` 92 UnitTag string `json:"unit-tag"` 93 94 Kind StorageKind `json:"kind"` 95 Location string `json:"location"` 96 Life Life `json:"life"` 97 } 98 99 // StorageAttachmentId identifies a storage attachment by the tags of the 100 // related unit and storage instance. 101 type StorageAttachmentId struct { 102 StorageTag string `json:"storage-tag"` 103 UnitTag string `json:"unit-tag"` 104 } 105 106 // StorageAttachmentIds holds a set of storage attachment identifiers. 107 type StorageAttachmentIds struct { 108 Ids []StorageAttachmentId `json:"ids"` 109 } 110 111 // StorageAttachmentIdsResult holds the result of an API call to retrieve the 112 // IDs of a unit's attached storage instances. 113 type StorageAttachmentIdsResult struct { 114 Result StorageAttachmentIds `json:"result"` 115 Error *Error `json:"error,omitempty"` 116 } 117 118 // StorageAttachmentIdsResult holds the result of an API call to retrieve the 119 // IDs of multiple units attached storage instances. 120 type StorageAttachmentIdsResults struct { 121 Results []StorageAttachmentIdsResult `json:"results,omitempty"` 122 } 123 124 // StorageAttachmentsResult holds the result of an API call to retrieve details 125 // of a unit's attached storage instances. 126 type StorageAttachmentsResult struct { 127 Result []StorageAttachment `json:"result"` 128 Error *Error `json:"error,omitempty"` 129 } 130 131 // StorageAttachmentsResults holds the result of an API call to retrieve details 132 // of multiple units' attached storage instances. 133 type StorageAttachmentsResults struct { 134 Results []StorageAttachmentsResult `json:"results,omitempty"` 135 } 136 137 // StorageAttachmentResult holds the result of an API call to retrieve details 138 // of a storage attachment. 139 type StorageAttachmentResult struct { 140 Result StorageAttachment `json:"result"` 141 Error *Error `json:"error,omitempty"` 142 } 143 144 // StorageAttachmentResults holds the result of an API call to retrieve details 145 // of multiple storage attachments. 146 type StorageAttachmentResults struct { 147 Results []StorageAttachmentResult `json:"results,omitempty"` 148 } 149 150 // MachineStorageId identifies the attachment of a storage entity 151 // to a machine, by their tags. 152 type MachineStorageId struct { 153 MachineTag string `json:"machine-tag"` 154 // AttachmentTag is the tag of the volume or filesystem whose 155 // attachment to the machine is represented. 156 AttachmentTag string `json:"attachment-tag"` 157 } 158 159 // MachineStorageIds holds a set of machine/storage-entity 160 // attachment identifiers. 161 type MachineStorageIds struct { 162 Ids []MachineStorageId `json:"ids"` 163 } 164 165 // Volume identifies and describes a storage volume in the model. 166 type Volume struct { 167 VolumeTag string `json:"volume-tag"` 168 Info VolumeInfo `json:"info"` 169 } 170 171 // Volume describes a storage volume in the model. 172 type VolumeInfo struct { 173 VolumeId string `json:"volume-id"` 174 HardwareId string `json:"hardware-id,omitempty"` 175 WWN string `json:"wwn,omitempty"` 176 // Pool is the name of the storage pool used to 177 // allocate the volume. Juju controllers older 178 // than 2.2 do not populate this field, so it may 179 // be omitted. 180 Pool string `json:"pool,omitempty"` 181 // Size is the size of the volume in MiB. 182 Size uint64 `json:"size"` 183 Persistent bool `json:"persistent"` 184 } 185 186 // Volumes describes a set of storage volumes in the model. 187 type Volumes struct { 188 Volumes []Volume `json:"volumes"` 189 } 190 191 // VolumeAttachment identifies and describes a volume attachment. 192 type VolumeAttachment struct { 193 VolumeTag string `json:"volume-tag"` 194 MachineTag string `json:"machine-tag"` 195 Info VolumeAttachmentInfo `json:"info"` 196 } 197 198 // VolumeAttachment identifies and describes a volume attachment. 199 type VolumeAttachmentPlan struct { 200 VolumeTag string `json:"volume-tag"` 201 MachineTag string `json:"machine-tag"` 202 Life Life `json:"life,omitempty"` 203 PlanInfo VolumeAttachmentPlanInfo `json:"plan-info"` 204 // BlockDevice should only be set by machine agents after 205 // the AttachVolume() function is called. It represents the machines 206 // view of the block device represented by the plan. 207 BlockDevice storage.BlockDevice `json:"block-device,omitempty"` 208 } 209 210 type VolumeAttachmentPlans struct { 211 VolumeAttachmentPlans []VolumeAttachmentPlan `json:"volume-plans"` 212 } 213 214 // VolumeAttachmentPlanInfo describes info needed by machine agents 215 // to initialize attached volumes 216 type VolumeAttachmentPlanInfo struct { 217 DeviceType storage.DeviceType `json:"device-type,omitempty"` 218 DeviceAttributes map[string]string `json:"device-attributes,omitempty"` 219 } 220 221 // VolumeAttachmentInfo describes a volume attachment. 222 type VolumeAttachmentInfo struct { 223 DeviceName string `json:"device-name,omitempty"` 224 DeviceLink string `json:"device-link,omitempty"` 225 BusAddress string `json:"bus-address,omitempty"` 226 ReadOnly bool `json:"read-only,omitempty"` 227 PlanInfo *VolumeAttachmentPlanInfo `json:"plan-info,omitempty"` 228 } 229 230 // VolumeAttachments describes a set of storage volume attachments. 231 type VolumeAttachments struct { 232 VolumeAttachments []VolumeAttachment `json:"volume-attachments"` 233 } 234 235 // VolumeParams holds the parameters for creating a storage volume. 236 type VolumeParams struct { 237 VolumeTag string `json:"volume-tag"` 238 Size uint64 `json:"size"` 239 Provider string `json:"provider"` 240 Attributes map[string]interface{} `json:"attributes,omitempty"` 241 Tags map[string]string `json:"tags,omitempty"` 242 Attachment *VolumeAttachmentParams `json:"attachment,omitempty"` 243 } 244 245 // RemoveVolumeParams holds the parameters for destroying or releasing a 246 // storage volume. 247 type RemoveVolumeParams struct { 248 // Provider is the storage provider that manages the volume. 249 Provider string `json:"provider"` 250 251 // VolumeId is the storage provider's unique ID for the volume. 252 VolumeId string `json:"volume-id"` 253 254 // Destroy controls whether the volume should be completely 255 // destroyed, or otherwise merely released from Juju's management. 256 Destroy bool `json:"destroy,omitempty"` 257 } 258 259 // VolumeAttachmentParams holds the parameters for creating a volume 260 // attachment. 261 type VolumeAttachmentParams struct { 262 VolumeTag string `json:"volume-tag"` 263 MachineTag string `json:"machine-tag"` 264 VolumeId string `json:"volume-id,omitempty"` 265 InstanceId string `json:"instance-id,omitempty"` 266 Provider string `json:"provider"` 267 ReadOnly bool `json:"read-only,omitempty"` 268 } 269 270 // VolumeAttachmentsResult holds the volume attachments for a single 271 // machine, or an error. 272 type VolumeAttachmentsResult struct { 273 Attachments []VolumeAttachment `json:"attachments,omitempty"` 274 Error *Error `json:"error,omitempty"` 275 } 276 277 // VolumeAttachmentsResults holds a set of VolumeAttachmentsResults for 278 // a set of machines. 279 type VolumeAttachmentsResults struct { 280 Results []VolumeAttachmentsResult `json:"results,omitempty"` 281 } 282 283 // VolumeAttachmentResult holds the details of a single volume attachment, 284 // or an error. 285 type VolumeAttachmentResult struct { 286 Result VolumeAttachment `json:"result"` 287 Error *Error `json:"error,omitempty"` 288 } 289 290 // VolumeAttachmentResults holds a set of VolumeAttachmentResults. 291 type VolumeAttachmentResults struct { 292 Results []VolumeAttachmentResult `json:"results,omitempty"` 293 } 294 295 // VolumeAttachmentPlanResult holds the details of a single volume attachment plan, 296 // or an error. 297 type VolumeAttachmentPlanResult struct { 298 Result VolumeAttachmentPlan `json:"result"` 299 Error *Error `json:"error,omitempty"` 300 } 301 302 // VolumeAttachmentPlanResults holds a set of VolumeAttachmentPlanResult. 303 type VolumeAttachmentPlanResults struct { 304 Results []VolumeAttachmentPlanResult `json:"results,omitempty"` 305 } 306 307 // VolumeResult holds information about a volume. 308 type VolumeResult struct { 309 Result Volume `json:"result"` 310 Error *Error `json:"error,omitempty"` 311 } 312 313 // VolumeResults holds information about multiple volumes. 314 type VolumeResults struct { 315 Results []VolumeResult `json:"results,omitempty"` 316 } 317 318 // VolumeParamsResults holds provisioning parameters for a volume. 319 type VolumeParamsResult struct { 320 Result VolumeParams `json:"result"` 321 Error *Error `json:"error,omitempty"` 322 } 323 324 // VolumeParamsResults holds provisioning parameters for multiple volumes. 325 type VolumeParamsResults struct { 326 Results []VolumeParamsResult `json:"results,omitempty"` 327 } 328 329 // RemoveVolumeParamsResults holds parameters for destroying a volume. 330 type RemoveVolumeParamsResult struct { 331 Result RemoveVolumeParams `json:"result"` 332 Error *Error `json:"error,omitempty"` 333 } 334 335 // RemoveVolumeParamsResults holds parameters for destroying multiple volumes. 336 type RemoveVolumeParamsResults struct { 337 Results []RemoveVolumeParamsResult `json:"results,omitempty"` 338 } 339 340 // VolumeAttachmentParamsResults holds provisioning parameters for a volume 341 // attachment. 342 type VolumeAttachmentParamsResult struct { 343 Result VolumeAttachmentParams `json:"result"` 344 Error *Error `json:"error,omitempty"` 345 } 346 347 // VolumeAttachmentParamsResults holds provisioning parameters for multiple 348 // volume attachments. 349 type VolumeAttachmentParamsResults struct { 350 Results []VolumeAttachmentParamsResult `json:"results,omitempty"` 351 } 352 353 // Filesystem identifies and describes a storage filesystem in the model. 354 type Filesystem struct { 355 FilesystemTag string `json:"filesystem-tag"` 356 VolumeTag string `json:"volume-tag,omitempty"` 357 Info FilesystemInfo `json:"info"` 358 } 359 360 // Filesystem describes a storage filesystem in the model. 361 type FilesystemInfo struct { 362 FilesystemId string `json:"filesystem-id"` 363 // Pool is the name of the storage pool used to 364 // allocate the filesystem. Juju controllers older 365 // than 2.2 do not populate this field, so it may 366 // be omitted. 367 Pool string `json:"pool"` 368 // Size is the size of the filesystem in MiB. 369 Size uint64 `json:"size"` 370 } 371 372 // Filesystems describes a set of storage filesystems in the model. 373 type Filesystems struct { 374 Filesystems []Filesystem `json:"filesystems"` 375 } 376 377 // FilesystemAttachment identifies and describes a filesystem attachment. 378 type FilesystemAttachment struct { 379 FilesystemTag string `json:"filesystem-tag"` 380 MachineTag string `json:"machine-tag"` 381 Info FilesystemAttachmentInfo `json:"info"` 382 } 383 384 // FilesystemAttachmentInfo describes a filesystem attachment. 385 type FilesystemAttachmentInfo struct { 386 MountPoint string `json:"mount-point,omitempty"` 387 ReadOnly bool `json:"read-only,omitempty"` 388 } 389 390 // FilesystemAttachments describes a set of storage filesystem attachments. 391 type FilesystemAttachments struct { 392 FilesystemAttachments []FilesystemAttachment `json:"filesystem-attachments"` 393 } 394 395 // FilesystemParams holds the parameters for creating a storage filesystem. 396 type FilesystemParams struct { 397 FilesystemTag string `json:"filesystem-tag"` 398 VolumeTag string `json:"volume-tag,omitempty"` 399 Size uint64 `json:"size"` 400 Provider string `json:"provider"` 401 Attributes map[string]interface{} `json:"attributes,omitempty"` 402 Tags map[string]string `json:"tags,omitempty"` 403 Attachment *FilesystemAttachmentParams `json:"attachment,omitempty"` 404 } 405 406 // RemoveFilesystemParams holds the parameters for destroying or releasing 407 // a filesystem. 408 type RemoveFilesystemParams struct { 409 // Provider is the storage provider that manages the filesystem. 410 Provider string `json:"provider"` 411 412 // FilesystemId is the storage provider's unique ID for the filesystem. 413 FilesystemId string `json:"filesystem-id"` 414 415 // Destroy controls whether the filesystem should be completely 416 // destroyed, or otherwise merely released from Juju's management. 417 Destroy bool `json:"destroy,omitempty"` 418 } 419 420 // FilesystemAttachmentParams holds the parameters for creating a filesystem 421 // attachment. 422 type FilesystemAttachmentParams struct { 423 FilesystemTag string `json:"filesystem-tag"` 424 MachineTag string `json:"machine-tag"` 425 FilesystemId string `json:"filesystem-id,omitempty"` 426 InstanceId string `json:"instance-id,omitempty"` 427 Provider string `json:"provider"` 428 MountPoint string `json:"mount-point,omitempty"` 429 ReadOnly bool `json:"read-only,omitempty"` 430 } 431 432 // FilesystemAttachmentResult holds the details of a single filesystem attachment, 433 // or an error. 434 type FilesystemAttachmentResult struct { 435 Result FilesystemAttachment `json:"result"` 436 Error *Error `json:"error,omitempty"` 437 } 438 439 // FilesystemAttachmentResults holds a set of FilesystemAttachmentResults. 440 type FilesystemAttachmentResults struct { 441 Results []FilesystemAttachmentResult `json:"results,omitempty"` 442 } 443 444 // FilesystemResult holds information about a filesystem. 445 type FilesystemResult struct { 446 Result Filesystem `json:"result"` 447 Error *Error `json:"error,omitempty"` 448 } 449 450 // FilesystemResults holds information about multiple filesystems. 451 type FilesystemResults struct { 452 Results []FilesystemResult `json:"results,omitempty"` 453 } 454 455 // FilesystemParamsResults holds provisioning parameters for a filesystem. 456 type FilesystemParamsResult struct { 457 Result FilesystemParams `json:"result"` 458 Error *Error `json:"error,omitempty"` 459 } 460 461 // FilesystemParamsResults holds provisioning parameters for multiple filesystems. 462 type FilesystemParamsResults struct { 463 Results []FilesystemParamsResult `json:"results,omitempty"` 464 } 465 466 // RemoveFilesystemParamsResult holds parameters for destroying or releasing 467 // a filesystem. 468 type RemoveFilesystemParamsResult struct { 469 Result RemoveFilesystemParams `json:"result"` 470 Error *Error `json:"error,omitempty"` 471 } 472 473 // RemoveFilesystemParamsResults holds parameters for destroying or releasing 474 // multiple filesystems. 475 type RemoveFilesystemParamsResults struct { 476 Results []RemoveFilesystemParamsResult `json:"results,omitempty"` 477 } 478 479 // FilesystemAttachmentParamsResults holds provisioning parameters for a filesystem 480 // attachment. 481 type FilesystemAttachmentParamsResult struct { 482 Result FilesystemAttachmentParams `json:"result"` 483 Error *Error `json:"error,omitempty"` 484 } 485 486 // FilesystemAttachmentParamsResults holds provisioning parameters for multiple 487 // filesystem attachments. 488 type FilesystemAttachmentParamsResults struct { 489 Results []FilesystemAttachmentParamsResult `json:"results,omitempty"` 490 } 491 492 // StorageDetails holds information about storage. 493 type StorageDetails struct { 494 // StorageTag holds tag for this storage. 495 StorageTag string `json:"storage-tag"` 496 497 // OwnerTag holds tag for the owner of this storage, unit or application. 498 OwnerTag string `json:"owner-tag"` 499 500 // Kind holds what kind of storage this instance is. 501 Kind StorageKind `json:"kind"` 502 503 // Status contains the status of the storage instance. 504 Status EntityStatus `json:"status"` 505 506 // Life contains the lifecycle state of the storage. 507 // Juju controllers older than 2.2 do not populate this 508 // field, so it may be omitted. 509 Life Life `json:"life,omitempty"` 510 511 // Persistent reports whether or not the underlying volume or 512 // filesystem is persistent; i.e. whether or not it outlives 513 // the machine that it is attached to. 514 Persistent bool `json:"persistent"` 515 516 // Attachments contains a mapping from unit tag to 517 // storage attachment details. 518 Attachments map[string]StorageAttachmentDetails `json:"attachments,omitempty"` 519 } 520 521 // StorageFilter holds filter terms for listing storage details. 522 type StorageFilter struct { 523 // We don't currently implement any filters. This exists to get the 524 // API structure right, and so we can add filters later as necessary. 525 } 526 527 // StorageFilters holds a set of storage filters. 528 type StorageFilters struct { 529 Filters []StorageFilter `json:"filters,omitempty"` 530 } 531 532 // StorageDetailsResult holds information about a storage instance 533 // or error related to its retrieval. 534 type StorageDetailsResult struct { 535 Result *StorageDetails `json:"result,omitempty"` 536 Error *Error `json:"error,omitempty"` 537 } 538 539 // StorageDetailsResults holds results for storage details or related storage error. 540 type StorageDetailsResults struct { 541 Results []StorageDetailsResult `json:"results,omitempty"` 542 } 543 544 // StorageDetailsListResult holds a collection of storage details. 545 type StorageDetailsListResult struct { 546 Result []StorageDetails `json:"result,omitempty"` 547 Error *Error `json:"error,omitempty"` 548 } 549 550 // StorageDetailsListResults holds a collection of collections of storage details. 551 type StorageDetailsListResults struct { 552 Results []StorageDetailsListResult `json:"results,omitempty"` 553 } 554 555 // StorageAttachmentDetails holds detailed information about a storage attachment. 556 type StorageAttachmentDetails struct { 557 // StorageTag is the tag of the storage instance. 558 StorageTag string `json:"storage-tag"` 559 560 // UnitTag is the tag of the unit attached to the storage instance. 561 UnitTag string `json:"unit-tag"` 562 563 // MachineTag is the tag of the machine that the attached unit is assigned to. 564 MachineTag string `json:"machine-tag"` 565 566 // Location holds location (mount point/device path) of 567 // the attached storage. 568 Location string `json:"location,omitempty"` 569 570 // Life contains the lifecycle state of the storage attachment. 571 // Juju controllers older than 2.2 do not populate this 572 // field, so it may be omitted. 573 Life Life `json:"life,omitempty"` 574 } 575 576 // StoragePool holds data for a pool instance. 577 type StoragePool struct { 578 // Name is the pool's name. 579 Name string `json:"name"` 580 581 // Provider is the type of storage provider this pool represents, eg "loop", "ebs". 582 Provider string `json:"provider"` 583 584 // Attrs are the pool's configuration attributes. 585 Attrs map[string]interface{} `json:"attrs"` 586 } 587 588 // StoragePoolArgs contains a set of StoragePool. 589 type StoragePoolArgs struct { 590 Pools []StoragePool `json:"pools"` 591 } 592 593 // StoragePoolDeleteArg holds data for a pool instance to be deleted. 594 type StoragePoolDeleteArg struct { 595 Name string `json:"name"` 596 } 597 598 // StoragePoolDeleteArgs contains a set of StorageDeleteArg. 599 type StoragePoolDeleteArgs struct { 600 Pools []StoragePoolDeleteArg `json:"pools"` 601 } 602 603 // StoragePoolFilter holds a filter for matching storage pools. 604 type StoragePoolFilter struct { 605 // Names are pool's names to filter on. 606 Names []string `json:"names,omitempty"` 607 608 // Providers are pool's storage provider types to filter on. 609 Providers []string `json:"providers,omitempty"` 610 } 611 612 // StoragePoolFilters holds a collection of storage pool filters. 613 type StoragePoolFilters struct { 614 Filters []StoragePoolFilter `json:"filters,omitempty"` 615 } 616 617 // StoragePoolsResult holds a collection of storage pools. 618 type StoragePoolsResult struct { 619 Result []StoragePool `json:"storage-pools,omitempty"` 620 Error *Error `json:"error,omitempty"` 621 } 622 623 // StoragePoolsResults holds a collection of storage pools results. 624 type StoragePoolsResults struct { 625 Results []StoragePoolsResult `json:"results,omitempty"` 626 } 627 628 // VolumeFilter holds a filter for volume list API call. 629 type VolumeFilter struct { 630 // Machines are machine tags to filter on. 631 Machines []string `json:"machines,omitempty"` 632 } 633 634 // IsEmpty determines if filter is empty 635 func (f *VolumeFilter) IsEmpty() bool { 636 return len(f.Machines) == 0 637 } 638 639 // VolumeFilters holds a collection of volume filters. 640 type VolumeFilters struct { 641 Filters []VolumeFilter `json:"filters,omitempty"` 642 } 643 644 // FilesystemFilter holds a filter for filter list API call. 645 type FilesystemFilter struct { 646 // Machines are machine tags to filter on. 647 Machines []string `json:"machines,omitempty"` 648 } 649 650 // IsEmpty determines if filter is empty 651 func (f *FilesystemFilter) IsEmpty() bool { 652 return len(f.Machines) == 0 653 } 654 655 // FilesystemFilters holds a collection of filesystem filters. 656 type FilesystemFilters struct { 657 Filters []FilesystemFilter `json:"filters,omitempty"` 658 } 659 660 // VolumeDetails describes a storage volume in the model 661 // for the purpose of volume CLI commands. 662 // 663 // This is kept separate from Volume which contains only information 664 // specific to the volume model, whereas VolumeDetails is intended 665 // to contain complete information about a volume and related 666 // information (status, attachments, storage). 667 type VolumeDetails struct { 668 // VolumeTag is the tag for the volume. 669 VolumeTag string `json:"volume-tag"` 670 671 // Info contains information about the volume. 672 Info VolumeInfo `json:"info"` 673 674 // Life contains the lifecycle state of the volume. 675 // Juju controllers older than 2.2 do not populate this 676 // field, so it may be omitted. 677 Life Life `json:"life,omitempty"` 678 679 // Status contains the status of the volume. 680 Status EntityStatus `json:"status"` 681 682 // MachineAttachments contains a mapping from 683 // machine tag to volume attachment information. 684 MachineAttachments map[string]VolumeAttachmentDetails `json:"machine-attachments,omitempty"` 685 686 // UnitAttachments contains a mapping from 687 // unit tag to volume attachment information (CAAS models). 688 UnitAttachments map[string]VolumeAttachmentDetails `json:"unit-attachments,omitempty"` 689 690 // Storage contains details about the storage instance 691 // that the volume is assigned to, if any. 692 Storage *StorageDetails `json:"storage,omitempty"` 693 } 694 695 // VolumeAttachmentDetails describes a volume attachment. 696 type VolumeAttachmentDetails struct { 697 // NOTE(axw) for backwards-compatibility, this must not be given a 698 // json tag. This ensures that we collapse VolumeAttachmentInfo. 699 // 700 // TODO(axw) when we can break backwards-compatibility (Juju 3.0), 701 // give this a field name of "info", like we have in VolumeDetails 702 // above. 703 VolumeAttachmentInfo 704 705 // Life contains the lifecycle state of the volume attachment. 706 // Juju controllers older than 2.2 do not populate this 707 // field, so it may be omitted. 708 Life Life `json:"life,omitempty"` 709 } 710 711 // VolumeDetailsResult contains details about a volume, its attachments or 712 // an error preventing retrieving those details. 713 type VolumeDetailsResult struct { 714 // Result describes the volume in detail. 715 Result *VolumeDetails `json:"details,omitempty"` 716 717 // Error contains volume retrieval error. 718 Error *Error `json:"error,omitempty"` 719 } 720 721 // VolumeDetailsResults holds volume details. 722 type VolumeDetailsResults struct { 723 Results []VolumeDetailsResult `json:"results,omitempty"` 724 } 725 726 // VolumeDetailsListResult holds a collection of volume details. 727 type VolumeDetailsListResult struct { 728 Result []VolumeDetails `json:"result,omitempty"` 729 Error *Error `json:"error,omitempty"` 730 } 731 732 // VolumeDetailsListResults holds a collection of collections of volume details. 733 type VolumeDetailsListResults struct { 734 Results []VolumeDetailsListResult `json:"results,omitempty"` 735 } 736 737 // FilesystemDetails describes a storage filesystem in the model 738 // for the purpose of filesystem CLI commands. 739 // 740 // This is kept separate from Filesystem which contains only information 741 // specific to the filesystem model, whereas FilesystemDetails is intended 742 // to contain complete information about a filesystem and related 743 // information (status, attachments, storage). 744 type FilesystemDetails struct { 745 // FilesystemTag is the tag for the filesystem. 746 FilesystemTag string `json:"filesystem-tag"` 747 748 // VolumeTag is the tag for the volume backing the 749 // filesystem, if any. 750 VolumeTag string `json:"volume-tag,omitempty"` 751 752 // Info contains information about the filesystem. 753 Info FilesystemInfo `json:"info"` 754 755 // Life contains the lifecycle state of the filesystem. 756 // Juju controllers older than 2.2 do not populate this 757 // field, so it may be omitted. 758 Life Life `json:"life,omitempty"` 759 760 // Status contains the status of the filesystem. 761 Status EntityStatus `json:"status"` 762 763 // MachineAttachments contains a mapping from 764 // machine tag to filesystem attachment information (IAAS models). 765 MachineAttachments map[string]FilesystemAttachmentDetails `json:"machine-attachments,omitempty"` 766 767 // UnitAttachments contains a mapping from 768 // unit tag to filesystem attachment information (CAAS models). 769 UnitAttachments map[string]FilesystemAttachmentDetails `json:"unit-attachments,omitempty"` 770 771 // Storage contains details about the storage instance 772 // that the volume is assigned to, if any. 773 Storage *StorageDetails `json:"storage,omitempty"` 774 } 775 776 // FilesystemAttachmentDetails describes a filesystem attachment. 777 type FilesystemAttachmentDetails struct { 778 // NOTE(axw) for backwards-compatibility, this must not be given a 779 // json tag. This ensures that we collapse FilesystemAttachmentInfo. 780 // 781 // TODO(axw) when we can break backwards-compatibility (Juju 3.0), 782 // give this a field name of "info", like we have in FilesystemDetails 783 // above. 784 FilesystemAttachmentInfo 785 786 // Life contains the lifecycle state of the filesystem attachment. 787 // Juju controllers older than 2.2 do not populate this 788 // field, so it may be omitted. 789 Life Life `json:"life,omitempty"` 790 } 791 792 // FilesystemDetailsResult contains details about a filesystem, its attachments or 793 // an error preventing retrieving those details. 794 type FilesystemDetailsResult struct { 795 Result *FilesystemDetails `json:"result,omitempty"` 796 Error *Error `json:"error,omitempty"` 797 } 798 799 // FilesystemDetailsResults holds filesystem details. 800 type FilesystemDetailsResults struct { 801 Results []FilesystemDetailsResult `json:"results,omitempty"` 802 } 803 804 // FilesystemDetailsListResult holds a collection of filesystem details. 805 type FilesystemDetailsListResult struct { 806 Result []FilesystemDetails `json:"result,omitempty"` 807 Error *Error `json:"error,omitempty"` 808 } 809 810 // FilesystemDetailsListResults holds a collection of collections of 811 // filesystem details. 812 type FilesystemDetailsListResults struct { 813 Results []FilesystemDetailsListResult `json:"results,omitempty"` 814 } 815 816 // StorageConstraints contains constraints for storage instance. 817 type StorageConstraints struct { 818 // Pool is the name of the storage pool from which to provision the 819 // storage instance. 820 Pool string `json:"pool,omitempty"` 821 822 // Size is the required size of the storage instance, in MiB. 823 Size *uint64 `json:"size,omitempty"` 824 825 // Count is the required number of storage instances. 826 Count *uint64 `json:"count,omitempty"` 827 } 828 829 // StorageAddParams holds storage details to add to a unit dynamically. 830 type StorageAddParams struct { 831 // UnitTag is unit name. 832 UnitTag string `json:"unit"` 833 834 // StorageName is the name of the storage as specified in the charm. 835 StorageName string `json:"name"` 836 837 // Constraints are specified storage constraints. 838 Constraints StorageConstraints `json:"storage"` 839 } 840 841 // StoragesAddParams holds storage details to add to units dynamically. 842 type StoragesAddParams struct { 843 Storages []StorageAddParams `json:"storages"` 844 } 845 846 // RemoveStorage holds the parameters for removing storage from the model. 847 type RemoveStorage struct { 848 Storage []RemoveStorageInstance `json:"storage"` 849 } 850 851 // RemoveStorageInstance holds the parameters for removing a storage instance. 852 type RemoveStorageInstance struct { 853 // Tag is the tag of the storage instance to be destroyed. 854 Tag string `json:"tag"` 855 856 // DestroyAttachments controls whether or not the storage attachments 857 // will be destroyed automatically. If DestroyAttachments is false, 858 // then the storage must already be detached. 859 DestroyAttachments bool `json:"destroy-attachments,omitempty"` 860 861 // DestroyStorage controls whether or not the associated cloud storage 862 // is destroyed. If DestroyStorage is true, the cloud storage will be 863 // destroyed; otherwise it will only be released from Juju's control. 864 DestroyStorage bool `json:"destroy-storage,omitempty"` 865 } 866 867 // BulkImportStorageParams contains the parameters for importing a collection 868 // of storage entities. 869 type BulkImportStorageParams struct { 870 Storage []ImportStorageParams `json:"storage"` 871 } 872 873 // ImportStorageParams contains the parameters for importing a storage entity. 874 type ImportStorageParams struct { 875 // Kind is the kind of the storage entity to import. 876 Kind StorageKind `json:"kind"` 877 878 // Pool is the name of the storage pool into which the storage is to 879 // be imported. 880 Pool string `json:"pool"` 881 882 // ProviderId is the storage provider's unique ID for the storage, 883 // e.g. the EBS volume ID. 884 ProviderId string `json:"provider-id"` 885 886 // StorageName is the name of the storage to assign to the entity. 887 StorageName string `json:"storage-name"` 888 } 889 890 // ImportStorageResults contains the results of importing a collection of 891 // storage entities. 892 type ImportStorageResults struct { 893 Results []ImportStorageResult `json:"results"` 894 } 895 896 // ImportStorageResult contains the result of importing a storage entity. 897 type ImportStorageResult struct { 898 Result *ImportStorageDetails `json:"result,omitempty"` 899 Error *Error `json:"error,omitempty"` 900 } 901 902 // ImportStorageDetails contains the details of an imported storage entity. 903 type ImportStorageDetails struct { 904 // StorageTag contains the string representation of the storage tag 905 // assigned to the imported storage entity. 906 StorageTag string `json:"storage-tag"` 907 } 908 909 // AddStorageResults contains the results of adding storage to units. 910 type AddStorageResults struct { 911 Results []AddStorageResult `json:"results"` 912 } 913 914 // AddStorageResult contains the result of adding storage to a unit. 915 type AddStorageResult struct { 916 Result *AddStorageDetails `json:"result,omitempty"` 917 Error *Error `json:"error,omitempty"` 918 } 919 920 // AddStorageDetails contains the details of added storage. 921 type AddStorageDetails struct { 922 // StorageTags contains the string representation of the storage tags 923 // of the added storage instances. 924 StorageTags []string `json:"storage-tags"` 925 }