SEBA-261
refactor to support serialize/deserialize
Change-Id: Icdc0bc2bb06a9d1c3240c0f46e1de02953a0b017
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("******************")
}