blob: 591a1373ac2806236d48d804530d0fe67a8b3bc3 [file] [log] [blame]
Jon Perrittd9a4bf72014-10-23 23:44:04 -05001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
Jon Perritt8dd49db2014-10-24 12:39:07 -05008 osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
9 "github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume"
10 "github.com/rackspace/gophercloud/rackspace/compute/v2/servers"
Jon Perrittd9a4bf72014-10-23 23:44:04 -050011 th "github.com/rackspace/gophercloud/testhelper"
12 "github.com/smashwilson/gophercloud/acceptance/tools"
13)
14
15func TestBootFromVolume(t *testing.T) {
16 client, err := newClient()
17 th.AssertNoErr(t, err)
18
19 if testing.Short() {
20 t.Skip("Skipping test that requires server creation in short mode.")
21 }
22
23 options, err := optionsFromEnv()
24 th.AssertNoErr(t, err)
25
26 name := tools.RandomString("Gophercloud-", 8)
27 t.Logf("Creating server [%s].", name)
28
Jon Perritt8dd49db2014-10-24 12:39:07 -050029 bd := osBFV.BlockDevice{
Jon Perrittd9a4bf72014-10-23 23:44:04 -050030 UUID: options.imageID,
31 SourceType: "image",
Jon Perritt8dd49db2014-10-24 12:39:07 -050032 VolumeSize: 10,
Jon Perrittd9a4bf72014-10-23 23:44:04 -050033 }
34
Jon Perritt8dd49db2014-10-24 12:39:07 -050035 server, err := bootfromvolume.Create(client, servers.CreateOpts{
Jon Perrittd9a4bf72014-10-23 23:44:04 -050036 Name: name,
Jon Perritt8dd49db2014-10-24 12:39:07 -050037 FlavorRef: "performance1-1",
Jon Perrittd9a4bf72014-10-23 23:44:04 -050038 BlockDevice: bd,
39 }).Extract()
40 th.AssertNoErr(t, err)
Jon Perritt8dd49db2014-10-24 12:39:07 -050041 t.Logf("Created server: %+v\n", server)
42 defer deleteServer(t, client, server)
43 t.Logf("Deleting server [%s]...", name)
Jon Perrittd9a4bf72014-10-23 23:44:04 -050044}