blob: d08abe6a54346747ba51043c9de056584b4202ad [file] [log] [blame]
Jon Perritt0b09d1d2014-10-24 13:26:18 -05001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
9 "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
10 th "github.com/rackspace/gophercloud/testhelper"
11 "github.com/smashwilson/gophercloud/acceptance/tools"
12)
13
14func TestBootFromVolume(t *testing.T) {
15 client, err := newClient()
16 th.AssertNoErr(t, err)
17
18 if testing.Short() {
19 t.Skip("Skipping test that requires server creation in short mode.")
20 }
21
22 choices, err := ComputeChoicesFromEnv()
23 if err != nil {
24 t.Fatal(err)
25 }
26
27 name := tools.RandomString("Gophercloud-", 8)
28 t.Logf("Creating server [%s].", name)
29
Jon Perritt01686cd2014-10-24 14:10:16 -050030 bd := []bootfromvolume.BlockDevice{
31 bootfromvolume.BlockDevice{
32 UUID: choices.ImageID,
33 SourceType: bootfromvolume.Image,
34 VolumeSize: 10,
35 },
Jon Perritt0b09d1d2014-10-24 13:26:18 -050036 }
37
38 serverCreateOpts := servers.CreateOpts{
39 Name: name,
40 FlavorRef: "3",
41 }
42 server, err := bootfromvolume.Create(client, bootfromvolume.CreateOptsExt{
43 serverCreateOpts,
44 bd,
45 }).Extract()
46 th.AssertNoErr(t, err)
47 t.Logf("Created server: %+v\n", server)
Jon Perritt01686cd2014-10-24 14:10:16 -050048 //defer deleteServer(t, client, server)
Jon Perritt0b09d1d2014-10-24 13:26:18 -050049 t.Logf("Deleting server [%s]...", name)
50}