Created
November 17, 2014 15:56
-
-
Save smashwilson/fb9c27f70581990fb203 to your computer and use it in GitHub Desktop.
Using multiple OpenStack extensions that modify the server creation options in Gophercloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"github.com/rackspace/gophercloud/openstack/compute/v2/servers" | |
bfw "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume" | |
dc "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig" | |
) | |
// 1. Base CreateOpts | |
baseOpts := servers.CreateOpts{ | |
Name: "servername", | |
FlavorRef: "1", | |
ImageRef: "ubuntu-or-something", | |
} | |
// 2. BFV | |
bfvOpts := bfv.CreateOptsExt{ | |
CreateOptsBuilder: baseOpts, // Stack it on | |
BlockDevice: []bfv.BlockDevice{ | |
SourceType: "volume", | |
UUID: "my-volume-id", | |
} | |
} | |
// 3. DiskConfig | |
dcOpts := dc.CreateOptsExt{ | |
CreateOptsBuilder: bfvOpts, | |
DiskConfig: dc.Auto, | |
} | |
// 4. :rocket: | |
server, err := servers.Create(serviceClient, dcOpts).Extract() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment