PageRenderTime 167ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/JamesClonk/machine
Go | 55 lines | 44 code | 10 blank | 1 comment | 6 complexity | 5951fdc1647d97e2ecb7c8443bb3b9b0 MD5 | raw file
  1. // +build acceptance
  2. package v2
  3. import (
  4. "testing"
  5. "github.com/rackspace/gophercloud/acceptance/tools"
  6. "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
  7. "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
  8. th "github.com/rackspace/gophercloud/testhelper"
  9. )
  10. func TestBootFromVolume(t *testing.T) {
  11. client, err := newClient()
  12. th.AssertNoErr(t, err)
  13. if testing.Short() {
  14. t.Skip("Skipping test that requires server creation in short mode.")
  15. }
  16. choices, err := ComputeChoicesFromEnv()
  17. if err != nil {
  18. t.Fatal(err)
  19. }
  20. name := tools.RandomString("Gophercloud-", 8)
  21. t.Logf("Creating server [%s].", name)
  22. bd := []bootfromvolume.BlockDevice{
  23. bootfromvolume.BlockDevice{
  24. UUID: choices.ImageID,
  25. SourceType: bootfromvolume.Image,
  26. VolumeSize: 10,
  27. },
  28. }
  29. serverCreateOpts := servers.CreateOpts{
  30. Name: name,
  31. FlavorRef: choices.FlavorID,
  32. ImageRef: choices.ImageID,
  33. }
  34. server, err := bootfromvolume.Create(client, bootfromvolume.CreateOptsExt{
  35. serverCreateOpts,
  36. bd,
  37. }).Extract()
  38. th.AssertNoErr(t, err)
  39. if err = waitForStatus(client, server, "ACTIVE"); err != nil {
  40. t.Fatal(err)
  41. }
  42. t.Logf("Created server: %+v\n", server)
  43. defer servers.Delete(client, server.ID)
  44. t.Logf("Deleting server [%s]...", name)
  45. }