From 082ab6e5f7707a18f965d71423075fbf9aacd4e3 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Thu, 26 Nov 2020 19:17:09 -0800 Subject: [PATCH] Updates to Vnfs for nodeDB updates --- internal/pkg/vnfs/vnfs.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/pkg/vnfs/vnfs.go b/internal/pkg/vnfs/vnfs.go index 4c428a4f..bdf8c248 100644 --- a/internal/pkg/vnfs/vnfs.go +++ b/internal/pkg/vnfs/vnfs.go @@ -23,12 +23,18 @@ type VnfsObject struct { func Load (name string) (VnfsObject, error) { config := config.New() var ret VnfsObject + + if name == "" { + wwlog.Printf(wwlog.DEBUG, "Called vnfs.Load() without a name, returning error\n") + return ret, errors.New("Called vnfs.Load() without a VNFS name") + } + pathFriendlyName := CleanName(name) configFile := path.Join(config.VnfsImageDir(pathFriendlyName), "config.yaml") if util.IsFile(configFile) == false { - return ret, errors.New("No Configuration for VNFS name: " + configFile) + return ret, errors.New("VNFS has not been imported: " + name) } data, err := ioutil.ReadFile(configFile) @@ -64,6 +70,11 @@ func New(source string) (VnfsObject, error) { var ret VnfsObject config := config.New() + if source == "" { + wwlog.Printf(wwlog.DEBUG, "Called vnfs.Load() without a name, returning error\n") + return ret, errors.New("Called vnfs.Load() without a VNFS name") + } + pathFriendlyName := CleanName(source) if strings.HasPrefix(source, "/") == true {