seba-260 - fixed some bugs

Change-Id: I214e2c11046a868156d6308d65160d99c9fd3ab2
diff --git a/api/handler.go b/api/handler.go
index f2e832e..3b1754f 100644
--- a/api/handler.go
+++ b/api/handler.go
@@ -57,7 +57,6 @@
 	myChan := getSyncChannel()
 	<-myChan
 	defer done(myChan, true)
-	fmt.Println("HELLO WTF")
 	ping := in.GetPing()
 	pong := EchoReplyMessage{Pong: ping}
 	return &pong, nil
@@ -190,6 +189,6 @@
 GetInventory - returns a json dump of a particular seba-pod
 */
 func (s *Server) GetInventory(ctx context.Context, in *InventoryMessage) (*InventoryReturn, error) {
-	json := inventory.GatherInventory(in.GetClli())
-	return &InventoryReturn{JsonDump: json}, nil
+	json, err := inventory.GatherInventory(in.GetClli())
+	return &InventoryReturn{JsonDump: json}, err
 }
diff --git a/client/main.go b/client/main.go
index a91b22a..79b29c5 100644
--- a/client/main.go
+++ b/client/main.go
@@ -363,6 +363,7 @@
       params:
 	 -message string to be echoed back from the server
 	 e.g. ./client -server=localhost:7777 -e -message MESSAGE_TO_BE_ECHOED
+
    -c create chassis
       params:
          -clli CLLI_NAME
@@ -373,11 +374,13 @@
 	 -rack [optional default 1]
 	 -shelf [optional default 1]
 	 e.g. ./client -server=localhost:7777 -c -clli MY_CLLI -xos_user foundry -xos_password password -xos_address 192.168.0.1 -xos_port 30007 -rack 1 -shelf 1
+
    -u update xos user/password
          -clli CLLI_NAME
 	 -xos_user XOS_USER
 	 -xos_password XOS_PASSWORD
 	 e.g. ./client -server=localhost:7777 -u -clli MY_CLLI -xos_user NEW_USER -xos_password NEW_PASSWORD
+
    -s add physical olt chassis to chassis
       params:
          -clli CLLI_NAME - identifies abstract chassis to assign olt chassis to
@@ -387,6 +390,7 @@
 	 -driver [openolt,asfvolt16,adtran,tibits] - used to tell XOS which driver should be used to manange chassis
 	 -type [edgecore,adtran,tibit] - used to tell AbstractOLT how many ports are available on olt chassis
 	 e.g. ./client -server abstractOltHost:7777 -s -clli MY_CLLI -olt_address 192.168.1.100 -olt_port=9191 -name=slot1 -driver=openolt -type=adtran
+
    -o provision ont - adds ont to whitelist in XOS  on a specific port on a specific olt chassis based on abstract -> phyisical mapping
       params:
 	 -clli CLLI_NAME
@@ -395,6 +399,7 @@
 	 -ont ONT_NUMBER [1-64]
 	 -serial ONT_SERIAL_NUM
 	 e.g. ./client -server=localhost:7777 -o -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf
+
    -f provision ont full - same as -o above but allows explicit set of s/c vlans , NasPortID and CircuitID
       params:
 	 -clli CLLI_NAME
@@ -407,6 +412,7 @@
 	 -nas_port NAS_PORT_ID
 	 -circuit_id CIRCUIT_ID
 	 e.g. ./client -server=localhost:7777 -f -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf -stag=33 -ctag=104 -nas_port="pon 1/1/1/3:1.1" -circuit_id="CLLI 1/1/1/13:1.1"
+
    -d delete ont - removes ont from service
       params:
 	 -clli CLLI_NAME
@@ -415,10 +421,21 @@
 	 -ont ONT_NUMBER [1-64]
 	 -serial ONT_SERIAL_NUM
 	 e.g. ./client -server=localhost:7777 -d -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf
+
     -output (TEMPORARY) causes AbstractOLT to serialize all chassis to JSON file in $WorkingDirectory/backups
          e.g. ./client -server=localhost:7777 -output
+
     -reflow causes tosca to be repushed to xos
 	e.g. ./client -server=localhost:7777 -reflow
+
+    -inventory - returns a json document that describes currently provisioned equipment for a specific clli
+      params:
+	 -clli CLLI_NAME
+	 e.g. ./client -inventory -clli=ATLEDGEVOLT1
+
+    -full_inventory - returns a json document that describes all currently provisioned pods
+         e.g. ./client -full_inventory
+        
 	 `
 
 	fmt.Println(output)
diff --git a/internal/pkg/impl/ouput.go b/internal/pkg/impl/ouput.go
index aa2ea7e..739076b 100644
--- a/internal/pkg/impl/ouput.go
+++ b/internal/pkg/impl/ouput.go
@@ -24,7 +24,7 @@
 	"gerrit.opencord.org/abstract-olt/models"
 	"github.com/mongodb/mongo-go-driver/bson"
 	"github.com/mongodb/mongo-go-driver/mongo"
-	"github.com/mongodb/mongo-go-driver/mongo/updateopt"
+	"github.com/mongodb/mongo-go-driver/options"
 	context "golang.org/x/net/context"
 )
 
@@ -53,7 +53,8 @@
 
 				updateDoc := bson.NewDocument(bson.EC.SubDocument("$set", doc))
 				//update or insert if not existent
-				res, err := collection.UpdateOne(context.Background(), filter, updateDoc, updateopt.Upsert(true))
+				upsert := true
+				res, err := collection.UpdateOne(context.Background(), filter, updateDoc, &options.UpdateOptions{Upsert: &upsert})
 				if err != nil {
 					log.Printf("collection.UpdateOne failed with %v\n", err)
 				} else {
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 {