blob: 321c895d4e71e6565c5c4bfceb38695df9d1c893 [file] [log] [blame]
Author Namea594e632018-08-10 11:33:58 -04001/*
2 Copyright 2017 the original author or authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17package physical
18
19import "net"
20
21/*
22Represents an arbitrary OLT linecard
23*/
24type OLT interface {
25 GetCLLI() string
26 GetHostname() string
27 GetAddress() net.TCPAddr
28 GetNumber() int
29 GetPorts() []PONPort
30 GetParent() *Chassis
31 GetDataSwitchPort() int
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040032 SetNumber(int)
donNewtonAlpha8205a4d2018-08-16 18:27:20 -040033 activate() error
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040034 Output()
Author Namea594e632018-08-10 11:33:58 -040035}
36
37/*
38A basic representation of an OLT which fulfills the above interface,
39and can be used in other OLT implementations
40*/
41type SimpleOLT struct {
42 CLLI string
43 Hostname string
44 Address net.TCPAddr
Don Newton5154fff2018-11-06 17:40:58 -050045 Driver string
Author Namea594e632018-08-10 11:33:58 -040046 Number int
47 Ports []PONPort
donNewtonAlpha5234b132018-08-16 14:12:28 -040048 Active bool
donNewtonAlphac997d642018-10-17 13:22:48 -040049 Parent *Chassis `json:"-" bson:"-"`
Author Namea594e632018-08-10 11:33:58 -040050 DataSwitchPort int
51}
52
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040053func (s SimpleOLT) GetCLLI() string {
Author Namea594e632018-08-10 11:33:58 -040054 return s.CLLI
55}
56
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040057func (s SimpleOLT) GetHostname() string {
Author Namea594e632018-08-10 11:33:58 -040058 return s.Hostname
59}
60
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040061func (s SimpleOLT) GetAddress() net.TCPAddr {
Author Namea594e632018-08-10 11:33:58 -040062 return s.Address
63}
64
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040065func (s SimpleOLT) GetNumber() int {
Author Namea594e632018-08-10 11:33:58 -040066 return s.Number
67}
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040068func (s SimpleOLT) SetNumber(num int) {
69 s.Number = num
70}
Author Namea594e632018-08-10 11:33:58 -040071
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040072func (s SimpleOLT) GetPorts() []PONPort {
Author Namea594e632018-08-10 11:33:58 -040073 return s.Ports
74}
75
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040076func (s SimpleOLT) GetParent() *Chassis {
Author Namea594e632018-08-10 11:33:58 -040077 return s.Parent
78}
79
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040080func (s SimpleOLT) GetDataSwitchPort() int {
Author Namea594e632018-08-10 11:33:58 -040081 return s.DataSwitchPort
82}
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040083func (s SimpleOLT) activate() error {
donNewtonAlpha8205a4d2018-08-16 18:27:20 -040084 s.Active = true
85 //TODO make call to XOS to activate phyiscal OLT
86 return nil
87}
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040088func (s SimpleOLT) Output() error {
89 //TODO make call to XOS to activate phyiscal OLT
90 return nil
91}