khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Open Networking Foundation |
| 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 | */ |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 16 | |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 17 | package mocks |
| 18 | |
| 19 | import ( |
| 20 | "context" |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 21 | "errors" |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 22 | "fmt" |
Kent Hagerman | 2a07b86 | 2020-06-19 15:23:07 -0400 | [diff] [blame] | 23 | "strings" |
| 24 | |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 25 | "github.com/gogo/protobuf/proto" |
Kent Hagerman | 2a07b86 | 2020-06-19 15:23:07 -0400 | [diff] [blame] | 26 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 27 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
| 28 | com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common" |
| 29 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 30 | ic "github.com/opencord/voltha-protos/v3/go/inter_container" |
| 31 | of "github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 32 | "github.com/opencord/voltha-protos/v3/go/voltha" |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 33 | ) |
| 34 | |
| 35 | const ( |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 36 | numONUPerOLT = 4 |
| 37 | startingUNIPortNo = 100 |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 38 | ) |
| 39 | |
Kent Hagerman | 2a07b86 | 2020-06-19 15:23:07 -0400 | [diff] [blame] | 40 | // static implementation check |
| 41 | var _ adapters.IAdapter = &OLTAdapter{} |
| 42 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 43 | // OLTAdapter represent OLT adapter |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 44 | type OLTAdapter struct { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 45 | *Adapter |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 46 | } |
| 47 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 48 | // NewOLTAdapter - creates OLT adapter instance |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 49 | func NewOLTAdapter(ctx context.Context, cp adapterif.CoreProxy) *OLTAdapter { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 50 | return &OLTAdapter{ |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 51 | Adapter: NewAdapter(cp), |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 52 | } |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 53 | } |
| 54 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 55 | // Adopt_device creates new handler for added device |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 56 | func (oltA *OLTAdapter) Adopt_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 57 | go func() { |
| 58 | d := proto.Clone(device).(*voltha.Device) |
| 59 | d.Root = true |
| 60 | d.Vendor = "olt_adapter_mock" |
| 61 | d.Model = "go-mock" |
| 62 | d.SerialNumber = com.GetRandomSerialNumber() |
| 63 | d.MacAddress = strings.ToUpper(com.GetRandomMacAddress()) |
| 64 | oltA.storeDevice(d) |
| 65 | if res := oltA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 66 | logger.Fatalf(ctx, "deviceUpdate-failed-%s", res) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 67 | } |
khenaidoo | c6c7bda | 2020-06-17 17:20:18 -0400 | [diff] [blame] | 68 | capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 69 | nniPort := &voltha.Port{ |
| 70 | PortNo: 2, |
| 71 | Label: fmt.Sprintf("nni-%d", 2), |
| 72 | Type: voltha.Port_ETHERNET_NNI, |
| 73 | OperStatus: voltha.OperStatus_ACTIVE, |
khenaidoo | c6c7bda | 2020-06-17 17:20:18 -0400 | [diff] [blame] | 74 | OfpPort: &of.OfpPort{ |
| 75 | HwAddr: macAddressToUint32Array("11:22:33:44:55:66"), |
| 76 | Config: 0, |
| 77 | State: uint32(of.OfpPortState_OFPPS_LIVE), |
| 78 | Curr: capability, |
| 79 | Advertised: capability, |
| 80 | Peer: capability, |
| 81 | CurrSpeed: uint32(of.OfpPortFeatures_OFPPF_1GB_FD), |
| 82 | MaxSpeed: uint32(of.OfpPortFeatures_OFPPF_1GB_FD), |
| 83 | }, |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 84 | } |
| 85 | var err error |
| 86 | if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, nniPort); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 87 | logger.Fatalf(ctx, "PortCreated-failed-%s", err) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | ponPort := &voltha.Port{ |
| 91 | PortNo: 1, |
| 92 | Label: fmt.Sprintf("pon-%d", 1), |
| 93 | Type: voltha.Port_PON_OLT, |
| 94 | OperStatus: voltha.OperStatus_ACTIVE, |
| 95 | } |
| 96 | if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 97 | logger.Fatalf(ctx, "PortCreated-failed-%s", err) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | d.ConnectStatus = voltha.ConnectStatus_REACHABLE |
| 101 | d.OperStatus = voltha.OperStatus_ACTIVE |
| 102 | |
| 103 | if err = oltA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 104 | logger.Fatalf(ctx, "Device-state-update-failed-%s", err) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | //Get the latest device data from the Core |
| 108 | if d, err = oltA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 109 | logger.Fatalf(ctx, "getting-device-failed-%s", err) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 110 | } |
| 111 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 112 | oltA.updateDevice(d) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 113 | |
| 114 | // Register Child devices |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 115 | initialUniPortNo := startingUNIPortNo |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 116 | for i := 0; i < numONUPerOLT; i++ { |
| 117 | go func(seqNo int) { |
| 118 | if _, err := oltA.coreProxy.ChildDeviceDetected( |
| 119 | context.TODO(), |
| 120 | d.Id, |
| 121 | 1, |
| 122 | "onu_adapter_mock", |
| 123 | initialUniPortNo+seqNo, |
| 124 | "onu_adapter_mock", |
| 125 | com.GetRandomSerialNumber(), |
| 126 | int64(seqNo)); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 127 | logger.Fatalf(ctx, "failure-sending-child-device-%s", err) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 128 | } |
| 129 | }(i) |
| 130 | } |
| 131 | }() |
| 132 | return nil |
| 133 | } |
| 134 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 135 | // Get_ofp_device_info returns ofp device info |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 136 | func (oltA *OLTAdapter) Get_ofp_device_info(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 137 | if d := oltA.getDevice(device.Id); d == nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 138 | logger.Fatalf(ctx, "device-not-found-%s", device.Id) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 139 | } |
| 140 | return &ic.SwitchCapability{ |
| 141 | Desc: &of.OfpDesc{ |
| 142 | HwDesc: "olt_adapter_mock", |
| 143 | SwDesc: "olt_adapter_mock", |
| 144 | SerialNum: "12345678", |
| 145 | }, |
| 146 | SwitchFeatures: &of.OfpSwitchFeatures{ |
| 147 | NBuffers: 256, |
| 148 | NTables: 2, |
| 149 | Capabilities: uint32(of.OfpCapabilities_OFPC_FLOW_STATS | |
| 150 | of.OfpCapabilities_OFPC_TABLE_STATS | |
| 151 | of.OfpCapabilities_OFPC_PORT_STATS | |
| 152 | of.OfpCapabilities_OFPC_GROUP_STATS), |
| 153 | }, |
| 154 | }, nil |
| 155 | } |
| 156 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 157 | // GetNumONUPerOLT returns number of ONUs per OLT |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 158 | func (oltA *OLTAdapter) GetNumONUPerOLT() int { |
| 159 | return numONUPerOLT |
| 160 | } |
| 161 | |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 162 | // Returns the starting UNI port number |
| 163 | func (oltA *OLTAdapter) GetStartingUNIPortNo() int { |
| 164 | return startingUNIPortNo |
| 165 | } |
| 166 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 167 | // Disable_device disables device |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 168 | func (oltA *OLTAdapter) Disable_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 169 | go func() { |
| 170 | if d := oltA.getDevice(device.Id); d == nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 171 | logger.Fatalf(ctx, "device-not-found-%s", device.Id) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | cloned := proto.Clone(device).(*voltha.Device) |
| 175 | // Update the all ports state on that device to disable |
Kent Hagerman | 2a07b86 | 2020-06-19 15:23:07 -0400 | [diff] [blame] | 176 | if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_UNKNOWN); err != nil { |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 177 | logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err}) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 178 | } |
| 179 | |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 180 | //Update the device operational state |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 181 | cloned.OperStatus = voltha.OperStatus_UNKNOWN |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 182 | // The device is still reachable after it has been disabled, so the connection status should not be changed. |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 183 | |
| 184 | if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil { |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 185 | // Device may already have been deleted in the core |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 186 | logger.Warnw(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err}) |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 187 | return |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 188 | } |
| 189 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 190 | oltA.updateDevice(cloned) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 191 | |
| 192 | // Tell the Core that all child devices have been disabled (by default it's an action already taken by the Core |
| 193 | if err := oltA.coreProxy.ChildDevicesLost(context.TODO(), cloned.Id); err != nil { |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 194 | // Device may already have been deleted in the core |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 195 | logger.Warnw(ctx, "lost-notif-of-child-devices-failed", log.Fields{"device-id": device.Id, "error": err}) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 196 | } |
| 197 | }() |
| 198 | return nil |
| 199 | } |
| 200 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 201 | // Reenable_device reenables device |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 202 | func (oltA *OLTAdapter) Reenable_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 203 | go func() { |
| 204 | if d := oltA.getDevice(device.Id); d == nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 205 | logger.Fatalf(ctx, "device-not-found-%s", device.Id) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | cloned := proto.Clone(device).(*voltha.Device) |
| 209 | // Update the all ports state on that device to enable |
Kent Hagerman | 2a07b86 | 2020-06-19 15:23:07 -0400 | [diff] [blame] | 210 | if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_ACTIVE); err != nil { |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 211 | logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"device-id": device.Id, "error": err}) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | //Update the device state |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 215 | cloned.OperStatus = voltha.OperStatus_ACTIVE |
| 216 | |
| 217 | if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil { |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 218 | logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err}) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | // Tell the Core that all child devices have been enabled |
| 222 | if err := oltA.coreProxy.ChildDevicesDetected(context.TODO(), cloned.Id); err != nil { |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 223 | logger.Fatalf(ctx, "detection-notif-of-child-devices-failed", log.Fields{"device-id": device.Id, "error": err}) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 224 | } |
| 225 | }() |
| 226 | return nil |
| 227 | } |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 228 | |
| 229 | // Enable_port - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 230 | func (oltA *OLTAdapter) Enable_port(ctx context.Context, deviceId string, Port *voltha.Port) error { //nolint |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 231 | go func() { |
| 232 | |
| 233 | if Port.Type == voltha.Port_PON_OLT { |
| 234 | if err := oltA.coreProxy.PortStateUpdate(context.TODO(), deviceId, voltha.Port_PON_OLT, Port.PortNo, voltha.OperStatus_ACTIVE); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 235 | logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"device-id": deviceId, "error": err}) |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | |
| 239 | }() |
| 240 | return nil |
| 241 | } |
| 242 | |
| 243 | // Disable_port - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 244 | func (oltA *OLTAdapter) Disable_port(ctx context.Context, deviceId string, Port *voltha.Port) error { //nolint |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 245 | go func() { |
| 246 | |
| 247 | if Port.Type == voltha.Port_PON_OLT { |
| 248 | if err := oltA.coreProxy.PortStateUpdate(context.TODO(), deviceId, voltha.Port_PON_OLT, Port.PortNo, voltha.OperStatus_DISCOVERED); err != nil { |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 249 | // Corresponding device may have been deleted |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 250 | logger.Warnw(ctx, "updating-ports-failed", log.Fields{"device-id": deviceId, "error": err}) |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | }() |
| 254 | return nil |
| 255 | } |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 256 | |
| 257 | // Child_device_lost deletes ONU and its references |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 258 | func (oltA *OLTAdapter) Child_device_lost(ctx context.Context, deviceID string, pPortNo uint32, onuID uint32) error { // nolint |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 259 | return nil |
| 260 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 261 | |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 262 | // Reboot_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 263 | func (oltA *OLTAdapter) Reboot_device(ctx context.Context, device *voltha.Device) error { // nolint |
divyadesai | cb8b59d | 2020-08-18 09:55:47 +0000 | [diff] [blame] | 264 | logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id}) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 265 | |
| 266 | go func() { |
| 267 | if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), device.Id, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN); err != nil { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 268 | logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err}) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 269 | } |
Kent Hagerman | 2a07b86 | 2020-06-19 15:23:07 -0400 | [diff] [blame] | 270 | if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), device.Id, 0, voltha.OperStatus_UNKNOWN); err != nil { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 271 | // Not an error as the previous command will start the process of clearing the OLT |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 272 | logger.Infow(ctx, "port-update-failed", log.Fields{"device-id": device.Id, "error": err}) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 273 | } |
| 274 | }() |
| 275 | return nil |
| 276 | } |
| 277 | |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 278 | // TODO: REMOVE Start_omci_test begins an omci self-test |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 279 | func (oltA *OLTAdapter) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*ic.TestResponse, error) { // nolint |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 280 | _ = device |
| 281 | return nil, errors.New("start-omci-test-not-implemented") |
| 282 | } |
| 283 | |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 284 | func (oltA *OLTAdapter) Get_ext_value(ctx context.Context, deviceId string, device *voltha.Device, valueflag voltha.ValueType_Type) (*voltha.ReturnValues, error) { // nolint |
Dinesh Belwalkar | c1129f1 | 2020-02-27 10:41:33 -0800 | [diff] [blame] | 285 | _ = deviceId |
| 286 | _ = device |
| 287 | _ = valueflag |
| 288 | return nil, errors.New("get-ext-value-not-implemented") |
| 289 | } |