blob: 0101b0002e688d1908a409d80dfce7b5de0b5443 [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Sean Condonfae8e662016-12-15 10:25:13 +00003 *
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 */
16package org.onosproject.drivers.netconf;
17
18import java.util.HashMap;
19import java.util.Map;
20import java.util.Set;
21
22import org.onlab.packet.Ip4Address;
23import org.onlab.packet.IpAddress;
24import org.onosproject.net.DeviceId;
25import org.onosproject.netconf.NetconfController;
26import org.onosproject.netconf.NetconfDevice;
27import org.onosproject.netconf.NetconfDeviceInfo;
28import org.onosproject.netconf.NetconfDeviceListener;
29import org.onosproject.netconf.NetconfException;
30
31public class MockNetconfController implements NetconfController {
32
33 private Map<DeviceId, NetconfDevice> devicesMap;
34
35 public MockNetconfController() {
Yuta HIGUCHI2ee4fba2018-06-12 16:21:06 -070036 devicesMap = new HashMap<>();
Sean Condonfae8e662016-12-15 10:25:13 +000037 }
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. Bainbridge56e90232018-12-18 23:25:08 -080058 NetconfDeviceInfo ncdi = new NetconfDeviceInfo("mock", "mock", ipAddress, port, null);
Yuta HIGUCHI2ee4fba2018-06-12 16:21:06 -070059
60 mockNetconfDevice = new MockNetconfDevice(ncdi);
61 devicesMap.put(deviceId, mockNetconfDevice);
Sean Condonfae8e662016-12-15 10:25:13 +000062
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. Bainbridge56e90232018-12-18 23:25:08 -080099 @Override
100 public NetconfDevice getNetconfDevice(IpAddress ip, int port, String path) {
101 // TODO Auto-generated method stub
102 return null;
103 }
Sean Condonfae8e662016-12-15 10:25:13 +0000104}