github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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 // Size is the size of the volume in MiB. 176 Size uint64 `json:"size"` 177 Persistent bool `json:"persistent"` 178 } 179 180 // Volumes describes a set of storage volumes in the model. 181 type Volumes struct { 182 Volumes []Volume `json:"volumes"` 183 } 184 185 // VolumeAttachment identifies and describes a volume attachment. 186 type VolumeAttachment struct { 187 VolumeTag string `json:"volume-tag"` 188 MachineTag string `json:"machine-tag"` 189 Info VolumeAttachmentInfo `json:"info"` 190 } 191 192 // VolumeAttachmentInfo describes a volume attachment. 193 type VolumeAttachmentInfo struct { 194 DeviceName string `json:"device-name,omitempty"` 195 DeviceLink string `json:"device-link,omitempty"` 196 BusAddress string `json:"bus-address,omitempty"` 197 ReadOnly bool `json:"read-only,omitempty"` 198 } 199 200 // VolumeAttachments describes a set of storage volume attachments. 201 type VolumeAttachments struct { 202 VolumeAttachments []VolumeAttachment `json:"volume-attachments"` 203 } 204 205 // VolumeParams holds the parameters for creating a storage volume. 206 type VolumeParams struct { 207 VolumeTag string `json:"volume-tag"` 208 Size uint64 `json:"size"` 209 Provider string `json:"provider"` 210 Attributes map[string]interface{} `json:"attributes,omitempty"` 211 Tags map[string]string `json:"tags,omitempty"` 212 Attachment *VolumeAttachmentParams `json:"attachment,omitempty"` 213 } 214 215 // VolumeAttachmentParams holds the parameters for creating a volume 216 // attachment. 217 type VolumeAttachmentParams struct { 218 VolumeTag string `json:"volume-tag"` 219 MachineTag string `json:"machine-tag"` 220 VolumeId string `json:"volume-id,omitempty"` 221 InstanceId string `json:"instance-id,omitempty"` 222 Provider string `json:"provider"` 223 ReadOnly bool `json:"read-only,omitempty"` 224 } 225 226 // VolumeAttachmentsResult holds the volume attachments for a single 227 // machine, or an error. 228 type VolumeAttachmentsResult struct { 229 Attachments []VolumeAttachment `json:"attachments,omitempty"` 230 Error *Error `json:"error,omitempty"` 231 } 232 233 // VolumeAttachmentsResults holds a set of VolumeAttachmentsResults for 234 // a set of machines. 235 type VolumeAttachmentsResults struct { 236 Results []VolumeAttachmentsResult `json:"results,omitempty"` 237 } 238 239 // VolumeAttachmentResult holds the details of a single volume attachment, 240 // or an error. 241 type VolumeAttachmentResult struct { 242 Result VolumeAttachment `json:"result"` 243 Error *Error `json:"error,omitempty"` 244 } 245 246 // VolumeAttachmentResults holds a set of VolumeAttachmentResults. 247 type VolumeAttachmentResults struct { 248 Results []VolumeAttachmentResult `json:"results,omitempty"` 249 } 250 251 // VolumeResult holds information about a volume. 252 type VolumeResult struct { 253 Result Volume `json:"result"` 254 Error *Error `json:"error,omitempty"` 255 } 256 257 // VolumeResults holds information about multiple volumes. 258 type VolumeResults struct { 259 Results []VolumeResult `json:"results,omitempty"` 260 } 261 262 // VolumeParamsResults holds provisioning parameters for a volume. 263 type VolumeParamsResult struct { 264 Result VolumeParams `json:"result"` 265 Error *Error `json:"error,omitempty"` 266 } 267 268 // VolumeParamsResults holds provisioning parameters for multiple volumes. 269 type VolumeParamsResults struct { 270 Results []VolumeParamsResult `json:"results,omitempty"` 271 } 272 273 // VolumeAttachmentParamsResults holds provisioning parameters for a volume 274 // attachment. 275 type VolumeAttachmentParamsResult struct { 276 Result VolumeAttachmentParams `json:"result"` 277 Error *Error `json:"error,omitempty"` 278 } 279 280 // VolumeAttachmentParamsResults holds provisioning parameters for multiple 281 // volume attachments. 282 type VolumeAttachmentParamsResults struct { 283 Results []VolumeAttachmentParamsResult `json:"results,omitempty"` 284 } 285 286 // Filesystem identifies and describes a storage filesystem in the model. 287 type Filesystem struct { 288 FilesystemTag string `json:"filesystem-tag"` 289 VolumeTag string `json:"volume-tag,omitempty"` 290 Info FilesystemInfo `json:"info"` 291 } 292 293 // Filesystem describes a storage filesystem in the model. 294 type FilesystemInfo struct { 295 FilesystemId string `json:"filesystem-id"` 296 // Size is the size of the filesystem in MiB. 297 Size uint64 `json:"size"` 298 } 299 300 // Filesystems describes a set of storage filesystems in the model. 301 type Filesystems struct { 302 Filesystems []Filesystem `json:"filesystems"` 303 } 304 305 // FilesystemAttachment identifies and describes a filesystem attachment. 306 type FilesystemAttachment struct { 307 FilesystemTag string `json:"filesystem-tag"` 308 MachineTag string `json:"machine-tag"` 309 Info FilesystemAttachmentInfo `json:"info"` 310 } 311 312 // FilesystemAttachmentInfo describes a filesystem attachment. 313 type FilesystemAttachmentInfo struct { 314 MountPoint string `json:"mount-point,omitempty"` 315 ReadOnly bool `json:"read-only,omitempty"` 316 } 317 318 // FilesystemAttachments describes a set of storage filesystem attachments. 319 type FilesystemAttachments struct { 320 FilesystemAttachments []FilesystemAttachment `json:"filesystem-attachments"` 321 } 322 323 // FilesystemParams holds the parameters for creating a storage filesystem. 324 type FilesystemParams struct { 325 FilesystemTag string `json:"filesystem-tag"` 326 VolumeTag string `json:"volume-tag,omitempty"` 327 Size uint64 `json:"size"` 328 Provider string `json:"provider"` 329 Attributes map[string]interface{} `json:"attributes,omitempty"` 330 Tags map[string]string `json:"tags,omitempty"` 331 Attachment *FilesystemAttachmentParams `json:"attachment,omitempty"` 332 } 333 334 // FilesystemAttachmentParams holds the parameters for creating a filesystem 335 // attachment. 336 type FilesystemAttachmentParams struct { 337 FilesystemTag string `json:"filesystem-tag"` 338 MachineTag string `json:"machine-tag"` 339 FilesystemId string `json:"filesystem-id,omitempty"` 340 InstanceId string `json:"instance-id,omitempty"` 341 Provider string `json:"provider"` 342 MountPoint string `json:"mount-point,omitempty"` 343 ReadOnly bool `json:"read-only,omitempty"` 344 } 345 346 // FilesystemAttachmentResult holds the details of a single filesystem attachment, 347 // or an error. 348 type FilesystemAttachmentResult struct { 349 Result FilesystemAttachment `json:"result"` 350 Error *Error `json:"error,omitempty"` 351 } 352 353 // FilesystemAttachmentResults holds a set of FilesystemAttachmentResults. 354 type FilesystemAttachmentResults struct { 355 Results []FilesystemAttachmentResult `json:"results,omitempty"` 356 } 357 358 // FilesystemResult holds information about a filesystem. 359 type FilesystemResult struct { 360 Result Filesystem `json:"result"` 361 Error *Error `json:"error,omitempty"` 362 } 363 364 // FilesystemResults holds information about multiple filesystems. 365 type FilesystemResults struct { 366 Results []FilesystemResult `json:"results,omitempty"` 367 } 368 369 // FilesystemParamsResults holds provisioning parameters for a filesystem. 370 type FilesystemParamsResult struct { 371 Result FilesystemParams `json:"result"` 372 Error *Error `json:"error,omitempty"` 373 } 374 375 // FilesystemParamsResults holds provisioning parameters for multiple filesystems. 376 type FilesystemParamsResults struct { 377 Results []FilesystemParamsResult `json:"results,omitempty"` 378 } 379 380 // FilesystemAttachmentParamsResults holds provisioning parameters for a filesystem 381 // attachment. 382 type FilesystemAttachmentParamsResult struct { 383 Result FilesystemAttachmentParams `json:"result"` 384 Error *Error `json:"error,omitempty"` 385 } 386 387 // FilesystemAttachmentParamsResults holds provisioning parameters for multiple 388 // filesystem attachments. 389 type FilesystemAttachmentParamsResults struct { 390 Results []FilesystemAttachmentParamsResult `json:"results,omitempty"` 391 } 392 393 // StorageDetails holds information about storage. 394 type StorageDetails struct { 395 // StorageTag holds tag for this storage. 396 StorageTag string `json:"storage-tag"` 397 398 // OwnerTag holds tag for the owner of this storage, unit or application. 399 OwnerTag string `json:"owner-tag"` 400 401 // Kind holds what kind of storage this instance is. 402 Kind StorageKind `json:"kind"` 403 404 // Status contains the status of the storage instance. 405 Status EntityStatus `json:"status"` 406 407 // Persistent reports whether or not the underlying volume or 408 // filesystem is persistent; i.e. whether or not it outlives 409 // the machine that it is attached to. 410 Persistent bool `json:"persistent"` 411 412 // Attachments contains a mapping from unit tag to 413 // storage attachment details. 414 Attachments map[string]StorageAttachmentDetails `json:"attachments,omitempty"` 415 } 416 417 // StorageFilter holds filter terms for listing storage details. 418 type StorageFilter struct { 419 // We don't currently implement any filters. This exists to get the 420 // API structure right, and so we can add filters later as necessary. 421 } 422 423 // StorageFilters holds a set of storage filters. 424 type StorageFilters struct { 425 Filters []StorageFilter `json:"filters,omitempty"` 426 } 427 428 // StorageDetailsResult holds information about a storage instance 429 // or error related to its retrieval. 430 type StorageDetailsResult struct { 431 Result *StorageDetails `json:"result,omitempty"` 432 Error *Error `json:"error,omitempty"` 433 } 434 435 // StorageDetailsResults holds results for storage details or related storage error. 436 type StorageDetailsResults struct { 437 Results []StorageDetailsResult `json:"results,omitempty"` 438 } 439 440 // StorageDetailsListResult holds a collection of storage details. 441 type StorageDetailsListResult struct { 442 Result []StorageDetails `json:"result,omitempty"` 443 Error *Error `json:"error,omitempty"` 444 } 445 446 // StorageDetailsListResults holds a collection of collections of storage details. 447 type StorageDetailsListResults struct { 448 Results []StorageDetailsListResult `json:"results,omitempty"` 449 } 450 451 // StorageAttachmentDetails holds detailed information about a storage attachment. 452 type StorageAttachmentDetails struct { 453 // StorageTag is the tag of the storage instance. 454 StorageTag string `json:"storage-tag"` 455 456 // UnitTag is the tag of the unit attached to the storage instance. 457 UnitTag string `json:"unit-tag"` 458 459 // MachineTag is the tag of the machine that the attached unit is assigned to. 460 MachineTag string `json:"machine-tag"` 461 462 // Location holds location (mount point/device path) of 463 // the attached storage. 464 Location string `json:"location,omitempty"` 465 } 466 467 // StoragePool holds data for a pool instance. 468 type StoragePool struct { 469 // Name is the pool's name. 470 Name string `json:"name"` 471 472 // Provider is the type of storage provider this pool represents, eg "loop", "ebs". 473 Provider string `json:"provider"` 474 475 // Attrs are the pool's configuration attributes. 476 Attrs map[string]interface{} `json:"attrs"` 477 } 478 479 // StoragePoolFilter holds a filter for matching storage pools. 480 type StoragePoolFilter struct { 481 // Names are pool's names to filter on. 482 Names []string `json:"names,omitempty"` 483 484 // Providers are pool's storage provider types to filter on. 485 Providers []string `json:"providers,omitempty"` 486 } 487 488 // StoragePoolFilters holds a collection of storage pool filters. 489 type StoragePoolFilters struct { 490 Filters []StoragePoolFilter `json:"filters,omitempty"` 491 } 492 493 // StoragePoolsResult holds a collection of storage pools. 494 type StoragePoolsResult struct { 495 Result []StoragePool `json:"storage-pools,omitempty"` 496 Error *Error `json:"error,omitempty"` 497 } 498 499 // StoragePoolsResults holds a collection of storage pools results. 500 type StoragePoolsResults struct { 501 Results []StoragePoolsResult `json:"results,omitempty"` 502 } 503 504 // VolumeFilter holds a filter for volume list API call. 505 type VolumeFilter struct { 506 // Machines are machine tags to filter on. 507 Machines []string `json:"machines,omitempty"` 508 } 509 510 // IsEmpty determines if filter is empty 511 func (f *VolumeFilter) IsEmpty() bool { 512 return len(f.Machines) == 0 513 } 514 515 // VolumeFilters holds a collection of volume filters. 516 type VolumeFilters struct { 517 Filters []VolumeFilter `json:"filters,omitempty"` 518 } 519 520 // FilesystemFilter holds a filter for filter list API call. 521 type FilesystemFilter struct { 522 // Machines are machine tags to filter on. 523 Machines []string `json:"machines,omitempty"` 524 } 525 526 // IsEmpty determines if filter is empty 527 func (f *FilesystemFilter) IsEmpty() bool { 528 return len(f.Machines) == 0 529 } 530 531 // FilesystemFilters holds a collection of filesystem filters. 532 type FilesystemFilters struct { 533 Filters []FilesystemFilter `json:"filters,omitempty"` 534 } 535 536 // VolumeDetails describes a storage volume in the model 537 // for the purpose of volume CLI commands. 538 // 539 // This is kept separate from Volume which contains only information 540 // specific to the volume model, whereas VolumeDetails is intended 541 // to contain complete information about a volume and related 542 // information (status, attachments, storage). 543 type VolumeDetails struct { 544 // VolumeTag is the tag for the volume. 545 VolumeTag string `json:"volume-tag"` 546 547 // Info contains information about the volume. 548 Info VolumeInfo `json:"info"` 549 550 // Status contains the status of the volume. 551 Status EntityStatus `json:"status"` 552 553 // MachineAttachments contains a mapping from 554 // machine tag to volume attachment information. 555 MachineAttachments map[string]VolumeAttachmentInfo `json:"machine-attachments,omitempty"` 556 557 // Storage contains details about the storage instance 558 // that the volume is assigned to, if any. 559 Storage *StorageDetails `json:"storage,omitempty"` 560 } 561 562 // VolumeDetailsResult contains details about a volume, its attachments or 563 // an error preventing retrieving those details. 564 type VolumeDetailsResult struct { 565 // Result describes the volume in detail. 566 Result *VolumeDetails `json:"details,omitempty"` 567 568 // Error contains volume retrieval error. 569 Error *Error `json:"error,omitempty"` 570 } 571 572 // VolumeDetailsResults holds volume details. 573 type VolumeDetailsResults struct { 574 Results []VolumeDetailsResult `json:"results,omitempty"` 575 } 576 577 // VolumeDetailsListResult holds a collection of volume details. 578 type VolumeDetailsListResult struct { 579 Result []VolumeDetails `json:"result,omitempty"` 580 Error *Error `json:"error,omitempty"` 581 } 582 583 // VolumeDetailsListResults holds a collection of collections of volume details. 584 type VolumeDetailsListResults struct { 585 Results []VolumeDetailsListResult `json:"results,omitempty"` 586 } 587 588 // FilesystemDetails describes a storage filesystem in the model 589 // for the purpose of filesystem CLI commands. 590 // 591 // This is kept separate from Filesystem which contains only information 592 // specific to the filesystem model, whereas FilesystemDetails is intended 593 // to contain complete information about a filesystem and related 594 // information (status, attachments, storage). 595 type FilesystemDetails struct { 596 // FilesystemTag is the tag for the filesystem. 597 FilesystemTag string `json:"filesystem-tag"` 598 599 // VolumeTag is the tag for the volume backing the 600 // filesystem, if any. 601 VolumeTag string `json:"volume-tag,omitempty"` 602 603 // Info contains information about the filesystem. 604 Info FilesystemInfo `json:"info"` 605 606 // Status contains the status of the filesystem. 607 Status EntityStatus `json:"status"` 608 609 // MachineAttachments contains a mapping from 610 // machine tag to filesystem attachment information. 611 MachineAttachments map[string]FilesystemAttachmentInfo `json:"machine-attachments,omitempty"` 612 613 // Storage contains details about the storage instance 614 // that the volume is assigned to, if any. 615 Storage *StorageDetails `json:"storage,omitempty"` 616 } 617 618 // FilesystemDetailsResult contains details about a filesystem, its attachments or 619 // an error preventing retrieving those details. 620 type FilesystemDetailsResult struct { 621 Result *FilesystemDetails `json:"result,omitempty"` 622 Error *Error `json:"error,omitempty"` 623 } 624 625 // FilesystemDetailsResults holds filesystem details. 626 type FilesystemDetailsResults struct { 627 Results []FilesystemDetailsResult `json:"results,omitempty"` 628 } 629 630 // FilesystemDetailsListResult holds a collection of filesystem details. 631 type FilesystemDetailsListResult struct { 632 Result []FilesystemDetails `json:"result,omitempty"` 633 Error *Error `json:"error,omitempty"` 634 } 635 636 // FilesystemDetailsListResults holds a collection of collections of 637 // filesystem details. 638 type FilesystemDetailsListResults struct { 639 Results []FilesystemDetailsListResult `json:"results,omitempty"` 640 } 641 642 // StorageConstraints contains constraints for storage instance. 643 type StorageConstraints struct { 644 // Pool is the name of the storage pool from which to provision the 645 // storage instance. 646 Pool string `json:"pool,omitempty"` 647 648 // Size is the required size of the storage instance, in MiB. 649 Size *uint64 `json:"size,omitempty"` 650 651 // Count is the required number of storage instances. 652 Count *uint64 `json:"count,omitempty"` 653 } 654 655 // StorageAddParams holds storage details to add to a unit dynamically. 656 type StorageAddParams struct { 657 // UnitTag is unit name. 658 UnitTag string `json:"unit"` 659 660 // StorageName is the name of the storage as specified in the charm. 661 StorageName string `json:"name"` 662 663 // Constraints are specified storage constraints. 664 Constraints StorageConstraints `json:"storage"` 665 } 666 667 // StoragesAddParams holds storage details to add to units dynamically. 668 type StoragesAddParams struct { 669 Storages []StorageAddParams `json:"storages"` 670 }