SEBA-258 - Added MONGODB backup
Change-Id: I2542e7dfc894dfa5a1269c6be99cfa8036b9911c
diff --git a/models/physical/olt.go b/models/physical/olt.go
index 721e731..c800ad5 100644
--- a/models/physical/olt.go
+++ b/models/physical/olt.go
@@ -45,7 +45,7 @@
Number int
Ports []PONPort
Active bool
- Parent *Chassis `json:"-"`
+ Parent *Chassis `json:"-" bson:"-"`
DataSwitchPort int
}
diff --git a/models/physical/ont.go b/models/physical/ont.go
index 79c21ee..21fbbae 100644
--- a/models/physical/ont.go
+++ b/models/physical/ont.go
@@ -20,12 +20,12 @@
Ont represents a single ont/onu connect to a splitter on a Port
*/
type Ont struct {
- Number int
- Svlan int
- Cvlan int
- SerialNumber string
- Parent *PONPort `json:"-"`
- Active bool
- NasPortID string
- CircuitID string
+ Number int `json:",omitempty"`
+ Svlan int `,json:",omitempty"`
+ Cvlan int `,json:",omitempty"`
+ SerialNumber string `,json:",omitempty"`
+ Parent *PONPort `json:"-" bson:"-"`
+ Active bool `json:",omitempty"`
+ NasPortID string `json:",omitempty"`
+ CircuitID string `json:",omitempty"`
}
diff --git a/models/physical/ponport.go b/models/physical/ponport.go
index 683489e..9c626c3 100644
--- a/models/physical/ponport.go
+++ b/models/physical/ponport.go
@@ -27,7 +27,7 @@
Number int
DeviceID string
Onts [64]Ont
- Parent *SimpleOLT `json:"-"`
+ Parent *SimpleOLT `json:"-" bson:"-"`
}
/*
diff --git a/models/serialize.go b/models/serialize.go
index a0c2a01..fbcf460 100644
--- a/models/serialize.go
+++ b/models/serialize.go
@@ -18,24 +18,32 @@
import (
"encoding/json"
+ "log"
+
+ "gerrit.opencord.org/abstract-olt/internal/pkg/settings"
+ "gerrit.opencord.org/abstract-olt/models/abstract"
+ "gerrit.opencord.org/abstract-olt/models/physical"
)
func (chassisHolder ChassisHolder) Serialize() ([]byte, error) {
- return json.Marshal(chassisHolder)
+ return json.Marshal(chassisHolder.PhysicalChassis)
}
func (chassisHolder *ChassisHolder) Deserialize(jsonData []byte) error {
- err := json.Unmarshal(jsonData, chassisHolder)
+ physicalChassis := physical.Chassis{}
+ err := json.Unmarshal(jsonData, &physicalChassis)
if err != nil {
return err
}
- physicalChassis := &chassisHolder.PhysicalChassis
- abstractChassis := &chassisHolder.AbstractChassis
+ abstractChassis := abstract.GenerateChassis(physicalChassis.CLLI, 1, 1)
+ chassisHolder.AbstractChassis = abstractChassis
+ chassisHolder.PhysicalChassis = physicalChassis
+
//first handle abstract parent pointers
for i := 0; i < len(abstractChassis.Slots); i++ {
slot := &abstractChassis.Slots[i]
- slot.Parent = abstractChassis
+ slot.Parent = &abstractChassis
for j := 0; j < len(slot.Ports); j++ {
port := &slot.Ports[j]
port.Parent = slot
@@ -47,7 +55,7 @@
//second handle physical parent pointers
for i := 0; i < len(physicalChassis.Linecards); i++ {
slot := physicalChassis.Linecards[i]
- slot.Parent = physicalChassis
+ slot.Parent = &physicalChassis
for j := 0; j < len(slot.Ports); j++ {
port := &slot.Ports[j]
port.Parent = &slot
@@ -65,5 +73,8 @@
absPort.PhysPort = &slot.Ports[j]
}
}
+ if settings.GetDebug() {
+ log.Printf("created chassis %v\n", abstractChassis)
+ }
return nil
}