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 ( |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 20 | "context" |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 21 | "fmt" |
Andrea Campanella | 025667e | 2021-01-14 11:50:07 +0100 | [diff] [blame] | 22 | "github.com/opencord/voltha-protos/v4/go/extension" |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 23 | "strconv" |
| 24 | "strings" |
| 25 | "sync" |
| 26 | |
Maninder | dfadc98 | 2020-10-28 14:04:33 +0530 | [diff] [blame] | 27 | "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif" |
| 28 | ic "github.com/opencord/voltha-protos/v4/go/inter_container" |
| 29 | of "github.com/opencord/voltha-protos/v4/go/openflow_13" |
| 30 | "github.com/opencord/voltha-protos/v4/go/voltha" |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | func macAddressToUint32Array(mac string) []uint32 { |
| 34 | slist := strings.Split(mac, ":") |
| 35 | result := make([]uint32, len(slist)) |
| 36 | var err error |
| 37 | var tmp int64 |
| 38 | for index, val := range slist { |
| 39 | if tmp, err = strconv.ParseInt(val, 16, 32); err != nil { |
| 40 | return []uint32{1, 2, 3, 4, 5, 6} |
| 41 | } |
| 42 | result[index] = uint32(tmp) |
| 43 | } |
| 44 | return result |
| 45 | } |
| 46 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 47 | // Adapter represents adapter attributes |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 48 | type Adapter struct { |
Himani Chawla | 2ba1c9c | 2020-10-07 13:19:03 +0530 | [diff] [blame] | 49 | coreProxy adapterif.CoreProxy |
| 50 | flows map[uint64]*voltha.OfpFlowStats |
| 51 | flowLock sync.RWMutex |
| 52 | devices map[string]*voltha.Device |
| 53 | deviceLock sync.RWMutex |
| 54 | failFlowAdd bool |
| 55 | failFlowDelete bool |
| 56 | failDeleteDevice bool |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 57 | } |
| 58 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 59 | // NewAdapter creates adapter instance |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 60 | func NewAdapter(cp adapterif.CoreProxy) *Adapter { |
| 61 | return &Adapter{ |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 62 | flows: map[uint64]*voltha.OfpFlowStats{}, |
| 63 | devices: map[string]*voltha.Device{}, |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 64 | coreProxy: cp, |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func (ta *Adapter) storeDevice(d *voltha.Device) { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 69 | ta.deviceLock.Lock() |
| 70 | defer ta.deviceLock.Unlock() |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 71 | if d != nil { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 72 | ta.devices[d.Id] = d |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 76 | func (ta *Adapter) getDevice(id string) *voltha.Device { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 77 | ta.deviceLock.RLock() |
| 78 | defer ta.deviceLock.RUnlock() |
| 79 | return ta.devices[id] |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 80 | } |
| 81 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 82 | func (ta *Adapter) updateDevice(d *voltha.Device) { |
| 83 | ta.storeDevice(d) |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 84 | } |
| 85 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 86 | // Adapter_descriptor - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 87 | func (ta *Adapter) Adapter_descriptor(ctx context.Context) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 88 | return nil |
| 89 | } |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 90 | |
| 91 | // Device_types - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 92 | func (ta *Adapter) Device_types(ctx context.Context) (*voltha.DeviceTypes, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 93 | return nil, nil |
| 94 | } |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 95 | |
| 96 | // Health - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 97 | func (ta *Adapter) Health(ctx context.Context) (*voltha.HealthStatus, error) { |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 98 | return nil, nil |
| 99 | } |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 100 | |
| 101 | // Adopt_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 102 | func (ta *Adapter) Adopt_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 103 | return nil |
| 104 | } |
| 105 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 106 | // Reconcile_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 107 | func (ta *Adapter) Reconcile_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 108 | return nil |
| 109 | } |
| 110 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 111 | // Abandon_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 112 | func (ta *Adapter) Abandon_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 113 | return nil |
| 114 | } |
| 115 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 116 | // Disable_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 117 | func (ta *Adapter) Disable_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 118 | return nil |
| 119 | } |
| 120 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 121 | // Reenable_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 122 | func (ta *Adapter) Reenable_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 123 | return nil |
| 124 | } |
| 125 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 126 | // Reboot_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 127 | func (ta *Adapter) Reboot_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 128 | return nil |
| 129 | } |
| 130 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 131 | // Self_test_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 132 | func (ta *Adapter) Self_test_device(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 133 | return nil |
| 134 | } |
| 135 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 136 | // Delete_device - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 137 | func (ta *Adapter) Delete_device(ctx context.Context, device *voltha.Device) error { // nolint |
Himani Chawla | 2ba1c9c | 2020-10-07 13:19:03 +0530 | [diff] [blame] | 138 | if ta.failDeleteDevice { |
| 139 | return fmt.Errorf("delete-device-failure") |
| 140 | } |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 141 | return nil |
| 142 | } |
| 143 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 144 | // Get_device_details - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 145 | func (ta *Adapter) Get_device_details(ctx context.Context, device *voltha.Device) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 146 | return nil |
| 147 | } |
| 148 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 149 | // Update_flows_bulk - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 150 | func (ta *Adapter) Update_flows_bulk(ctx context.Context, device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 151 | return nil |
| 152 | } |
| 153 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 154 | // Update_flows_incrementally mocks the incremental flow update |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 155 | func (ta *Adapter) Update_flows_incrementally(ctx context.Context, device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { // nolint |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 156 | ta.flowLock.Lock() |
| 157 | defer ta.flowLock.Unlock() |
| 158 | |
khenaidoo | 0db4c81 | 2020-05-27 15:27:30 -0400 | [diff] [blame] | 159 | if flows.ToAdd != nil && len(flows.ToAdd.Items) > 0 { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 160 | if ta.failFlowAdd { |
| 161 | return fmt.Errorf("flow-add-error") |
| 162 | } |
| 163 | for _, f := range flows.ToAdd.Items { |
| 164 | ta.flows[f.Id] = f |
| 165 | } |
| 166 | } |
khenaidoo | 0db4c81 | 2020-05-27 15:27:30 -0400 | [diff] [blame] | 167 | if flows.ToRemove != nil && len(flows.ToRemove.Items) > 0 { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 168 | if ta.failFlowDelete { |
| 169 | return fmt.Errorf("flow-delete-error") |
| 170 | } |
| 171 | for _, f := range flows.ToRemove.Items { |
| 172 | delete(ta.flows, f.Id) |
| 173 | } |
| 174 | } |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 175 | return nil |
| 176 | } |
| 177 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 178 | // Update_pm_config - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 179 | func (ta *Adapter) Update_pm_config(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 180 | return nil |
| 181 | } |
| 182 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 183 | // Receive_packet_out - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 184 | func (ta *Adapter) Receive_packet_out(ctx context.Context, deviceID string, egressPortNo int, msg *of.OfpPacketOut) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 185 | return nil |
| 186 | } |
| 187 | |
Devmalya Paul | c594bb3 | 2019-11-06 07:34:27 +0000 | [diff] [blame] | 188 | // Suppress_event - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 189 | func (ta *Adapter) Suppress_event(ctx context.Context, filter *voltha.EventFilter) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 190 | return nil |
| 191 | } |
| 192 | |
Devmalya Paul | c594bb3 | 2019-11-06 07:34:27 +0000 | [diff] [blame] | 193 | // Unsuppress_event - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 194 | func (ta *Adapter) Unsuppress_event(ctx context.Context, filter *voltha.EventFilter) error { // nolint |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 195 | return nil |
| 196 | } |
| 197 | |
| 198 | // Get_ofp_device_info - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 199 | func (ta *Adapter) 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] | 200 | return &ic.SwitchCapability{ |
| 201 | Desc: &of.OfpDesc{ |
| 202 | HwDesc: "adapter_mock", |
| 203 | SwDesc: "adapter_mock", |
| 204 | SerialNum: "000000000", |
| 205 | }, |
| 206 | SwitchFeatures: &of.OfpSwitchFeatures{ |
| 207 | NBuffers: 256, |
| 208 | NTables: 2, |
| 209 | Capabilities: uint32(of.OfpCapabilities_OFPC_FLOW_STATS | |
| 210 | of.OfpCapabilities_OFPC_TABLE_STATS | |
| 211 | of.OfpCapabilities_OFPC_PORT_STATS | |
| 212 | of.OfpCapabilities_OFPC_GROUP_STATS), |
| 213 | }, |
| 214 | }, nil |
| 215 | } |
| 216 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 217 | // Process_inter_adapter_message - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 218 | func (ta *Adapter) Process_inter_adapter_message(ctx context.Context, msg *ic.InterAdapterMessage) error { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 219 | return nil |
| 220 | } |
| 221 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 222 | // Download_image - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 223 | func (ta *Adapter) Download_image(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 224 | return nil, nil |
| 225 | } |
| 226 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 227 | // Get_image_download_status - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 228 | func (ta *Adapter) Get_image_download_status(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 229 | return nil, nil |
| 230 | } |
| 231 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 232 | // Cancel_image_download - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 233 | func (ta *Adapter) Cancel_image_download(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 234 | return nil, nil |
| 235 | } |
| 236 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 237 | // Activate_image_update - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 238 | func (ta *Adapter) Activate_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 239 | return nil, nil |
| 240 | } |
| 241 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 242 | // Revert_image_update - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 243 | func (ta *Adapter) Revert_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint |
khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 244 | return nil, nil |
| 245 | } |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 246 | |
| 247 | // Enable_port - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 248 | func (ta *Adapter) Enable_port(ctx context.Context, deviceId string, port *voltha.Port) error { //nolint |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 249 | return nil |
| 250 | } |
| 251 | |
| 252 | // Disable_port - |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 253 | func (ta *Adapter) Disable_port(ctx context.Context, deviceId string, port *voltha.Port) error { //nolint |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 254 | return nil |
| 255 | } |
Scott Baker | 0e78ba2 | 2020-02-24 17:58:47 -0800 | [diff] [blame] | 256 | |
| 257 | // Child_device_lost - |
Girish Gowdra | 6f9b10e | 2021-03-11 14:36:39 -0800 | [diff] [blame] | 258 | func (ta *Adapter) Child_device_lost(ctx context.Context, childDevice *voltha.Device) error { //nolint |
Scott Baker | 0e78ba2 | 2020-02-24 17:58:47 -0800 | [diff] [blame] | 259 | return nil |
| 260 | } |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 261 | |
| 262 | // Start_omci_test |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 263 | func (ta *Adapter) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { //nolint |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 264 | return nil, nil |
| 265 | } |
Dinesh Belwalkar | c1129f1 | 2020-02-27 10:41:33 -0800 | [diff] [blame] | 266 | |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 267 | func (ta *Adapter) 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] | 268 | return nil, nil |
| 269 | } |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 270 | |
Andrea Campanella | 025667e | 2021-01-14 11:50:07 +0100 | [diff] [blame] | 271 | // Single_get_value_request retrieves a single value. |
| 272 | func (ta *Adapter) Single_get_value_request(ctx context.Context, // nolint |
| 273 | request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) { |
| 274 | return nil, nil |
| 275 | } |
| 276 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame] | 277 | // GetFlowCount returns the total number of flows presently under this adapter |
| 278 | func (ta *Adapter) GetFlowCount() int { |
| 279 | ta.flowLock.RLock() |
| 280 | defer ta.flowLock.RUnlock() |
| 281 | |
| 282 | return len(ta.flows) |
| 283 | } |
| 284 | |
| 285 | // ClearFlows removes all flows in this adapter |
| 286 | func (ta *Adapter) ClearFlows() { |
| 287 | ta.flowLock.Lock() |
| 288 | defer ta.flowLock.Unlock() |
| 289 | |
| 290 | ta.flows = map[uint64]*voltha.OfpFlowStats{} |
| 291 | } |
| 292 | |
| 293 | // SetFlowAction sets the adapter action on addition and deletion of flows |
| 294 | func (ta *Adapter) SetFlowAction(failFlowAdd, failFlowDelete bool) { |
| 295 | ta.failFlowAdd = failFlowAdd |
| 296 | ta.failFlowDelete = failFlowDelete |
| 297 | } |
Himani Chawla | 2ba1c9c | 2020-10-07 13:19:03 +0530 | [diff] [blame] | 298 | |
| 299 | // SetDeleteAction sets the adapter action on delete device |
| 300 | func (ta *Adapter) SetDeleteAction(failDeleteDevice bool) { |
| 301 | ta.failDeleteDevice = failDeleteDevice |
| 302 | } |
ssiddiqui | f076cb8 | 2021-04-23 10:47:04 +0530 | [diff] [blame] | 303 | |
| 304 | // Download_onu_image - |
| 305 | func (ta *Adapter) Download_onu_image(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) { //nolint |
| 306 | return nil, nil |
| 307 | } |
| 308 | |
| 309 | // Get_onu_image_status - |
| 310 | func (ta *Adapter) Get_onu_image_status(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint |
| 311 | return nil, nil |
| 312 | } |
| 313 | |
| 314 | // Abort_onu_image_upgrade - |
| 315 | func (ta *Adapter) Abort_onu_image_upgrade(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint |
| 316 | return nil, nil |
| 317 | } |
| 318 | |
| 319 | // Get_onu_images - |
| 320 | func (ta *Adapter) Get_onu_images(ctx context.Context, deviceID string) (*voltha.OnuImages, error) { //nolint |
| 321 | return nil, nil |
| 322 | } |
| 323 | |
| 324 | // Activate_onu_image - |
| 325 | func (ta *Adapter) Activate_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint |
| 326 | return nil, nil |
| 327 | } |
| 328 | |
| 329 | // Commit_onu_image - |
| 330 | func (ta *Adapter) Commit_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { //nolint |
| 331 | return nil, nil |
| 332 | } |