blob: 010bf4279cba98ac782aa34370081f3f7fc5634c [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 Perritt01686cd2014-10-24 14:10:16 -050029 bd := []osBFV.BlockDevice{
30 osBFV.BlockDevice{
31 UUID: options.imageID,
32 SourceType: osBFV.Image,
33 VolumeSize: 10,
34 },
Jon Perrittd9a4bf72014-10-23 23:44:04 -050035 }
36
Jon Perritt8dd49db2014-10-24 12:39:07 -050037 server, err := bootfromvolume.Create(client, servers.CreateOpts{
Jon Perrittd9a4bf72014-10-23 23:44:04 -050038 Name: name,
Jon Perritt8dd49db2014-10-24 12:39:07 -050039 FlavorRef: "performance1-1",
Jon Perrittd9a4bf72014-10-23 23:44:04 -050040 BlockDevice: bd,
41 }).Extract()
42 th.AssertNoErr(t, err)
Jon Perritt8dd49db2014-10-24 12:39:07 -050043 t.Logf("Created server: %+v\n", server)
Jon Perritt01686cd2014-10-24 14:10:16 -050044 //defer deleteServer(t, client, server)
Jon Perritt8dd49db2014-10-24 12:39:07 -050045 t.Logf("Deleting server [%s]...", name)
Jon Perrittd9a4bf72014-10-23 23:44:04 -050046}