PageRenderTime 61ms CodeModel.GetById 28ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/JamesClonk/machine
Go | 46 lines | 35 code | 9 blank | 2 comment | 1 complexity | 68d4a5320cc6874bfaed8f342240212f MD5 | raw file
 1// +build acceptance
 2
 3package v2
 4
 5import (
 6	"testing"
 7
 8	"github.com/rackspace/gophercloud/acceptance/tools"
 9	osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
10	"github.com/rackspace/gophercloud/rackspace/compute/v2/bootfromvolume"
11	"github.com/rackspace/gophercloud/rackspace/compute/v2/servers"
12	th "github.com/rackspace/gophercloud/testhelper"
13)
14
15func 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
29	bd := []osBFV.BlockDevice{
30		osBFV.BlockDevice{
31			UUID:       options.imageID,
32			SourceType: osBFV.Image,
33			VolumeSize: 10,
34		},
35	}
36
37	server, err := bootfromvolume.Create(client, servers.CreateOpts{
38		Name:        name,
39		FlavorRef:   "performance1-1",
40		BlockDevice: bd,
41	}).Extract()
42	th.AssertNoErr(t, err)
43	t.Logf("Created server: %+v\n", server)
44	//defer deleteServer(t, client, server)
45	t.Logf("Deleting server [%s]...", name)
46}