/Godeps/_workspace/src/github.com/rackspace/gophercloud/acceptance/openstack/compute/v2/bootfromvolume_test.go
Go | 55 lines | 44 code | 10 blank | 1 comment | 6 complexity | 5951fdc1647d97e2ecb7c8443bb3b9b0 MD5 | raw file
- // +build acceptance
- package v2
- import (
- "testing"
- "github.com/rackspace/gophercloud/acceptance/tools"
- "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
- "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
- th "github.com/rackspace/gophercloud/testhelper"
- )
- func TestBootFromVolume(t *testing.T) {
- client, err := newClient()
- th.AssertNoErr(t, err)
- if testing.Short() {
- t.Skip("Skipping test that requires server creation in short mode.")
- }
- choices, err := ComputeChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
- name := tools.RandomString("Gophercloud-", 8)
- t.Logf("Creating server [%s].", name)
- bd := []bootfromvolume.BlockDevice{
- bootfromvolume.BlockDevice{
- UUID: choices.ImageID,
- SourceType: bootfromvolume.Image,
- VolumeSize: 10,
- },
- }
- serverCreateOpts := servers.CreateOpts{
- Name: name,
- FlavorRef: choices.FlavorID,
- ImageRef: choices.ImageID,
- }
- server, err := bootfromvolume.Create(client, bootfromvolume.CreateOptsExt{
- serverCreateOpts,
- bd,
- }).Extract()
- th.AssertNoErr(t, err)
- if err = waitForStatus(client, server, "ACTIVE"); err != nil {
- t.Fatal(err)
- }
- t.Logf("Created server: %+v\n", server)
- defer servers.Delete(client, server.ID)
- t.Logf("Deleting server [%s]...", name)
- }