initial add
deleting bin/cert
adding license info
tweaking packages to match go standard conventions
updating to match tweaked package names
Change-Id: I78b395a778c0ceb649e2aa4491c81fd3dc28d0c0
diff --git a/models/abstract/ChassisUtils.go b/models/abstract/ChassisUtils.go
new file mode 100644
index 0000000..4c41698
--- /dev/null
+++ b/models/abstract/ChassisUtils.go
@@ -0,0 +1,105 @@
+/*
+ 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 "errors"
+
+/*
+GenerateChassis - constructs a new AbstractOLT Chassis
+*/
+func GenerateChassis(CLLI string) *Chassis {
+ chassis := Chassis{CLLI: CLLI}
+
+ var slots [16]Slot
+ for i := 0; i < 16; i++ {
+ slots[i] = generateSlot(i, &chassis)
+ }
+
+ chassis.Slots = slots
+ return &chassis
+}
+
+func generateSlot(n int, c *Chassis) Slot {
+ slot := Slot{Number: n, Parent: c}
+
+ var ports [16]Port
+ for i := 0; i < 16; i++ {
+ ports[i] = generatePort(i, &slot)
+ }
+
+ slot.Ports = ports
+ return slot
+}
+func generatePort(n int, s *Slot) Port {
+ port := Port{Number: n, Parent: s}
+
+ var onts [64]Ont
+ for i := 0; i < 64; i++ {
+ /* adding one because the system that provisions is 1 based on everything not 0 based*/
+ onts[i] = Ont{Number: i, Svlan: calculateSvlan(s.Number+1, n+1, i+1),
+ Cvlan: calculateCvlan(s.Number+1, n+1, i+1), Parent: &port}
+ }
+
+ port.Onts = onts
+ return port
+}
+
+func calculateCvlan(slot int, port int, ont int) int {
+ ontPortOffset := 120 // Max(ONT_SLOT) * Max(ONT_PORT) = 10 * 12 = 120
+ ontSlotOffset := 12 //= Max(ONT_PORT) = 12
+ vlanOffset := 1 //(VID 1 is reserved)
+
+ cVid := ((ont-1)%32)*ontPortOffset +
+ (slot-1)*ontSlotOffset + port + vlanOffset
+
+ return cVid
+}
+
+func calculateSvlan(slot int, port int, ont int) int {
+ ltSlotOffset := 16
+ vlanGap := 288 // Max(LT_SLOT) * Max(ltSlotOffset) = 18 * 16 = 288
+ vlanOffset := 1 //(VID 1 is reserved)
+
+ sVid := ((slot-1)*ltSlotOffset + port) + ((ont-1)/32)*vlanGap + vlanOffset
+
+ return sVid
+}
+
+/*
+NextPort pulls the first unMapped port in the abstract chassis so the next physical port can be mapped to it
+*/
+func (chassis *Chassis) NextPort() (*Port, error) {
+ info := &chassis.AllocInfo
+
+ if info.outOfPorts {
+ return nil, errors.New("Abstract chassis out of ports")
+ }
+
+ nextPort := &chassis.Slots[info.slot].Ports[info.port]
+
+ info.port++
+ if info.port == MAX_PORTS {
+ info.port = 0
+ info.slot++
+ if info.slot == MAX_SLOTS {
+ info.slot = 0
+ info.outOfPorts = true
+ }
+ }
+
+ return nextPort, nil
+}
diff --git a/models/abstract/chassis.go b/models/abstract/chassis.go
new file mode 100644
index 0000000..52de90d
--- /dev/null
+++ b/models/abstract/chassis.go
@@ -0,0 +1,36 @@
+/*
+ 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
+
+const MAX_SLOTS int = 16
+const MAX_PORTS int = 16
+
+/*
+Chassis is a model that takes up to 16 discreet OLT chassis as if it is a 16 slot OLT chassis
+*/
+type Chassis struct {
+ CLLI string
+ Slots [16]Slot
+ AllocInfo PortAllocationInfo
+}
+
+type PortAllocationInfo struct {
+ // Current info on next port to be allocated
+ slot int
+ port int
+ outOfPorts bool
+}
diff --git a/models/abstract/ont.go b/models/abstract/ont.go
new file mode 100644
index 0000000..bfd6d60
--- /dev/null
+++ b/models/abstract/ont.go
@@ -0,0 +1,27 @@
+/*
+ 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
+
+/*
+Ont represents a single ont/onu connect to a splitter on a Port
+*/
+type Ont struct {
+ Number int
+ Svlan int
+ Cvlan int
+ Parent *Port `json:"-"`
+}
diff --git a/models/abstract/port.go b/models/abstract/port.go
new file mode 100644
index 0000000..c23249a
--- /dev/null
+++ b/models/abstract/port.go
@@ -0,0 +1,30 @@
+/*
+ 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 "gerrit.opencord.org/abstract-olt/models/physical"
+
+/*
+Port represents a single PON port on the OLT chassis
+*/
+type Port struct {
+ Number int
+ // DeviceID string
+ Onts [64]Ont
+ PhysPort *physical.PONPort
+ Parent *Slot `json:"-"`
+}
diff --git a/models/abstract/slot.go b/models/abstract/slot.go
new file mode 100644
index 0000000..343542e
--- /dev/null
+++ b/models/abstract/slot.go
@@ -0,0 +1,30 @@
+/*
+ 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
+
+/*
+Slot models a collection of PON ports (likely a single chassis) as if it is a
+line card within a chassis
+*/
+type Slot struct {
+ // DeviceID string
+ // Hostname string
+ // Address net.TCPAddr
+ Number int
+ Ports [16]Port
+ Parent *Chassis `json:"-"`
+}