Allow ImageRef to be empty when block device is present (#97)
This commit removes the requirement for ImageRef to be set when creating
a server. This is to enable booting from a volume to work properly.
A unit test was added to verify this is possible.
Acceptance tests were also modified to handle this.
diff --git a/acceptance/openstack/compute/v2/servers_test.go b/acceptance/openstack/compute/v2/servers_test.go
index f5b60c5..fa6603d 100644
--- a/acceptance/openstack/compute/v2/servers_test.go
+++ b/acceptance/openstack/compute/v2/servers_test.go
@@ -3,8 +3,10 @@
package v2
import (
+ "strings"
"testing"
+ "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
@@ -86,6 +88,27 @@
}
}
+func TestServersWithoutImageRef(t *testing.T) {
+ client, err := clients.NewComputeV2Client()
+ if err != nil {
+ t.Fatalf("Unable to create a compute client: %v", err)
+ }
+
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ server, err := CreateServerWithoutImageRef(t, client, choices)
+ if err != nil {
+ if err400, ok := err.(*gophercloud.ErrUnexpectedResponseCode); ok {
+ if !strings.Contains("Missing imageRef attribute", string(err400.Body)) {
+ defer DeleteServer(t, client, server)
+ }
+ }
+ }
+}
+
func TestServersUpdate(t *testing.T) {
client, err := clients.NewComputeV2Client()
if err != nil {