github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/storage/volume.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package storage 5 6 import "github.com/juju/names/v5" 7 8 type DeviceType string 9 10 var ( 11 DeviceTypeLocal DeviceType = "local" 12 DeviceTypeISCSI DeviceType = "iscsi" 13 ) 14 15 // Volume identifies and describes a volume (disk, logical volume, etc.) 16 type Volume struct { 17 // Name is a unique name assigned by Juju to the volume. 18 Tag names.VolumeTag 19 20 VolumeInfo 21 } 22 23 // VolumeInfo describes a volume (disk, logical volume etc.) 24 type VolumeInfo struct { 25 // VolumeId is a unique provider-supplied ID for the volume. 26 // VolumeId is required to be unique for the lifetime of the 27 // volume, but may be reused. 28 VolumeId string 29 30 // HardwareId is the volume's hardware ID. Not all volumes have 31 // a hardware ID, so this may be left blank. 32 HardwareId string 33 34 // WWN is the volume's World Wide Name (WWN). Not all volumes 35 // have a WWN, so this may be left blank. 36 WWN string 37 38 // Size is the size of the volume, in MiB. 39 Size uint64 40 41 // Persistent reflects whether the volume is destroyed with the 42 // machine to which it is attached. 43 Persistent bool 44 } 45 46 // VolumeAttachment identifies and describes machine-specific volume 47 // attachment information, including how the volume is exposed on the 48 // machine. 49 type VolumeAttachment struct { 50 // Volume is the unique tag assigned by Juju for the volume 51 // that this attachment corresponds to. 52 Volume names.VolumeTag 53 54 // Machine is the unique tag assigned by Juju for the machine that 55 // this attachment corresponds to. 56 Machine names.Tag 57 58 VolumeAttachmentInfo 59 } 60 61 type VolumeAttachmentPlan struct { 62 // Volume is the unique tag assigned by Juju for the volume 63 // that this attachment corresponds to. 64 Volume names.VolumeTag 65 66 // Machine is the unique tag assigned by Juju for the machine that 67 // this attachment corresponds to. 68 Machine names.MachineTag 69 70 VolumeAttachmentPlanInfo 71 } 72 73 type VolumeAttachmentPlanInfo struct { 74 // DeviceType describes what type of volume we are dealing with 75 // possible options are: 76 // * local - a block device that is directly attached to this instance 77 // * iscsi - an iSCSI disk. This type of disk will require the machine agent 78 // to execute additional steps before the device is available 79 DeviceType DeviceType 80 // DeviceAttributes is a map that contains DeviceType specific initialization 81 // values. For example, in the case of iscsi, it may contain server address:port, 82 // target, chap secrets, etc. 83 DeviceAttributes map[string]string 84 } 85 86 // VolumeAttachmentInfo describes machine-specific volume attachment 87 // information, including how the volume is exposed on the machine. 88 type VolumeAttachmentInfo struct { 89 // DeviceName is the volume's OS-specific device name (e.g. "sdb"). 90 // 91 // If the device name may change (e.g. on machine restart), then this 92 // field must be left blank. 93 DeviceName string 94 95 // DeviceLink is an OS-specific device link that must exactly match 96 // one of the block device's links when attached. 97 // 98 // If no device link is known, or it may change (e.g. on machine 99 // restart), then this field must be left blank. 100 DeviceLink string 101 102 // BusAddress is the bus address, where the volume is attached to 103 // the machine. 104 // 105 // The format of this field must match the field of the same name 106 // in BlockDevice. 107 BusAddress string 108 109 // ReadOnly signifies whether the volume is read only or writable. 110 ReadOnly bool 111 112 // PlanInfo holds information that the machine agent might use to 113 // initialize the block device that has been attached to it. 114 PlanInfo *VolumeAttachmentPlanInfo 115 }