Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Jon Perritt | 8dd49db | 2014-10-24 12:39:07 -0500 | [diff] [blame] | 8 | 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 Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 11 | th "github.com/rackspace/gophercloud/testhelper" |
| 12 | "github.com/smashwilson/gophercloud/acceptance/tools" |
| 13 | ) |
| 14 | |
| 15 | func 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 Perritt | 01686cd | 2014-10-24 14:10:16 -0500 | [diff] [blame] | 29 | bd := []osBFV.BlockDevice{ |
| 30 | osBFV.BlockDevice{ |
| 31 | UUID: options.imageID, |
| 32 | SourceType: osBFV.Image, |
| 33 | VolumeSize: 10, |
| 34 | }, |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 35 | } |
| 36 | |
Jon Perritt | 8dd49db | 2014-10-24 12:39:07 -0500 | [diff] [blame] | 37 | server, err := bootfromvolume.Create(client, servers.CreateOpts{ |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 38 | Name: name, |
Jon Perritt | 8dd49db | 2014-10-24 12:39:07 -0500 | [diff] [blame] | 39 | FlavorRef: "performance1-1", |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 40 | BlockDevice: bd, |
| 41 | }).Extract() |
| 42 | th.AssertNoErr(t, err) |
Jon Perritt | 8dd49db | 2014-10-24 12:39:07 -0500 | [diff] [blame] | 43 | t.Logf("Created server: %+v\n", server) |
Jon Perritt | 01686cd | 2014-10-24 14:10:16 -0500 | [diff] [blame] | 44 | //defer deleteServer(t, client, server) |
Jon Perritt | 8dd49db | 2014-10-24 12:39:07 -0500 | [diff] [blame] | 45 | t.Logf("Deleting server [%s]...", name) |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 46 | } |