Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package physical |
| 18 | |
| 19 | import "net" |
| 20 | |
| 21 | /* |
| 22 | Represents an arbitrary OLT linecard |
| 23 | */ |
| 24 | type OLT interface { |
| 25 | GetCLLI() string |
| 26 | GetHostname() string |
| 27 | GetAddress() net.TCPAddr |
| 28 | GetNumber() int |
| 29 | GetPorts() []PONPort |
| 30 | GetParent() *Chassis |
| 31 | GetDataSwitchPort() int |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 32 | SetNumber(int) |
donNewtonAlpha | 8205a4d | 2018-08-16 18:27:20 -0400 | [diff] [blame] | 33 | activate() error |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 34 | Output() |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /* |
| 38 | A basic representation of an OLT which fulfills the above interface, |
| 39 | and can be used in other OLT implementations |
| 40 | */ |
| 41 | type SimpleOLT struct { |
| 42 | CLLI string |
| 43 | Hostname string |
| 44 | Address net.TCPAddr |
| 45 | Number int |
| 46 | Ports []PONPort |
donNewtonAlpha | 5234b13 | 2018-08-16 14:12:28 -0400 | [diff] [blame] | 47 | Active bool |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 48 | Parent *Chassis `json:"-"` |
| 49 | DataSwitchPort int |
| 50 | } |
| 51 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 52 | func (s SimpleOLT) GetCLLI() string { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 53 | return s.CLLI |
| 54 | } |
| 55 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 56 | func (s SimpleOLT) GetHostname() string { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 57 | return s.Hostname |
| 58 | } |
| 59 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 60 | func (s SimpleOLT) GetAddress() net.TCPAddr { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 61 | return s.Address |
| 62 | } |
| 63 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 64 | func (s SimpleOLT) GetNumber() int { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 65 | return s.Number |
| 66 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 67 | func (s SimpleOLT) SetNumber(num int) { |
| 68 | s.Number = num |
| 69 | } |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 70 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 71 | func (s SimpleOLT) GetPorts() []PONPort { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 72 | return s.Ports |
| 73 | } |
| 74 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 75 | func (s SimpleOLT) GetParent() *Chassis { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 76 | return s.Parent |
| 77 | } |
| 78 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 79 | func (s SimpleOLT) GetDataSwitchPort() int { |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 80 | return s.DataSwitchPort |
| 81 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 82 | func (s SimpleOLT) activate() error { |
donNewtonAlpha | 8205a4d | 2018-08-16 18:27:20 -0400 | [diff] [blame] | 83 | s.Active = true |
| 84 | //TODO make call to XOS to activate phyiscal OLT |
| 85 | return nil |
| 86 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 87 | func (s SimpleOLT) Output() error { |
| 88 | //TODO make call to XOS to activate phyiscal OLT |
| 89 | return nil |
| 90 | } |