From aabf8f69654080111e741decd845352679d8c6e8 Mon Sep 17 00:00:00 2001 From: Robert Breker Date: Tue, 4 Apr 2017 23:28:25 +0100 Subject: [PATCH] Print user friendly warning when target sr unknown Signed-off-by: Robert Breker --- xenserver/xenserver.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xenserver/xenserver.go b/xenserver/xenserver.go index 92a5229..adce0f7 100644 --- a/xenserver/xenserver.go +++ b/xenserver/xenserver.go @@ -5,6 +5,7 @@ import ( "bytes" "crypto/rand" "crypto/tls" + "errors" "fmt" "io" "io/ioutil" @@ -325,6 +326,13 @@ func (d *Driver) Create() error { var sr *xsclient.SR if d.SR == "" { sr, err = c.GetDefaultSR() + if sr.Ref == "OpaqueRef:NULL" { + err := errors.New("No default SR found. Please configure a " + + "default or specify the SR explicitly using " + + "--xenserver-sr-label.") + log.Errorf("%v", err) + return err + } } else { sr, err = c.GetUniqueSRByNameLabel(d.SR) }