SEBA-261
refactor to support serialize/deserialize

Change-Id: Icdc0bc2bb06a9d1c3240c0f46e1de02953a0b017
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("******************")
 }