Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 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 | package org.onosproject.drivers.netconf; |
| 17 | |
| 18 | import java.util.HashMap; |
| 19 | import java.util.Map; |
| 20 | import java.util.Set; |
| 21 | |
| 22 | import org.onlab.packet.Ip4Address; |
| 23 | import org.onlab.packet.IpAddress; |
| 24 | import org.onosproject.net.DeviceId; |
| 25 | import org.onosproject.netconf.NetconfController; |
| 26 | import org.onosproject.netconf.NetconfDevice; |
| 27 | import org.onosproject.netconf.NetconfDeviceInfo; |
| 28 | import org.onosproject.netconf.NetconfDeviceListener; |
| 29 | import org.onosproject.netconf.NetconfException; |
| 30 | |
| 31 | public class MockNetconfController implements NetconfController { |
| 32 | |
| 33 | private Map<DeviceId, NetconfDevice> devicesMap; |
| 34 | |
| 35 | public MockNetconfController() { |
Yuta HIGUCHI | 2ee4fba | 2018-06-12 16:21:06 -0700 | [diff] [blame] | 36 | devicesMap = new HashMap<>(); |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public void addDeviceListener(NetconfDeviceListener listener) { |
| 41 | // TODO Auto-generated method stub |
| 42 | |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public void removeDeviceListener(NetconfDeviceListener listener) { |
| 47 | // TODO Auto-generated method stub |
| 48 | |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public NetconfDevice connectDevice(DeviceId deviceId) throws NetconfException { |
| 53 | NetconfDevice mockNetconfDevice = null; |
| 54 | |
| 55 | String[] nameParts = deviceId.uri().toASCIIString().split(":"); |
| 56 | IpAddress ipAddress = Ip4Address.valueOf(nameParts[1]); |
| 57 | int port = Integer.parseInt(nameParts[2]); |
David K. Bainbridge | 56e9023 | 2018-12-18 23:25:08 -0800 | [diff] [blame] | 58 | NetconfDeviceInfo ncdi = new NetconfDeviceInfo("mock", "mock", ipAddress, port, null); |
Yuta HIGUCHI | 2ee4fba | 2018-06-12 16:21:06 -0700 | [diff] [blame] | 59 | |
| 60 | mockNetconfDevice = new MockNetconfDevice(ncdi); |
| 61 | devicesMap.put(deviceId, mockNetconfDevice); |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 62 | |
| 63 | return mockNetconfDevice; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public void disconnectDevice(DeviceId deviceId, boolean remove) { |
| 68 | // TODO Auto-generated method stub |
| 69 | |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public void removeDevice(DeviceId deviceId) { |
| 74 | // TODO Auto-generated method stub |
| 75 | |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public Map<DeviceId, NetconfDevice> getDevicesMap() { |
| 80 | return devicesMap; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public Set<DeviceId> getNetconfDevices() { |
| 85 | return devicesMap.keySet(); |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public NetconfDevice getNetconfDevice(DeviceId deviceInfo) { |
| 90 | return devicesMap.get(deviceInfo); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public NetconfDevice getNetconfDevice(IpAddress ip, int port) { |
| 95 | // TODO Auto-generated method stub |
| 96 | return null; |
| 97 | } |
| 98 | |
David K. Bainbridge | 56e9023 | 2018-12-18 23:25:08 -0800 | [diff] [blame] | 99 | @Override |
| 100 | public NetconfDevice getNetconfDevice(IpAddress ip, int port, String path) { |
| 101 | // TODO Auto-generated method stub |
| 102 | return null; |
| 103 | } |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 104 | } |