Merge "SEBA-261 refactor to support serialize/deserialize"
diff --git a/Makefile b/Makefile
index b470f16..aa0f08e 100644
--- a/Makefile
+++ b/Makefile
@@ -60,6 +60,9 @@
   --swagger_out=logtostderr=true:api \
   api/abstract_olt_api.proto
 
+docker: ## build docker image
+	@docker build -t sebaproject/abstract-olt:${DOCKERTAG} .
+
 api: api/abstract_olt_api.pb.go api/abstract_olt_api.pb.gw.go swagger
 
 dep: ## Get the dependencies
diff --git a/api/abstract_olt_api.proto b/api/abstract_olt_api.proto
index fb4aee7..6604703 100644
--- a/api/abstract_olt_api.proto
+++ b/api/abstract_olt_api.proto
@@ -81,6 +81,12 @@
 message DeleteOntReturn{
    bool Success=1;
 }
+message OutputMessage{
+   string Something=1;
+}
+message OutputReturn{
+   bool Success=1;
+}
 service AbstractOLT{
    rpc Echo(EchoMessage) returns (EchoReplyMessage){
       option(google.api.http)={
@@ -112,5 +118,11 @@
 	body:"*"
       };
    }
+   rpc Output(OutputMessage)returns(OutputReturn){
+      option(google.api.http)={
+        post:"/v1/Output"
+	body:"*"
+      };
+   }
 }
 
diff --git a/api/handler.go b/api/handler.go
index 54115a6..2e6b9cc 100644
--- a/api/handler.go
+++ b/api/handler.go
@@ -21,6 +21,7 @@
 	"fmt"
 	"log"
 	"net"
+	"os"
 	"strings"
 
 	"gerrit.opencord.org/abstract-olt/internal/pkg/settings"
@@ -36,6 +37,9 @@
 type Server struct {
 }
 
