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