1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/*
Package bootfromvolume extends a server create request with the ability to
specify block device options. This can be used to boot a server from a block
storage volume as well as specify multiple ephemeral disks upon creation.
It is recommended to refer to the Block Device Mapping documentation to see
all possible ways to configure a server's block devices at creation time:
https://docs.openstack.org/nova/latest/user/block-device-mapping.html
Note that this package implements `block_device_mapping_v2`.
Example of Creating a Server From an Image
This example will boot a server from an image and use a standard ephemeral
disk as the server's root disk. This is virtually no different than creating
a server without using block device mappings.
blockDevices := []bootfromvolume.BlockDevice{
bootfromvolume.BlockDevice{
BootIndex: 0,
DeleteOnTermination: true,
DestinationType: bootfromvolume.DestinationLocal,
SourceType: bootfromvolume.SourceImage,
UUID: "image-uuid",
},
}
serverCreateOpts := servers.CreateOpts{
Name: "server_name",
FlavorRef: "flavor-uuid",
ImageRef: "image-uuid",
}
createOpts := bootfromvolume.CreateOptsExt{
CreateOptsBuilder: serverCreateOpts,
BlockDevice: blockDevices,
}
server, err := bootfromvolume.Create(client, createOpts).Extract()
if err != nil {
panic(err)
}
Example of Creating a Server From a New Volume
This example will create a block storage volume based on the given Image. The
server will use this volume as its root disk.
blockDevices := []bootfromvolume.BlockDevice{
bootfromvolume.BlockDevice{
DeleteOnTermination: true,
DestinationType: bootfromvolume.DestinationVolume,
SourceType: bootfromvolume.SourceImage,
UUID: "image-uuid",
VolumeSize: 2,
},
}
serverCreateOpts := servers.CreateOpts{
Name: "server_name",
FlavorRef: "flavor-uuid",
}
createOpts := bootfromvolume.CreateOptsExt{
CreateOptsBuilder: serverCreateOpts,
BlockDevice: blockDevices,
}
server, err := bootfromvolume.Create(client, createOpts).Extract()
if err != nil {
panic(err)
}
Example of Creating a Server From an Existing Volume
This example will create a server with an existing volume as its root disk.
blockDevices := []bootfromvolume.BlockDevice{
bootfromvolume.BlockDevice{
DeleteOnTermination: true,
DestinationType: bootfromvolume.DestinationVolume,
SourceType: bootfromvolume.SourceVolume,
UUID: "volume-uuid",
},
}
serverCreateOpts := servers.CreateOpts{
Name: "server_name",
FlavorRef: "flavor-uuid",
}
createOpts := bootfromvolume.CreateOptsExt{
CreateOptsBuilder: serverCreateOpts,
BlockDevice: blockDevices,
}
server, err := bootfromvolume.Create(client, createOpts).Extract()
if err != nil {
panic(err)
}
Example of Creating a Server with Multiple Ephemeral Disks
This example will create a server with multiple ephemeral disks. The first
block device will be based off of an existing Image. Each additional
ephemeral disks must have an index of -1.
blockDevices := []bootfromvolume.BlockDevice{
bootfromvolume.BlockDevice{
BootIndex: 0,
DestinationType: bootfromvolume.DestinationLocal,
DeleteOnTermination: true,
SourceType: bootfromvolume.SourceImage,
UUID: "image-uuid",
VolumeSize: 5,
},
bootfromvolume.BlockDevice{
BootIndex: -1,
DestinationType: bootfromvolume.DestinationLocal,
DeleteOnTermination: true,
GuestFormat: "ext4",
SourceType: bootfromvolume.SourceBlank,
VolumeSize: 1,
},
bootfromvolume.BlockDevice{
BootIndex: -1,
DestinationType: bootfromvolume.DestinationLocal,
DeleteOnTermination: true,
GuestFormat: "ext4",
SourceType: bootfromvolume.SourceBlank,
VolumeSize: 1,
},
}
serverCreateOpts := servers.CreateOpts{
Name: "server_name",
FlavorRef: "flavor-uuid",
ImageRef: "image-uuid",
}
createOpts := bootfromvolume.CreateOptsExt{
CreateOptsBuilder: serverCreateOpts,
BlockDevice: blockDevices,
}
server, err := bootfromvolume.Create(client, createOpts).Extract()
if err != nil {
panic(err)
}
*/
package bootfromvolume
|