github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/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:"blockdevices,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:"machineblockdevices"` 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 50 OwnerTag string 51 Kind StorageKind 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 91 OwnerTag string 92 UnitTag string 93 94 Kind StorageKind 95 Location string 96 Life 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:"storagetag"` 103 UnitTag string `json:"unittag"` 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:"machinetag"` 154 // AttachmentTag is the tag of the volume or filesystem whose 155 // attachment to the machine is represented. 156 AttachmentTag string `json:"attachmenttag"` 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 environment. 166 type Volume struct { 167 VolumeTag string `json:"volumetag"` 168 Info VolumeInfo `json:"info"` 169 } 170 171 // Volume describes a storage volume in the environment. 172 type VolumeInfo struct { 173 VolumeId string `json:"volumeid"` 174 HardwareId string `json:"hardwareid,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 environment. 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:"volumetag"` 188 MachineTag string `json:"machinetag"` 189 Info VolumeAttachmentInfo `json:"info"` 190 } 191 192 // VolumeAttachmentInfo describes a volume attachment. 193 type VolumeAttachmentInfo struct { 194 DeviceName string `json:"devicename,omitempty"` 195 BusAddress string `json:"busaddress,omitempty"` 196 ReadOnly bool `json:"read-only,omitempty"` 197 } 198 199 // VolumeAttachments describes a set of storage volume attachments. 200 type VolumeAttachments struct { 201 VolumeAttachments []VolumeAttachment `json:"volumeattachments"` 202 } 203 204 // VolumeParams holds the parameters for creating a storage volume. 205 type VolumeParams struct { 206 VolumeTag string `json:"volumetag"` 207 Size uint64 `json:"size"` 208 Provider string `json:"provider"` 209 Attributes map[string]interface{} `json:"attributes,omitempty"` 210 Tags map[string]string `json:"tags,omitempty"` 211 Attachment *VolumeAttachmentParams `json:"attachment,omitempty"` 212 } 213 214 // VolumeAttachmentParams holds the parameters for creating a volume 215 // attachment. 216 type VolumeAttachmentParams struct { 217 VolumeTag string `json:"volumetag"` 218 MachineTag string `json:"machinetag"` 219 VolumeId string `json:"volumeid,omitempty"` 220 InstanceId string `json:"instanceid,omitempty"` 221 Provider string `json:"provider"` 222 ReadOnly bool `json:"read-only,omitempty"` 223 } 224 225 // VolumeAttachmentsResult holds the volume attachments for a single 226 // machine, or an error. 227 type VolumeAttachmentsResult struct { 228 Attachments []VolumeAttachment `json:"attachments,omitempty"` 229 Error *Error `json:"error,omitempty"` 230 } 231 232 // VolumeAttachmentsResults holds a set of VolumeAttachmentsResults for 233 // a set of machines. 234 type VolumeAttachmentsResults struct { 235 Results []VolumeAttachmentsResult `json:"results,omitempty"` 236 } 237 238 // VolumeAttachmentResult holds the details of a single volume attachment, 239 // or an error. 240 type VolumeAttachmentResult struct { 241 Result VolumeAttachment `json:"result"` 242 Error *Error `json:"error,omitempty"` 243 } 244 245 // VolumeAttachmentResults holds a set of VolumeAttachmentResults. 246 type VolumeAttachmentResults struct { 247 Results []VolumeAttachmentResult `json:"results,omitempty"` 248 } 249 250 // VolumeResult holds information about a volume. 251 type VolumeResult struct { 252 Result Volume `json:"result"` 253 Error *Error `json:"error,omitempty"` 254 } 255 256 // VolumeResults holds information about multiple volumes. 257 type VolumeResults struct { 258 Results []VolumeResult `json:"results,omitempty"` 259 } 260 261 // VolumeParamsResults holds provisioning parameters for a volume. 262 type VolumeParamsResult struct { 263 Result VolumeParams `json:"result"` 264 Error *Error `json:"error,omitempty"` 265 } 266 267 // VolumeParamsResults holds provisioning parameters for multiple volumes. 268 type VolumeParamsResults struct { 269 Results []VolumeParamsResult `json:"results,omitempty"` 270 } 271 272 // VolumeAttachmentParamsResults holds provisioning parameters for a volume 273 // attachment. 274 type VolumeAttachmentParamsResult struct { 275 Result VolumeAttachmentParams `json:"result"` 276 Error *Error `json:"error,omitempty"` 277 } 278 279 // VolumeAttachmentParamsResults holds provisioning parameters for multiple 280 // volume attachments. 281 type VolumeAttachmentParamsResults struct { 282 Results []VolumeAttachmentParamsResult `json:"results,omitempty"` 283 } 284 285 // Filesystem identifies and describes a storage filesystem in the environment. 286 type Filesystem struct { 287 FilesystemTag string `json:"filesystemtag"` 288 VolumeTag string `json:"volumetag,omitempty"` 289 Info FilesystemInfo `json:"info"` 290 } 291 292 // Filesystem describes a storage filesystem in the environment. 293 type FilesystemInfo struct { 294 FilesystemId string `json:"filesystemid"` 295 // Size is the size of the filesystem in MiB. 296 Size uint64 `json:"size"` 297 } 298 299 // Filesystems describes a set of storage filesystems in the environment. 300 type Filesystems struct { 301 Filesystems []Filesystem `json:"filesystems"` 302 } 303 304 // FilesystemAttachment identifies and describes a filesystem attachment. 305 type FilesystemAttachment struct { 306 FilesystemTag string `json:"filesystemtag"` 307 MachineTag string `json:"machinetag"` 308 Info FilesystemAttachmentInfo `json:"info"` 309 } 310 311 // FilesystemAttachmentInfo describes a filesystem attachment. 312 type FilesystemAttachmentInfo struct { 313 MountPoint string `json:"mountpoint,omitempty"` 314 ReadOnly bool `json:"read-only,omitempty"` 315 } 316 317 // FilesystemAttachments describes a set of storage filesystem attachments. 318 type FilesystemAttachments struct { 319 FilesystemAttachments []FilesystemAttachment `json:"filesystemattachments"` 320 } 321 322 // FilesystemParams holds the parameters for creating a storage filesystem. 323 type FilesystemParams struct { 324 FilesystemTag string `json:"filesystemtag"` 325 VolumeTag string `json:"volumetag,omitempty"` 326 Size uint64 `json:"size"` 327 Provider string `json:"provider"` 328 Attributes map[string]interface{} `json:"attributes,omitempty"` 329 Tags map[string]string `json:"tags,omitempty"` 330 Attachment *FilesystemAttachmentParams `json:"attachment,omitempty"` 331 } 332 333 // FilesystemAttachmentParams holds the parameters for creating a filesystem 334 // attachment. 335 type FilesystemAttachmentParams struct { 336 FilesystemTag string `json:"filesystemtag"` 337 MachineTag string `json:"machinetag"` 338 FilesystemId string `json:"filesystemid,omitempty"` 339 InstanceId string `json:"instanceid,omitempty"` 340 Provider string `json:"provider"` 341 MountPoint string `json:"mountpoint,omitempty"` 342 ReadOnly bool `json:"read-only,omitempty"` 343 } 344 345 // FilesystemAttachmentResult holds the details of a single filesystem attachment, 346 // or an error. 347 type FilesystemAttachmentResult struct { 348 Result FilesystemAttachment `json:"result"` 349 Error *Error `json:"error,omitempty"` 350 } 351 352 // FilesystemAttachmentResults holds a set of FilesystemAttachmentResults. 353 type FilesystemAttachmentResults struct { 354 Results []FilesystemAttachmentResult `json:"results,omitempty"` 355 } 356 357 // FilesystemResult holds information about a filesystem. 358 type FilesystemResult struct { 359 Result Filesystem `json:"result"` 360 Error *Error `json:"error,omitempty"` 361 } 362 363 // FilesystemResults holds information about multiple filesystems. 364 type FilesystemResults struct { 365 Results []FilesystemResult `json:"results,omitempty"` 366 } 367 368 // FilesystemParamsResults holds provisioning parameters for a filesystem. 369 type FilesystemParamsResult struct { 370 Result FilesystemParams `json:"result"` 371 Error *Error `json:"error,omitempty"` 372 } 373 374 // FilesystemParamsResults holds provisioning parameters for multiple filesystems. 375 type FilesystemParamsResults struct { 376 Results []FilesystemParamsResult `json:"results,omitempty"` 377 } 378 379 // FilesystemAttachmentParamsResults holds provisioning parameters for a filesystem 380 // attachment. 381 type FilesystemAttachmentParamsResult struct { 382 Result FilesystemAttachmentParams `json:"result"` 383 Error *Error `json:"error,omitempty"` 384 } 385 386 // FilesystemAttachmentParamsResults holds provisioning parameters for multiple 387 // filesystem attachments. 388 type FilesystemAttachmentParamsResults struct { 389 Results []FilesystemAttachmentParamsResult `json:"results,omitempty"` 390 } 391 392 // StorageDetails holds information about storage. 393 type StorageDetails struct { 394 395 // StorageTag holds tag for this storage. 396 StorageTag string `json:"storagetag"` 397 398 // OwnerTag holds tag for the owner of this storage, unit or service. 399 OwnerTag string `json:"ownertag"` 400 401 // Kind holds what kind of storage this instance is. 402 Kind StorageKind `json:"kind"` 403 404 // Status indicates storage status, e.g. pending, provisioned, attached. 405 Status string `json:"status,omitempty"` 406 407 // UnitTag holds tag for unit for attached instances. 408 UnitTag string `json:"unittag,omitempty"` 409 410 // Location holds location for provisioned attached instances. 411 Location string `json:"location,omitempty"` 412 413 // Persistent indicates whether the storage is persistent or not. 414 Persistent bool `json:"persistent"` 415 } 416 417 // StorageDetailsResult holds information about a storage instance 418 // or error related to its retrieval. 419 type StorageDetailsResult struct { 420 Result StorageDetails `json:"result"` 421 Error *Error `json:"error,omitempty"` 422 } 423 424 // StorageDetailsResults holds results for storage details or related storage error. 425 type StorageDetailsResults struct { 426 Results []StorageDetailsResult `json:"results,omitempty"` 427 } 428 429 // StorageInfo contains information about a storage as well as 430 // potentially an error related to information retrieval. 431 type StorageInfo struct { 432 StorageDetails `json:"result"` 433 Error *Error `json:"error,omitempty"` 434 } 435 436 // StorageInfosResult holds storage details. 437 type StorageInfosResult struct { 438 Results []StorageInfo `json:"results,omitempty"` 439 } 440 441 // StoragePool holds data for a pool instance. 442 type StoragePool struct { 443 444 // Name is the pool's name. 445 Name string `json:"name"` 446 447 // Provider is the type of storage provider this pool represents, eg "loop", "ebs". 448 Provider string `json:"provider"` 449 450 // Attrs are the pool's configuration attributes. 451 Attrs map[string]interface{} `json:"attrs"` 452 } 453 454 // StoragePoolFilter holds a filter for pool API call. 455 type StoragePoolFilter struct { 456 457 // Names are pool's names to filter on. 458 Names []string `json:"names,omitempty"` 459 460 // Providers are pool's storage provider types to filter on. 461 Providers []string `json:"providers,omitempty"` 462 } 463 464 // StoragePoolsResult holds a collection of pool instances. 465 type StoragePoolsResult struct { 466 Results []StoragePool `json:"results,omitempty"` 467 } 468 469 // VolumeFilter holds a filter for volume list API call. 470 type VolumeFilter struct { 471 // Machines are machine tags to filter on. 472 Machines []string `json:"machines,omitempty"` 473 } 474 475 // IsEmpty determines if filter is empty 476 func (f *VolumeFilter) IsEmpty() bool { 477 return len(f.Machines) == 0 478 } 479 480 // VolumeInstance describes a storage volume in the environment 481 // for the purpose of volume CLI commands. 482 // It is kept separate from Volume which is primarily used in uniter 483 // and may answer different concerns as well as serve different purposes. 484 type VolumeInstance struct { 485 486 // VolumeTag is tag for this volume instance. 487 VolumeTag string `json:"volumetag"` 488 489 // VolumeId is a unique provider-supplied ID for the volume. 490 VolumeId string `json:"volumeid"` 491 492 // HardwareId is the volume's hardware ID. 493 HardwareId string `json:"hardwareid,omitempty"` 494 495 // Size is the size of the volume in MiB. 496 Size uint64 `json:"size"` 497 498 // Persistent reflects whether the volume is destroyed with the 499 // machine to which it is attached. 500 Persistent bool `json:"persistent"` 501 502 // StorageInstance returns the tag of the storage instance that this 503 // volume is assigned to, if any. 504 StorageTag string `json:"storage,omitempty"` 505 506 // UnitTag is the tag of the unit attached to storage instance 507 // for this volume. 508 UnitTag string `json:"unit,omitempty"` 509 510 // Status contains the current status of the volume. 511 Status EntityStatus `json:"status"` 512 } 513 514 // VolumeItem contain volume, its attachments 515 // and retrieval error. 516 type VolumeItem struct { 517 // Volume is storage volume. 518 Volume VolumeInstance `json:"volume,omitempty"` 519 520 // Attachments are storage volume attachments. 521 Attachments []VolumeAttachment `json:"attachments,omitempty"` 522 523 // Error contains volume retrieval error. 524 Error *Error `json:"error,omitempty"` 525 } 526 527 // VolumeItemsResult holds volumes. 528 type VolumeItemsResult struct { 529 Results []VolumeItem `json:"results,omitempty"` 530 } 531 532 // StorageConstraints contains constraints for storage instance. 533 type StorageConstraints struct { 534 // Pool is the name of the storage pool from which to provision the 535 // storage instance. 536 Pool string `bson:"pool,omitempty"` 537 538 // Size is the required size of the storage instance, in MiB. 539 Size *uint64 `bson:"size,omitempty"` 540 541 // Count is the required number of storage instances. 542 Count *uint64 `bson:"count,omitempty"` 543 } 544 545 // StorageAddParams holds storage details to add to a unit dynamically. 546 type StorageAddParams struct { 547 // UnitTag is unit name. 548 UnitTag string `json:"unit"` 549 550 // StorageName is the name of the storage as specified in the charm. 551 StorageName string `bson:"name"` 552 553 // Constraints are specified storage constraints. 554 Constraints StorageConstraints `json:"storage"` 555 } 556 557 // StoragesAddParams holds storage details to add to units dynamically. 558 type StoragesAddParams struct { 559 Storages []StorageAddParams `json:"storages"` 560 }