blob: 721e731b9f48cc97f5e17e679ce3059c6b5d9f6e [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
45 Number int
46 Ports []PONPort
donNewtonAlpha5234b132018-08-16 14:12:28 -040047 Active bool
Author Namea594e632018-08-10 11:33:58 -040048 Parent *Chassis `json:"-"`
49 DataSwitchPort int
50}
51
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040052func (s SimpleOLT) GetCLLI() string {
Author Namea594e632018-08-10 11:33:58 -040053 return s.CLLI
54}
55
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040056func (s SimpleOLT) GetHostname() string {
Author Namea594e632018-08-10 11:33:58 -040057 return s.Hostname
58}
59
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040060func (s SimpleOLT) GetAddress() net.TCPAddr {
Author Namea594e632018-08-10 11:33:58 -040061 return s.Address
62}
63
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040064func (s SimpleOLT) GetNumber() int {
Author Namea594e632018-08-10 11:33:58 -040065 return s.Number
66}
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040067func (s SimpleOLT) SetNumber(num int) {
68 s.Number = num
69}
Author Namea594e632018-08-10 11:33:58 -040070
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040071func (s SimpleOLT) GetPorts() []PONPort {
Author Namea594e632018-08-10 11:33:58 -040072 return s.Ports
73}
74
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040075func (s SimpleOLT) GetParent() *Chassis {
Author Namea594e632018-08-10 11:33:58 -040076 return s.Parent
77}
78
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040079func (s SimpleOLT) GetDataSwitchPort() int {
Author Namea594e632018-08-10 11:33:58 -040080 return s.DataSwitchPort
81}
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040082func (s SimpleOLT) activate() error {
donNewtonAlpha8205a4d2018-08-16 18:27:20 -040083 s.Active = true
84 //TODO make call to XOS to activate phyiscal OLT
85 return nil
86}
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040087func (s SimpleOLT) Output() error {
88 //TODO make call to XOS to activate phyiscal OLT
89 return nil
90}