+/*
+Echo - Tester function which just returns same string sent to it
+*/
 func (s *Server) Echo(ctx context.Context, in *EchoMessage) (*EchoReplyMessage, error) {
 	ping := in.GetPing()
 	pong := EchoReplyMessage{Pong: ping}
@@ -46,23 +50,24 @@
 CreateChassis - allocates a new Chassis struct and stores it in chassisMap
 */
 func (s *Server) CreateChassis(ctx context.Context, in *AddChassisMessage) (*AddChassisReturn, error) {
-	phyChassisMap := models.GetPhyChassisMap()
-	absChassisMap := models.GetAbstractChassisMap()
+	chassisMap := models.GetChassisMap()
 	clli := in.GetCLLI()
-	chassis := (*phyChassisMap)[clli]
-	if chassis != nil {
-		return &AddChassisReturn{DeviceID: chassis.CLLI}, nil
+	chassisHolder := (*chassisMap)[clli]
+	if chassisHolder != nil {
+		return &AddChassisReturn{DeviceID: chassisHolder.AbstractChassis.CLLI}, nil
 	}
+
 	abstractChassis := abstract.GenerateChassis(clli, int(in.GetRack()), int(in.GetShelf()))
-	phyChassis := &physical.Chassis{CLLI: clli, VCoreAddress: net.TCPAddr{IP: net.ParseIP(in.GetVCoreIP()), Port: int(in.GetVCorePort())}, Rack: int(in.GetRack()), Shelf: int(in.GetShelf())}
+	phyChassis := physical.Chassis{CLLI: clli, VCoreAddress: net.TCPAddr{IP: net.ParseIP(in.GetVCoreIP()),
+		Port: int(in.GetVCorePort())}, Rack: int(in.GetRack()), Shelf: int(in.GetShelf())}
+
+	chassisHolder = &models.ChassisHolder{AbstractChassis: abstractChassis, PhysicalChassis: phyChassis}
 	if settings.GetDebug() {
 		output := fmt.Sprintf("%v", abstractChassis)
 		formatted := strings.Replace(output, "{", "\n{", -1)
 		log.Printf("new chassis %s\n", formatted)
 	}
-	(*phyChassisMap)[clli] = phyChassis
-	fmt.Printf("phy %v, abs %v\n", phyChassisMap, absChassisMap)
-	(*absChassisMap)[clli] = abstractChassis
+	(*chassisMap)[clli] = chassisHolder
 	return &AddChassisReturn{DeviceID: clli}, nil
 }
 
@@ -71,64 +76,47 @@
 */
 func (s *Server) CreateOLTChassis(ctx context.Context, in *AddOLTChassisMessage) (*AddOLTChassisReturn, error) {
 	fmt.Printf(" CreateOLTChassis %v \n", *in)
-	phyChassisMap := models.GetPhyChassisMap()
+	chassisMap := models.GetChassisMap()
 	clli := in.GetCLLI()
-	chassis := (*phyChassisMap)[clli]
-	if chassis == nil {
+	chassisHolder := (*chassisMap)[clli]
+	if chassisHolder == nil {
 		errString := fmt.Sprintf("There is no chassis with CLLI of %s", clli)
 		return &AddOLTChassisReturn{DeviceID: "", ChassisDeviceID: ""}, errors.New(errString)
 	}
 	oltType := in.GetType()
 	address := net.TCPAddr{IP: net.ParseIP(in.GetSlotIP()), Port: int(in.GetSlotPort())}
-	sOlt := physical.SimpleOLT{CLLI: clli, Hostname: in.GetHostname(), Address: address, Parent: chassis}
-
-	var olt physical.OLT
+	physicalChassis := &chassisHolder.PhysicalChassis
+	sOlt := physical.SimpleOLT{CLLI: clli, Hostname: in.GetHostname(), Address: address, Parent: physicalChassis}
 	switch oltType {
 	case AddOLTChassisMessage_edgecore:
-		olt = physical.CreateEdgecore(&sOlt)
+		sOlt.CreateEdgecore()
 	case AddOLTChassisMessage_adtran:
 	case AddOLTChassisMessage_tibit:
 	}
-	err := AddCard(chassis, olt)
-	if err != nil {
-		//TODO do something
+	physicalChassis.AddOLTChassis(sOlt)
+	ports := sOlt.GetPorts()
+	for i := 0; i < len(ports); i++ {
+		absPort, _ := chassisHolder.AbstractChassis.NextPort()
+
+		absPort.PhysPort = &ports[i]
+		//AssignTraits(&ports[i], absPort)
 	}
 	return &AddOLTChassisReturn{DeviceID: in.GetHostname(), ChassisDeviceID: clli}, nil
 
 }
 
 /*
-AddCard Adds an OLT card to an existing physical chassis, allocating ports
-in the physical card to those in the abstract model
-*/
-func AddCard(physChassis *physical.Chassis, olt physical.OLT) error {
-	physChassis.AddOLTChassis(olt)
-
-	ports := olt.GetPorts()
-	absChassis := (*models.GetAbstractChassisMap())[physChassis.CLLI]
-
-	for i := 0; i < len(ports); i++ {
-		absPort, _ := absChassis.NextPort()
-
-		absPort.PhysPort = &ports[i]
-		//AssignTraits(&ports[i], absPort)
-	}
-	//should probably worry about error at some point
-	return nil
-}
-
-/*
 ProvisionOnt provisions an ONT on a specific Chassis/LineCard/Port
 */
 func (s *Server) ProvisionOnt(ctx context.Context, in *AddOntMessage) (*AddOntReturn, error) {
-	absChassisMap := models.GetAbstractChassisMap()
+	chassisMap := models.GetChassisMap()
 	clli := in.GetCLLI()
-	chassis := (*absChassisMap)[clli]
-	if chassis == nil {
+	chassisHolder := (*chassisMap)[clli]
+	if chassisHolder == nil {
 		errString := fmt.Sprintf("There is no chassis with CLLI of %s", clli)
 		return &AddOntReturn{Success: false}, errors.New(errString)
 	}
-	err := chassis.ActivateONT(int(in.GetSlotNumber()), int(in.GetPortNumber()), int(in.GetOntNumber()), in.GetSerialNumber())
+	err := chassisHolder.AbstractChassis.ActivateONT(int(in.GetSlotNumber()), int(in.GetPortNumber()), int(in.GetOntNumber()), in.GetSerialNumber())
 
 	if err != nil {
 		return nil, err
@@ -140,12 +128,27 @@
 DeleteOnt - deletes a previously provision ont
 */
 func (s *Server) DeleteOnt(ctx context.Context, in *DeleteOntMessage) (*DeleteOntReturn, error) {
-	absChassisMap := models.GetAbstractChassisMap()
+	chassisMap := models.GetChassisMap()
 	clli := in.GetCLLI()
-	chassis := (*absChassisMap)[clli]
-	err := chassis.DeleteONT(int(in.GetSlotNumber()), int(in.GetPortNumber()), int(in.GetOntNumber()), in.GetSerialNumber())
+	chassisHolder := (*chassisMap)[clli]
+	err := chassisHolder.AbstractChassis.DeleteONT(int(in.GetSlotNumber()), int(in.GetPortNumber()), int(in.GetOntNumber()), in.GetSerialNumber())
 	if err != nil {
 		return nil, err
 	}
 	return &DeleteOntReturn{Success: true}, nil
 }
+
+func (s *Server) Output(ctx context.Context, in *OutputMessage) (*OutputReturn, error) {
+	chassisMap := models.GetChassisMap()
+	for clli, chassisHolder := range *chassisMap {
+
+		json, _ := (chassisHolder).Serialize()
+		backupFile := fmt.Sprintf("backup/%s", clli)
+		f, _ := os.Create(backupFile)
+		defer f.Close()
+		_, _ = f.WriteString(string(json))
+		f.Sync()
+	}
+	return &OutputReturn{Success: true}, nil
+
+}
diff --git a/client/main.go b/client/main.go
index af87ec7..8d8ea4c 100644
--- a/client/main.go
+++ b/client/main.go
@@ -30,32 +30,49 @@
 )
 
 func main() {
+	/* COMMAND FLAGS */
+	output := flag.Bool("output", false, "dump output")
 	echo := flag.Bool("e", false, "echo")
 	message := flag.String("message", "ping", "message to be echoed back")
 	create := flag.Bool("c", false, "create?")
 	addOlt := flag.Bool("s", false, "addOlt?")
 	provOnt := flag.Bool("o", false, "provisionOnt?")
-	clli := flag.String("clli", "", "clli of abstract chassis")
+	deleteOnt := flag.Bool("d", false, "deleteOnt")
+	/* END COMMAND FLAGS */
+
+	/* CREATE CHASSIS FLAGS */
 	xosAddress := flag.String("xos_address", "", "xos address")
 	xosPort := flag.Uint("xos_port", 0, "xos port")
 	rack := flag.Uint("rack", 1, "rack number for chassis")
 	shelf := flag.Uint("shelf", 1, "shelf number for chassis")
+	/* END CREATE CHASSIS FLAGS */
+
+	/* ADD OLT FLAGS */
 	oltAddress := flag.String("olt_address", "", "ip address for olt chassis")
 	oltPort := flag.Uint("olt_port", 0, "listen port for olt chassis")
 	name := flag.String("name", "", "friendly name for olt chassis")
 	driver := flag.String("driver", "", "driver to use with olt chassis")
 	oltType := flag.String("type", "", "olt chassis type")
+	/* END ADD OLT FLAGS */
+
+	/* PROVISION / DELETE ONT FLAGS */
 	slot := flag.Uint("slot", 1, "slot number 1-16 to provision ont to")
 	port := flag.Uint("port", 1, "port number 1-16 to provision ont to")
 	ont := flag.Uint("ont", 1, "ont number 1-64")
 	serial := flag.String("serial", "", "serial number of ont")
+	/* END PROVISION / DELETE ONT FLAGS */
+
+	/*GENERIC FLAGS */
+	clli := flag.String("clli", "", "clli of abstract chassis")
 	useSsl := flag.Bool("ssl", false, "use ssl")
 	useAuth := flag.Bool("auth", false, "use auth")
 	crtFile := flag.String("cert", "cert/server.crt", "Public cert for server to establish tls session")
 	serverAddressPort := flag.String("server", "localhost:7777", "address and port of AbstractOLT server")
 	fqdn := flag.String("fqdn", "", "FQDN of the service to match what is in server.crt")
+	/*GENERIC FLAGS */
 
 	flag.Parse()
+
 	if *useSsl {
 		if *fqdn == "" {
 			fqdn = &(strings.Split(*serverAddressPort, ":")[0])
@@ -63,16 +80,24 @@
 		}
 	}
 
-	if (*echo && *addOlt) || (*echo && *create) || (*echo && *provOnt) || (*create && *addOlt) || (*create && *provOnt) || (*addOlt && *provOnt) {
-		fmt.Println("You can only call one method at a time")
+	cmdFlags := []*bool{echo, addOlt, create, provOnt, deleteOnt, output}
+	cmdCount := 0
+	for _, flag := range cmdFlags {
+		if *flag {
+			cmdCount++
+		}
+	}
+	if cmdCount > 1 {
+		fmt.Println("CMD You can only call one method at a time")
 		usage()
 		return
 	}
-	if !(*create || *provOnt || *addOlt || *echo) {
-		fmt.Println("You didn't specify an operation to perform")
+	if cmdCount < 1 {
+		fmt.Println("CMD You didn't specify an operation to perform")
 		usage()
 		return
 	}
+
 	var conn *grpc.ClientConn
 	var err error
 
@@ -113,6 +138,10 @@
 		provisionONT(c, clli, slot, port, ont, serial)
 	} else if *echo {
 		ping(c, *message)
+	} else if *output {
+		Output(c)
+	} else if *deleteOnt {
+		deleteONT(c, clli, slot, port, ont, serial)
 	}
 
 }
@@ -135,6 +164,17 @@
 func (a *Authentication) RequireTransportSecurity() bool {
 	return true
 }
+func Output(c api.AbstractOLTClient) error {
+	response, err := c.Output(context.Background(), &api.OutputMessage{Something: "wtf"})
+	if err != nil {
+		fmt.Printf("Error when calling Echo: %s", err)
+		return err
+	}
+	log.Printf("Response from server: %v", response.GetSuccess())
+
+	return nil
+}
+
 func ping(c api.AbstractOLTClient, message string) error {
 	response, err := c.Echo(context.Background(), &api.EchoMessage{Ping: message})
 	if err != nil {
@@ -205,6 +245,22 @@
 
 	return nil
 }
+func deleteONT(c api.AbstractOLTClient, clli *string, slot *uint, port *uint, ont *uint, serial *string) error {
+	fmt.Println("clli", *clli)
+	fmt.Println("slot", *slot)
+	fmt.Println("port", *port)
+	fmt.Println("ont", *ont)
+	fmt.Println("serial", *serial)
+	res, err := c.DeleteOnt(context.Background(), &api.DeleteOntMessage{CLLI: *clli, SlotNumber: int32(*slot), PortNumber: int32(*port), OntNumber: int32(*ont), SerialNumber: *serial})
+	if err != nil {
+		debug.PrintStack()
+		fmt.Printf("Error when calling ProvsionOnt %s", err)
+		return err
+	}
+	log.Printf("Response from server: %t", res.GetSuccess())
+	return nil
+}
+
 func usage() {
 	var output = `
 	Usage ./client -server=[serverAddress:port] -[methodFlag] params
@@ -240,7 +296,18 @@
 	 -port OLT_PORT_NUMBER [1-16]
 	 -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 `
+	 e.g. ./client -server=localhost:7777 -o -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf
+   -d delete ont - removes ont from service
+      params:
+	 -clli CLLI_NAME
+	 -slot SLOT_NUMBER [1-16]
+	 -port OLT_PORT_NUMBER [1-16]
+	 -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
+	 `
 
 	fmt.Println(output)
 }
diff --git a/cmd/AbstractOLT/AbstractOLT.go b/cmd/AbstractOLT/AbstractOLT.go
index 2148cc9..eee3b0f 100644
--- a/cmd/AbstractOLT/AbstractOLT.go
+++ b/cmd/AbstractOLT/AbstractOLT.go
@@ -19,6 +19,7 @@
 import (
 	"flag"
 	"fmt"
+	"io/ioutil"
 	"log"
 	"net"
 	"net/http"
@@ -27,6 +28,7 @@
 
 	"gerrit.opencord.org/abstract-olt/api"
 	"gerrit.opencord.org/abstract-olt/internal/pkg/settings"
+	"gerrit.opencord.org/abstract-olt/models"
 	"github.com/grpc-ecosystem/grpc-gateway/runtime"
 	"golang.org/x/net/context"
 	"google.golang.org/grpc"
@@ -96,28 +98,27 @@
 	}
 	// create a listener on TCP port
 	lis, err := net.Listen("tcp", address)
-	if err != nil {
-		log.Printf("startGRPCServer failed to start with %v\n", err)
-		return fmt.Errorf("failed to listen: %v", err)
-	}
 
 	// create a server instance
 	s := api.Server{}
 
 	// Create the TLS credentials
-	creds, err := credentials.NewServerTLSFromFile(certFile, keyFile)
-	if err != nil {
-		return fmt.Errorf("could not load TLS keys: %s", err)
-	}
 
 	// Create an array of gRPC options with the credentials
 	var opts []grpc.ServerOption
+	creds, err := credentials.NewClientTLSFromFile(certFile, "")
 	if *useSsl && *useAuthentication {
+		if err != nil {
+			return fmt.Errorf("could not load TLS keys: %s", err)
+		}
 		opts = []grpc.ServerOption{grpc.Creds(creds),
 			grpc.UnaryInterceptor(unaryInterceptor)}
 	} else if *useAuthentication {
 		opts = []grpc.ServerOption{grpc.UnaryInterceptor(unaryInterceptor)}
 	} else if *useSsl {
+		if err != nil {
+			return fmt.Errorf("could not load TLS keys: %s", err)
+		}
 		opts = []grpc.ServerOption{grpc.Creds(creds)}
 	} else {
 		opts = []grpc.ServerOption{}
@@ -146,19 +147,23 @@
 	defer cancel()
 	var mux *runtime.ServeMux
 
+	var opts []grpc.DialOption
 	if *useAuthentication {
 		mux = runtime.NewServeMux(runtime.WithIncomingHeaderMatcher(credMatcher))
 	} else {
 		mux = runtime.NewServeMux()
 	}
-	creds, err := credentials.NewClientTLSFromFile(certFile, "")
-	if err != nil {
-		return fmt.Errorf("could not load TLS certificate: %s", err)
+	if *useSsl {
+		creds, err := credentials.NewClientTLSFromFile(certFile, "")
+		opts = []grpc.DialOption{grpc.WithTransportCredentials(creds)}
+		if err != nil {
+			return fmt.Errorf("could not load TLS certificate: %s", err)
+		}
+	} else {
+		opts = []grpc.DialOption{grpc.WithInsecure()}
 	}
-
 	// Setup the client gRPC options
-	opts := []grpc.DialOption{grpc.WithTransportCredentials(creds)}
-	err = api.RegisterAbstractOLTHandlerFromEndpoint(ctx, mux, grpcAddress, opts)
+	err := api.RegisterAbstractOLTHandlerFromEndpoint(ctx, mux, grpcAddress, opts)
 	if err != nil {
 		return fmt.Errorf("could not register service Ping: %s", err)
 	}
@@ -226,7 +231,7 @@
 	go func() {
 		err := startGRPCServer(grpcAddress, certFile, keyFile)
 		if err != nil {
-			log.Fatalf("failed to start gRPC server: %s", err)
+			log.Printf("failed to start gRPC server: %s", err)
 		}
 	}()
 
@@ -234,11 +239,28 @@
 	go func() {
 		err := startRESTServer(restAddress, grpcAddress, certFile)
 		if err != nil {
-			log.Fatalf("failed to start gRPC server: %s", err)
+			log.Printf("failed to start REST server: %s", err)
 		}
 	}()
 
 	// infinite loop
+	files, err := ioutil.ReadDir("backup")
+	if err != nil {
+		log.Fatal(err)
+	}
+	for _, file := range files {
+		fmt.Println(file.Name())
+		chassisHolder := models.ChassisHolder{}
+		fileName := fmt.Sprintf("backup/%s", file.Name())
+		json, _ := ioutil.ReadFile(fileName)
+		err := chassisHolder.Deserialize([]byte(json))
+		if err != nil {
+			fmt.Printf("Deserialize threw an error %v\n", err)
+		}
+		chassisMap := models.GetChassisMap()
+		(*chassisMap)[file.Name()] = &chassisHolder
+	}
+
 	log.Printf("Entering infinite loop")
 	select {}
 	//TODO publish periodic stats etc
diff --git a/internal/pkg/chassisSerialize/serialize.go b/internal/pkg/chassisSerialize/serialize.go
deleted file mode 100644
index 6e947a5..0000000
--- a/internal/pkg/chassisSerialize/serialize.go
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-   Copyright 2017 the original author or authors.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-*/
-package chassisSerialize
-
-import (
-	"encoding/json"
-
-	"gerrit.opencord.org/abstract-olt/models/abstract"
-)
-
-func Serialize(chassis *abstract.Chassis) ([]byte, error) {
-	return json.Marshal(chassis)
-}
-
-func Deserialize(jsonData []byte) (*abstract.Chassis, error) {
-	var chassis abstract.Chassis
-	err := json.Unmarshal(jsonData, &chassis)
-
-	for i := 0; i < len(chassis.Slots); i++ {
-		var slot *abstract.Slot
-		slot = &chassis.Slots[i]
-		slot.Parent = &chassis
-		for j := 0; j < len(slot.Ports); j++ {
-			var port *abstract.Port
-			port = &slot.Ports[j]
-			port.Parent = slot
-			for k := 0; k < len(port.Onts); k++ {
-				port.Onts[k].Parent = port
-			}
-		}
-	}
-
-	return &chassis, err
-}
diff --git a/internal/pkg/settings/Settings_test.go b/internal/pkg/settings/Settings_test.go
index ef8419f..84dca73 100644
--- a/internal/pkg/settings/Settings_test.go
+++ b/internal/pkg/settings/Settings_test.go
@@ -28,3 +28,9 @@
 		t.Fatalf("Failed to set debug level")
 	}
 }
+func TestSettings_SetDummy(t *testing.T) {
+	settings.SetDummy(false)
+	if settings.GetDummy() {
+		t.Fatalf("Failed to set dummy level")
+	}
+}
diff --git a/models/abstract/ChassisUtils.go b/models/abstract/ChassisUtils.go
index 5e38890..0cacf79 100644
--- a/models/abstract/ChassisUtils.go
+++ b/models/abstract/ChassisUtils.go
@@ -19,7 +19,7 @@
 /*
 GenerateChassis - constructs a new AbstractOLT Chassis
 */
-func GenerateChassis(CLLI string, rack int, shelf int) *Chassis {
+func GenerateChassis(CLLI string, rack int, shelf int) Chassis {
 	chassis := Chassis{CLLI: CLLI, Rack: rack, Shelf: shelf}
 
 	var slots [16]Slot
@@ -28,7 +28,7 @@
 	}
 
 	chassis.Slots = slots
-	return &chassis
+	return chassis
 }
 
 func generateSlot(n int, c *Chassis) Slot {
diff --git a/models/abstract/chassis.go b/models/abstract/chassis.go
index 06e0002..9b62c8c 100644
--- a/models/abstract/chassis.go
+++ b/models/abstract/chassis.go
@@ -18,7 +18,6 @@
 
 import (
 	"errors"
-	"fmt"
 )
 
 const MAX_SLOTS int = 16
@@ -64,7 +63,6 @@
 	return nextPort, nil
 }
 func (chassis *Chassis) ActivateONT(slotNumber int, portNumber int, ontNumber int, serialNumber string) error {
-	fmt.Printf("chassis.ActivateONT(slot:%d,portNumber:%d,ontNumber:%d,serialNumber:%s\n", slotNumber, portNumber, ontNumber, serialNumber)
 	err := chassis.Slots[slotNumber-1].Ports[portNumber-1].provisionOnt(ontNumber, serialNumber)
 	return err
 }
diff --git a/models/abstract/port.go b/models/abstract/port.go
index e626e7c..1af3d6e 100644
--- a/models/abstract/port.go
+++ b/models/abstract/port.go
@@ -29,8 +29,8 @@
 	Number int
 	// DeviceID string
 	Onts     [64]Ont
-	PhysPort *physical.PONPort
-	Parent   *Slot `json:"-"`
+	PhysPort *physical.PONPort `json:"-"`
+	Parent   *Slot             `json:"-"`
 }
 
 /*
@@ -50,7 +50,6 @@
 }
 func (port *Port) provisionOnt(ontNumber int, serialNumber string) error {
 
-	fmt.Printf("My Number:%d abstract.port.provisionOnt(ontNumber:%d,serialNumber:%s\n", port.Number, ontNumber, serialNumber)
 	slot := port.Parent
 	chassis := *slot.Parent
 	baseID := fmt.Sprintf("%d/%d/%d/%d:%d.1.1", chassis.Rack, chassis.Shelf, slot.Number, port.Number, ontNumber)
diff --git a/models/abstract/serialize.go b/models/abstract/serialize.go
new file mode 100644
index 0000000..8781d2d
--- /dev/null
+++ b/models/abstract/serialize.go
@@ -0,0 +1,45 @@
+/*
+ Copyright 2017 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package abstract
+
+import (
+	"encoding/json"
+)
+
+func (chassis *Chassis) Serialize() ([]byte, error) {
+	return json.Marshal(chassis)
+}
+
+func (chassis *Chassis) Deserialize(jsonData []byte) error {
+	err := json.Unmarshal(jsonData, chassis)
+
+	for i := 0; i < len(chassis.Slots); i++ {
+		var slot *Slot
+		slot = &chassis.Slots[i]
+		slot.Parent = chassis
+		for j := 0; j < len(slot.Ports); j++ {
+			var port *Port
+			port = &slot.Ports[j]
+			port.Parent = slot
+			for k := 0; k < len(port.Onts); k++ {
+				port.Onts[k].Parent = port
+			}
+		}
+	}
+
+	return err
+}
diff --git a/models/chassisHolder.go b/models/chassisHolder.go
new file mode 100644
index 0000000..142c5fa
--- /dev/null
+++ b/models/chassisHolder.go
@@ -0,0 +1,26 @@
+/*
+ Copyright 2017 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package models
+
+import (
+	"gerrit.opencord.org/abstract-olt/models/abstract"
+	"gerrit.opencord.org/abstract-olt/models/physical"
+)
+
+type ChassisHolder struct {
+	PhysicalChassis physical.Chassis
+	AbstractChassis abstract.Chassis
+}
diff --git a/models/chassisMap.go b/models/chassisMap.go
index 65e552d..a4c04b0 100644
--- a/models/chassisMap.go
+++ b/models/chassisMap.go
@@ -18,34 +18,18 @@
 
 import (
 	"sync"
-
-	"gerrit.opencord.org/abstract-olt/models/abstract"
-	"gerrit.opencord.org/abstract-olt/models/physical"
 )
 
 var once sync.Once
-var absOnce sync.Once
-var chassisMap map[string]*physical.Chassis
-var aChassisMap map[string]*abstract.Chassis
+var chassisMap map[string]*ChassisHolder
 
 /*
-GetPhyChassisMap return the chassis map singleton
+GetChassisMap return the chassis map singleton
 */
-func GetPhyChassisMap() *map[string]*physical.Chassis {
+func GetChassisMap() *map[string]*ChassisHolder {
 	// the go singleton pattern
 	once.Do(func() {
-		chassisMap = make(map[string]*physical.Chassis)
+		chassisMap = make(map[string]*ChassisHolder)
 	})
 	return &chassisMap
 }
-
-/*
-GetAbstractChassisMap return the chassis map singleton
-*/
-func GetAbstractChassisMap() *map[string]*abstract.Chassis {
-	// the go singleton pattern
-	absOnce.Do(func() {
-		aChassisMap = make(map[string]*abstract.Chassis)
-	})
-	return &aChassisMap
-}
diff --git a/models/chassisMap_test.go b/models/chassisMap_test.go
index 7b30eeb..f1e5d35 100644
--- a/models/chassisMap_test.go
+++ b/models/chassisMap_test.go
@@ -23,16 +23,8 @@
 )
 
 func TestChassisMap_GetPhyChassisMap(t *testing.T) {
-	firstChassisMap := models.GetPhyChassisMap()
-	secondChassisMap := models.GetPhyChassisMap()
-
-	if firstChassisMap != secondChassisMap {
-		t.Fatalf("GetPhyChassisMap should always return pointer to same map")
-	}
-}
-func TestChassisMap_GetAbstractChassisMap(t *testing.T) {
-	firstChassisMap := models.GetAbstractChassisMap()
-	secondChassisMap := models.GetAbstractChassisMap()
+	firstChassisMap := models.GetChassisMap()
+	secondChassisMap := models.GetChassisMap()
 
 	if firstChassisMap != secondChassisMap {
 		t.Fatalf("GetPhyChassisMap should always return pointer to same map")
diff --git a/models/physical/chassis.go b/models/physical/chassis.go
index 5fb9a94..4392a10 100644
--- a/models/physical/chassis.go
+++ b/models/physical/chassis.go
@@ -33,16 +33,22 @@
 type Chassis struct {
 	CLLI         string
 	VCoreAddress net.TCPAddr
-	Dataswitch   DataSwitch
-	Linecards    []OLT
-	Rack         int
-	Shelf        int
+	//	Dataswitch   DataSwitch
+	Linecards []SimpleOLT
+	Rack      int
+	Shelf     int
 }
 type UnprovisionedSlotError struct {
 	CLLI       string
 	SlotNumber int
 }
 
+func (c *Chassis) Output() {
+	for _, olt := range c.Linecards {
+		olt.Output()
+	}
+}
+
 func (e *UnprovisionedSlotError) Error() string {
 	return fmt.Sprintf("SlotNumber %d in Chassis %s is currently unprovsioned", e.SlotNumber, e.CLLI)
 }
@@ -50,10 +56,10 @@
 /*
 AddOLTChassis - adds a reference to a new olt chassis
 */
-func (chassis *Chassis) AddOLTChassis(olt OLT) {
+func (chassis *Chassis) AddOLTChassis(olt SimpleOLT) {
+	olt.SetNumber((len(chassis.Linecards) + 1))
 	chassis.Linecards = append(chassis.Linecards, olt)
 	//TODO - api call to add olt i.e. preprovision_olt
-	fmt.Printf("chassis.AddOLTChassis(%s)\n", olt.GetHostname())
 	//S>103 func NewOltProvision(name string, deviceType string, host string, port int) OltProvsion {
 	ipString := olt.GetAddress().IP.String()
 	webServerPort := olt.GetAddress().Port
@@ -71,15 +77,15 @@
 	req.Header.Add("xos-password", "letmein")
 	resp, err := client.Do(req)
 	if err != nil {
-		fmt.Printf("ERROR :) %v\n", err)
+		//TODO
 		// handle error
 	}
-	fmt.Printf("Response is %v\n", resp)
+	log.Printf("Server response was %v\n", resp)
 
 }
 func (chassis *Chassis) provisionONT(ont Ont) {
 	//TODO - api call to provison s/c vlans and ont serial number etc
-	fmt.Printf("chassis.provisionONT(%s,SVlan:%d,CVlan:%d)\n", ont.SerialNumber, ont.Svlan, ont.Cvlan)
+	log.Printf("chassis.provisionONT(%s,SVlan:%d,CVlan:%d)\n", ont.SerialNumber, ont.Svlan, ont.Cvlan)
 	ponPort := ont.Parent
 	slot := ponPort.Parent
 
@@ -99,31 +105,24 @@
 	req.Header.Add("xos-password", "letmein")
 	resp, err := client.Do(req)
 	if err != nil {
-		fmt.Printf("ERROR :) %v\n", err)
+		log.Printf("ERROR :) %v\n", err)
 		// handle error
 	}
-	fmt.Printf("Response is %v\n", resp)
+	log.Printf("Response is %v\n", resp)
 	rgName := fmt.Sprintf("%s_%d_%d_%d_RG", chassis.CLLI, slot.Number, ponPort.Number, ont.Number)
 	subStruct := tosca.NewSubscriberProvision(rgName, ont.Cvlan, ont.Svlan, ont.SerialNumber, ont.NasPortID, ont.CircuitID, chassis.CLLI)
 	yaml, _ = subStruct.ToYaml()
-	fmt.Printf("yaml:%s\n", yaml)
+	log.Printf("yaml:%s\n", yaml)
 	req, err = http.NewRequest("POST", requestList, strings.NewReader(yaml))
 	req.Header.Add("xos-username", "admin@opencord.org")
 	req.Header.Add("xos-password", "letmein")
 	resp, err = client.Do(req)
 	if err != nil {
-		fmt.Printf("ERROR :) %v\n", err)
+		log.Printf("ERROR :) %v\n", err)
 		// handle error
 	}
 }
 func (chassis *Chassis) deleteONT(ont Ont) {
 	//TODO - api call to provison s/c vlans and ont serial number etc
-	fmt.Printf("chassis.deleteONT(%s,SVlan:%d,CVlan:%d)\n", ont.SerialNumber, ont.Svlan, ont.Cvlan)
-}
-func (chassis *Chassis) ActivateSlot(slotNumber int) error {
-	// AT&T backend systems start at 1 and not 0 :P
-	if chassis.Linecards[slotNumber-1] == nil {
-		return &UnprovisionedSlotError{CLLI: chassis.CLLI, SlotNumber: slotNumber}
-	}
-	return chassis.Linecards[slotNumber-1].activate()
+	log.Printf("chassis.deleteONT(%s,SVlan:%d,CVlan:%d)\n", ont.SerialNumber, ont.Svlan, ont.Cvlan)
 }
diff --git a/models/physical/edgecore.go b/models/physical/edgecore.go
index cded2dc..0cf4479 100644
--- a/models/physical/edgecore.go
+++ b/models/physical/edgecore.go
@@ -26,12 +26,11 @@
 /*
 CreateEdgecore takes simple olt struct and generates Edgecore OLT
 */
-func CreateEdgecore(olt *SimpleOLT) *Edgecore {
+func (olt *SimpleOLT) CreateEdgecore() {
 	var newPorts [16]PONPort
-	edge := Edgecore{SimpleOLT: *olt}
 	for i := 0; i < 16; i++ {
-		newPorts[i].Parent = &edge
+		newPorts[i].Parent = olt
+		newPorts[i].Number = i + 1
 	}
-	edge.Ports = newPorts[:]
-	return &edge
+	olt.Ports = newPorts[:]
 }
diff --git a/models/physical/edgecore_test.go b/models/physical/edgecore_test.go
index a7fbf68..c4a06df 100644
--- a/models/physical/edgecore_test.go
+++ b/models/physical/edgecore_test.go
@@ -34,8 +34,8 @@
 	switchPort := 3
 
 	olt := &physical.SimpleOLT{CLLI: clli, Hostname: hostname, Address: address, Parent: parent, DataSwitchPort: switchPort}
-	edgeCoreOlt := physical.CreateEdgecore(olt)
-	if edgeCoreOlt.GetCLLI() != clli {
+	olt.CreateEdgecore()
+	if olt.GetCLLI() != clli {
 		t.Fatal("Failed to assign CLLI in CreateEdgecore")
 	}
 }
diff --git a/models/physical/olt.go b/models/physical/olt.go
index 121fdac..721e731 100644
--- a/models/physical/olt.go
+++ b/models/physical/olt.go
@@ -29,7 +29,9 @@
 	GetPorts() []PONPort
 	GetParent() *Chassis
 	GetDataSwitchPort() int
+	SetNumber(int)
 	activate() error
+	Output()
 }
 
 /*
@@ -47,35 +49,42 @@
 	DataSwitchPort int
 }
 
-func (s *SimpleOLT) GetCLLI() string {
+func (s SimpleOLT) GetCLLI() string {
 	return s.CLLI
 }
 
-func (s *SimpleOLT) GetHostname() string {
+func (s SimpleOLT) GetHostname() string {
 	return s.Hostname
 }
 
-func (s *SimpleOLT) GetAddress() net.TCPAddr {
+func (s SimpleOLT) GetAddress() net.TCPAddr {
 	return s.Address
 }
 
-func (s *SimpleOLT) GetNumber() int {
+func (s SimpleOLT) GetNumber() int {
 	return s.Number
 }
+func (s SimpleOLT) SetNumber(num int) {
+	s.Number = num
+}
 
-func (s *SimpleOLT) GetPorts() []PONPort {
+func (s SimpleOLT) GetPorts() []PONPort {
 	return s.Ports
 }
 
-func (s *SimpleOLT) GetParent() *Chassis {
+func (s SimpleOLT) GetParent() *Chassis {
 	return s.Parent
 }
 
-func (s *SimpleOLT) GetDataSwitchPort() int {
+func (s SimpleOLT) GetDataSwitchPort() int {
 	return s.DataSwitchPort
 }
-func (s *SimpleOLT) activate() error {
+func (s SimpleOLT) activate() error {
 	s.Active = true
 	//TODO make call to XOS to activate phyiscal OLT
 	return nil
 }
+func (s SimpleOLT) Output() error {
+	//TODO make call to XOS to activate phyiscal OLT
+	return nil
+}
diff --git a/models/physical/ponport.go b/models/physical/ponport.go
index ca321fd..683489e 100644
--- a/models/physical/ponport.go
+++ b/models/physical/ponport.go
@@ -27,7 +27,7 @@
 	Number   int
 	DeviceID string
 	Onts     [64]Ont
-	Parent   *Edgecore `json:"-"`
+	Parent   *SimpleOLT `json:"-"`
 }
 
 /*
@@ -70,7 +70,6 @@
 func (port *PONPort) ActivateOnt(number int, sVlan int, cVlan int, serialNumber string, nasPortID string, circuitID string) error {
 	slot := port.Parent
 	chassis := slot.Parent
-	fmt.Printf("Calling ActivateOnt and port state is %t\n", port.Onts[number-1].Active)
 
 	if port.Onts[number-1].Active {
 		e := AllReadyActiveError{ontNumber: number, slotNum: slot.Number, ponportNum: port.Number, clli: chassis.CLLI}
@@ -90,7 +89,6 @@
 func (port *PONPort) DeleteOnt(number int, sVlan int, cVlan int, serialNumber string) error {
 	slot := port.Parent
 	chassis := slot.Parent
-	fmt.Printf("Calling ActivateOnt and port state is %t\n", port.Onts[number-1].Active)
 	if port.Onts[number-1].Active != true {
 		e := AllReadyDeactivatedError{ontNumber: number, slotNum: slot.Number, ponportNum: port.Number, clli: chassis.CLLI}
 		return &e
diff --git a/models/serialize.go b/models/serialize.go
new file mode 100644
index 0000000..a0c2a01
--- /dev/null
+++ b/models/serialize.go
@@ -0,0 +1,69 @@
+/*
+ Copyright 2017 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package models
+
+import (
+	"encoding/json"
+)
+
+func (chassisHolder ChassisHolder) Serialize() ([]byte, error) {
+	return json.Marshal(chassisHolder)
+
+}
+
+func (chassisHolder *ChassisHolder) Deserialize(jsonData []byte) error {
+	err := json.Unmarshal(jsonData, chassisHolder)
+	if err != nil {
+		return err
+	}
+	physicalChassis := &chassisHolder.PhysicalChassis
+	abstractChassis := &chassisHolder.AbstractChassis
+	//first handle abstract parent pointers
+	for i := 0; i < len(abstractChassis.Slots); i++ {
+		slot := &abstractChassis.Slots[i]
+		slot.Parent = abstractChassis
+		for j := 0; j < len(slot.Ports); j++ {
+			port := &slot.Ports[j]
+			port.Parent = slot
+			for k := 0; k < len(port.Onts); k++ {
+				port.Onts[k].Parent = port
+			}
+		}
+	}
+	//second handle physical parent pointers
+	for i := 0; i < len(physicalChassis.Linecards); i++ {
+		slot := physicalChassis.Linecards[i]
+		slot.Parent = physicalChassis
+		for j := 0; j < len(slot.Ports); j++ {
+			port := &slot.Ports[j]
+			port.Parent = &slot
+			for k := 0; k < len(port.Onts); k++ {
+				port.Onts[k].Parent = port
+			}
+		}
+	}
+	//finally handle abstract.Port -> physical.PonPort pointers
+
+	for i := 0; i < len(physicalChassis.Linecards); i++ {
+		slot := physicalChassis.Linecards[i]
+		for j := 0; j < len(slot.Ports); j++ {
+			absPort, _ := chassisHolder.AbstractChassis.NextPort()
+			absPort.PhysPort = &slot.Ports[j]
+		}
+	}
+	return nil
+}
diff --git a/models/serialize_test.go b/models/serialize_test.go
new file mode 100644
index 0000000..aaca6ec
--- /dev/null
+++ b/models/serialize_test.go
@@ -0,0 +1,69 @@
+/*
+ Copyright 2017 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package models_test
+
+import (
+	"net"
+	"testing"
+
+	"gerrit.opencord.org/abstract-olt/internal/pkg/settings"
+	"gerrit.opencord.org/abstract-olt/models"
+	"gerrit.opencord.org/abstract-olt/models/abstract"
+	"gerrit.opencord.org/abstract-olt/models/physical"
+)
+
+var chassisMap *map[string]*models.ChassisHolder
+var clli string
+var json []byte
+
+func TestChassisSerialize_Serialize(t *testing.T) {
+	//func (chassisHolder ChassisHolder) Serialize() ([]byte, error) {
+	settings.SetDummy(true)
+	clli = "TEST_CLLI"
+	chassisMap = models.GetChassisMap()
+	abstractChassis := abstract.GenerateChassis(clli, 1, 1)
+	phyChassis := physical.Chassis{CLLI: clli, VCoreAddress: net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 1234}, Rack: 1, Shelf: 1}
+	chassisHolder := &models.ChassisHolder{AbstractChassis: abstractChassis, PhysicalChassis: phyChassis}
+	(*chassisMap)[clli] = chassisHolder
+	sOlt := physical.SimpleOLT{CLLI: clli, Hostname: "slot1", Address: net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 1234}, Parent: &phyChassis}
+	phyChassis.AddOLTChassis(sOlt)
+	ports := sOlt.GetPorts()
+	for i := 0; i < len(ports); i++ {
+		absPort, _ := chassisHolder.AbstractChassis.NextPort()
+
+		absPort.PhysPort = &ports[i]
+		//AssignTraits(&ports[i], absPort)
+	}
+	var err error
+	json, err = chassisHolder.Serialize()
+	if err != nil {
+		t.Fatalf("TestChassisSerialize_Serialize failed with %v\n", err)
+	}
+}
+
+func TestChassisSerialize_Deserialize(t *testing.T) {
+	//func (chassisHolder *ChassisHolder) Deserialize(jsonData []byte) error {
+	chassisHolder := models.ChassisHolder{}
+	err := chassisHolder.Deserialize(json)
+	if err != nil {
+		t.Fatalf("Deserialize threw an error %v\n", err)
+	}
+	newJSON, _ := chassisHolder.Serialize()
+	if string(json) != string(newJSON) {
+		t.Fatalf("Failed to de-serialize and serialize accurately")
+	}
+}
diff --git a/models/tosca/addOlt.go b/models/tosca/addOlt.go
index 0005800..30e8d12 100644
--- a/models/tosca/addOlt.go
+++ b/models/tosca/addOlt.go
@@ -46,12 +46,18 @@
            outer_tpid: "0x8100"
            uplink: "65536"
            nas_id:
+           switch_datapath_id: of:0000000000000001
+           switch_port: "1"
         requirements:
           - volt_service:
               node: service#volt
               relationship: tosca.relationships.BelongsToOne
 `
 
+/*
+OltProvision struct that serves as model for yaml to provsion OLT in XOS
+*/
+
 type OltProvsion struct {
 	ToscaDefinitionsVersion string   `yaml:"tosca_definitions_version"`
 	Imports                 []string `yaml:"imports"`
@@ -68,13 +74,15 @@
 			OltDevice struct {
 				DeviceType string `yaml:"type"`
 				Properties struct {
-					Name      string `yaml:"name"`
-					Type      string `yaml:"device_type"`
-					Host      string `yaml:"host"`
-					Port      int    `yaml:"port"`
-					OuterTpid string `yaml:"outer_tpid"`
-					Uplink    string `yaml:"uplink"`
-					NasID     string `yaml:"nas_id"`
+					Name             string `yaml:"name"`
+					Type             string `yaml:"device_type"`
+					Host             string `yaml:"host"`
+					Port             int    `yaml:"port"`
+					OuterTpid        string `yaml:"outer_tpid"`
+					Uplink           string `yaml:"uplink"`
+					NasID            string `yaml:"nas_id"`
+					SwitchDataPathID string `yaml:"switch_datapath_id"`
+					SwitchPort       string `yaml:"switch_port"`
 				} `yaml:"properties"`
 				Requirements []struct {
 					VoltService struct {
diff --git a/models/tosca/addOlt_test.go b/models/tosca/addOlt_test.go
index 1b2f667..8961213 100644
--- a/models/tosca/addOlt_test.go
+++ b/models/tosca/addOlt_test.go
@@ -16,7 +16,6 @@
 package tosca_test
 
 import (
-	"fmt"
 	"strings"
 	"testing"
 
@@ -47,6 +46,8 @@
         outer_tpid: "0x8100"
         uplink: "65536"
         nas_id: my_clli
+        switch_datapath_id: of:0000000000000001
+        switch_port: "1"
       requirements:
       - volt_service:
           node: service#volt
@@ -56,9 +57,7 @@
 var olt tosca.OltProvsion
 
 func TestAddOlt_NewOltProvsion(t *testing.T) {
-	fmt.Println("In TestAddOlt_NewOltProvsion")
 	olt = tosca.NewOltProvision("my_clli", "myName", "openolt", "192.168.1.1", 9191)
-	fmt.Printf("%v\n\n", olt)
 }
 
 func TestAddOlt_ToYaml(t *testing.T) {
@@ -70,10 +69,4 @@
 	if x != 0 {
 		t.Fatal("ToYaml didn't produce the expected yaml")
 	}
-	fmt.Printf("Compare is %d\n", x)
-
-	fmt.Printf(y)
-	fmt.Println("******")
-	fmt.Print(output)
-	fmt.Println("******")
 }
diff --git a/models/tosca/addSubscriber_test.go b/models/tosca/addSubscriber_test.go
index 0d48340..36b6acf 100644
--- a/models/tosca/addSubscriber_test.go
+++ b/models/tosca/addSubscriber_test.go
@@ -17,7 +17,6 @@
 package tosca_test
 
 import (
-	"fmt"
 	"strings"
 	"testing"
 
@@ -46,9 +45,7 @@
 var sub tosca.SubscriberProvision
 
 func TestAddSubscriber_NewSubscriberProvision(t *testing.T) {
-	fmt.Println("Int TestAddSubscriber_NewSubscriberProvision")
 	sub = tosca.NewSubscriberProvision("myName", 20, 2, "onuSerialNumber", "/1/1/1/1/1.9", "/1/1/1/1/1.9-CID", "myCilli")
-	fmt.Printf("%v\n\n", sub)
 }
 
 func TestAddSubscriber_ToYaml(t *testing.T) {
@@ -59,17 +56,7 @@
 
 	x := strings.Compare(y, expectedOutput)
 	if x != 0 {
-		fmt.Println("******")
-		fmt.Println(expectedOutput)
-		fmt.Println("******")
-		fmt.Println(y)
-		fmt.Println("******")
 		t.Fatal("ToYaml didn't produce the expected yaml")
 	}
-	fmt.Printf("Compare is %d\n", x)
 
-	fmt.Printf(y)
-	fmt.Println("******")
-	fmt.Print(output)
-	fmt.Println("******")
 }
diff --git a/models/tosca/provisionOnt.go b/models/tosca/provisionOnt.go
index c83cc4d..e94c435 100644
--- a/models/tosca/provisionOnt.go
+++ b/models/tosca/provisionOnt.go
@@ -84,12 +84,11 @@
 	if err != nil {
 	}
 	props := &o.TopologyTemplate.NodeTemplates.Ont.Properties
-	props.PonPortID = offset + ponPortNumber
+	props.PonPortID = offset + (ponPortNumber - 1)
 	props.SerialNumber = serialNumber
 	ipNum := []byte(oltIP[12:16]) //only handling ipv4
 	ofID := fmt.Sprintf("of:00000000%0x", ipNum)
 	props.DeviceID = ofID
-	fmt.Printf("%v\n", o)
 	return o
 
 }
diff --git a/models/tosca/provisionOnt_test.go b/models/tosca/provisionOnt_test.go
index ff7cd85..8ce7446 100644
--- a/models/tosca/provisionOnt_test.go
+++ b/models/tosca/provisionOnt_test.go
@@ -17,7 +17,6 @@
 package tosca_test
 
 import (
-	"fmt"
 	"net"
 	"testing"
 
@@ -40,7 +39,7 @@
       type: tosca.nodes.AttWorkflowDriverWhiteListEntry
       properties:
         serial_number: some_serial
-        pon_port_id: 536870914
+        pon_port_id: 536870913
         device_id: of:00000000c0a8010b
       requirements:
       - owner:
@@ -57,6 +56,4 @@
 	if ontYaml != expected {
 		t.Fatalf("Didn't generate the expected yaml\n Generated:\n%s \nExpected:\n%s\n", ontYaml, expected)
 	}
-	fmt.Println(ontYaml)
-	fmt.Println("******************")
 }
diff --git a/test/integration/TestUtils.go b/test/integration/TestUtils.go
deleted file mode 100644
index 52a1348..0000000
--- a/test/integration/TestUtils.go
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-   Copyright 2017 the original author or authors.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-*/
-
-package integration
-
-import (
-	"fmt"
-	"path/filepath"
-	"reflect"
-	"runtime"
-	"testing"
-)
-
-// assert fails the test if the condition is false.
-func assert(tb testing.TB, condition bool, msg string, v ...interface{}) {
-	if !condition {
-		_, file, line, _ := runtime.Caller(1)
-		fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{filepath.Base(file), line}, v...)...)
-		tb.FailNow()
-	}
-}
-
-// ok fails the test if an err is not nil.
-func ok(tb testing.TB, err error) {
-	if err != nil {
-		_, file, line, _ := runtime.Caller(1)
-		fmt.Printf("\033[31m%s:%d: unexpected error: %s\033[39m\n\n", filepath.Base(file), line, err.Error())
-		tb.FailNow()
-	}
-}
-
-// equals fails the test if exp is not equal to act.
-func equals(tb testing.TB, exp, act interface{}) {
-	if !reflect.DeepEqual(exp, act) {
-		_, file, line, _ := runtime.Caller(1)
-		fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, exp, act)
-		tb.FailNow()
-	}
-}
diff --git a/test/integration/serialize_test.go b/test/integration/serialize_test.go
deleted file mode 100644
index c1524bb..0000000
--- a/test/integration/serialize_test.go
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-   Copyright 2017 the original author or authors.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-*/
-
-package integration
-
-import (
-	"testing"
-
-	"gerrit.opencord.org/abstract-olt/internal/pkg/chassisSerialize"
-	"gerrit.opencord.org/abstract-olt/models/abstract"
-)
-
-func TestSerialize(t *testing.T) {
-	chassis1 := generateTestChassis()
-	bytes1, err1 := chassisSerialize.Serialize(chassis1)
-	chassis2, err2 := chassisSerialize.Deserialize(bytes1)
-	bytes2, err3 := chassisSerialize.Serialize(chassis2)
-	chassis3, err4 := chassisSerialize.Deserialize(bytes2)
-
-	ok(t, err1)
-	ok(t, err2)
-	ok(t, err3)
-	ok(t, err4)
-	equals(t, chassis1, chassis3)
-	equals(t, chassis3.Slots[2].Parent, chassis3)
-	equals(t, chassis3.Slots[15].Ports[8].Parent, &chassis3.Slots[15])
-	equals(t, chassis3.Slots[0].Ports[10].Onts[15].Parent, &chassis3.Slots[0].Ports[10])
-}
-
-func generateTestChassis() *abstract.Chassis {
-	chassis := abstract.GenerateChassis("My_CLLI", 1, 1)
-
-	var slots [16]abstract.Slot
-	for i := 0; i < 16; i++ {
-		slots[i] = generateTestSlot(i, chassis)
-	}
-
-	chassis.Slots = slots
-	return chassis
-}
-
-func generateTestSlot(n int, c *abstract.Chassis) abstract.Slot {
-	slot := abstract.Slot{Number: n, Parent: c}
-
-	var ports [16]abstract.Port
-	for i := 0; i < 16; i++ {
-		ports[i] = generateTestPort(16*n+i, &slot)
-	}
-
-	slot.Ports = ports
-	return slot
-}
-
-func generateTestPort(n int, s *abstract.Slot) abstract.Port {
-	port := abstract.Port{Number: n, Parent: s}
-
-	var onts [64]abstract.Ont
-	for i := 0; i < 64; i++ {
-		j := n*64 + i
-		onts[i] = abstract.Ont{Number: j, Svlan: j * 10, Cvlan: j*10 + 5, Parent: &port}
-	}
-
-	port.Onts = onts
-	return port
-}