PageRenderTime 103ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/Godeps/_workspace/src/github.com/rackspace/gophercloud/acceptance/rackspace/compute/v2/bootfromvolume_test.go

https://gitlab.com/Red54/machine
Go | 49 lines | 37 code | 11 blank | 1 comment | 2 complexity | b2811061e04039d6016c3c00aecdc137 MD5 | raw file
  1. // +build acceptance
  2. package v2
  3. import (
  4. "testing"
  5. "github.com/rackspace/gophercloud/acceptance/tools"
  6. osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
  7. "github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume"
  8. "github.com/rackspace/gophercloud/rackspace/compute/v2/servers"
  9. th "github.com/rackspace/gophercloud/testhelper"
  10. )
  11. func TestBootFromVolume(t *testing.T) {
  12. client, err := newClient()
  13. th.AssertNoErr(t, err)
  14. if testing.Short() {
  15. t.Skip("Skipping test that requires server creation in short mode.")
  16. }
  17. options, err := optionsFromEnv()
  18. th.AssertNoErr(t, err)
  19. name := tools.RandomString("Gophercloud-", 8)
  20. t.Logf("Creating server [%s].", name)
  21. bd := []osBFV.BlockDevice{
  22. osBFV.BlockDevice{
  23. UUID: options.imageID,
  24. SourceType: osBFV.Image,
  25. VolumeSize: 10,
  26. },
  27. }
  28. server, err := bootfromvolume.Create(client, servers.CreateOpts{
  29. Name: name,
  30. FlavorRef: "performance1-1",
  31. BlockDevice: bd,
  32. }).Extract()
  33. th.AssertNoErr(t, err)
  34. t.Logf("Created server: %+v\n", server)
  35. defer deleteServer(t, client, server)
  36. getServer(t, client, server)
  37. listServers(t, client)
  38. }