seba-260 - fixed some bugs
Change-Id: I214e2c11046a868156d6308d65160d99c9fd3ab2
diff --git a/models/inventory/gather.go b/models/inventory/gather.go
index 9f2bd21..75e762f 100644
--- a/models/inventory/gather.go
+++ b/models/inventory/gather.go
@@ -17,6 +17,8 @@
import (
"encoding/json"
+ "errors"
+ "fmt"
"net"
"gerrit.opencord.org/abstract-olt/models"
@@ -64,12 +66,19 @@
return string(bytes)
}
-func GatherInventory(clli string) string {
+func GatherInventory(clli string) (string, error) {
+ if clli == "" {
+ return "", errors.New("You must provide a CLLI")
+ }
chassisMap := models.GetChassisMap()
chassisHolder := (*chassisMap)[clli]
+ if chassisHolder == nil {
+ errorMsg := fmt.Sprintf("No Chassis Holder found for CLLI %s", clli)
+ return "", errors.New(errorMsg)
+ }
chassis := parseClli(clli, chassisHolder)
bytes, _ := json.Marshal(chassis)
- return string(bytes)
+ return string(bytes), nil
}
func parseClli(clli string, chassisHolder *models.ChassisHolder) Chassis {