[ONOS-4045]Adding mastership service to NetconfProvider
Change-Id: Id39cbef54a079ab6e080a9d3f60770c4bea90b3f
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
index 7202fb7..59d8ce7 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
@@ -35,7 +35,7 @@
.getLogger(DefaultNetconfDevice.class);
private NetconfDeviceInfo netconfDeviceInfo;
- private boolean deviceState = false;
+ private boolean deviceState = true;
protected NetconfSessionFactory sessionFactory = new SshNetconfSessionFactory();
private NetconfSession netconfSession;
@@ -53,10 +53,10 @@
try {
netconfSession = sessionFactory.createNetconfSession(deviceInfo);
} catch (IOException e) {
+ deviceState = false;
throw new NetconfException("Cannot create connection and session for device " +
deviceInfo, e);
}
- deviceState = true;
}
@Override
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
index 99ef8ce..432329b 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
@@ -19,9 +19,16 @@
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
+import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.key.DeviceKeyId;
+import org.onosproject.net.key.DeviceKeyService;
+import org.onosproject.net.key.UsernamePassword;
import org.onosproject.netconf.NetconfController;
import org.onosproject.netconf.NetconfDevice;
import org.onosproject.netconf.NetconfDeviceFactory;
@@ -34,6 +41,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -45,6 +53,11 @@
@Component(immediate = true)
@Service
public class NetconfControllerImpl implements NetconfController {
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceKeyService deviceKeyService;
public static final Logger log = LoggerFactory
.getLogger(NetconfControllerImpl.class);
@@ -95,55 +108,93 @@
}
@Override
- public NetconfDevice connectDevice(NetconfDeviceInfo deviceInfo) throws NetconfException {
- if (netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
- log.info("Device {} is already present", deviceInfo);
- return netconfDeviceMap.get(deviceInfo.getDeviceId());
+ public NetconfDevice connectDevice(DeviceId deviceId) throws NetconfException {
+ if (netconfDeviceMap.containsKey(deviceId)) {
+ log.debug("Device {} is already present", deviceId);
+ return netconfDeviceMap.get(deviceId);
} else {
- log.info("Creating NETCONF device {}", deviceInfo);
- NetconfDevice device = createDevice(deviceInfo);
- device.getSession().addDeviceOutputListener(downListener);
- return device;
+ log.debug("Creating NETCONF device {}", deviceId);
+ Device device = deviceService.getDevice(deviceId);
+ String ip;
+ int port;
+ if (device != null) {
+ ip = device.annotations().value("ipaddress");
+ port = Integer.parseInt(device.annotations().value("port"));
+ } else {
+ String[] info = deviceId.toString().split(":");
+ if (info.length == 3) {
+ ip = info[1];
+ port = Integer.parseInt(info[2]);
+ } else {
+ ip = Arrays.asList(info).stream().filter(el -> !el.equals(info[0])
+ && !el.equals(info[info.length - 1]))
+ .reduce((t, u) -> t + ":" + u)
+ .get();
+ log.debug("ip v6 {}", ip);
+ port = Integer.parseInt(info[info.length - 1]);
+ }
+ }
+ try {
+ UsernamePassword deviceKey = deviceKeyService.getDeviceKey(
+ DeviceKeyId.deviceKeyId(deviceId.toString())).asUsernamePassword();
+
+ NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo(deviceKey.username(),
+ deviceKey.password(),
+ IpAddress.valueOf(ip),
+ port);
+ NetconfDevice netconfDevicedevice = createDevice(deviceInfo);
+
+ netconfDevicedevice.getSession().addDeviceOutputListener(downListener);
+ return netconfDevicedevice;
+ } catch (NullPointerException e) {
+ throw new NetconfException("No Device Key for device " + deviceId, e);
+ }
}
}
@Override
- public void disconnectDevice(NetconfDeviceInfo deviceInfo) {
- if (!netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
- log.warn("Device {} is not present", deviceInfo);
+ public void disconnectDevice(DeviceId deviceId, boolean remove) {
+ if (!netconfDeviceMap.containsKey(deviceId)) {
+ log.warn("Device {} is not present", deviceId);
} else {
- stopDevice(deviceInfo);
+ stopDevice(deviceId, remove);
}
}
- @Override
- public void removeDevice(NetconfDeviceInfo deviceInfo) {
- if (!netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
- log.warn("Device {} is not present", deviceInfo);
- } else {
- netconfDeviceMap.remove(deviceInfo.getDeviceId());
+ private void stopDevice(DeviceId deviceId, boolean remove) {
+ netconfDeviceMap.get(deviceId).disconnect();
+ netconfDeviceMap.remove(deviceId);
+ if (remove) {
for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceRemoved(deviceInfo);
+ l.deviceRemoved(deviceId);
+ }
+ }
+ }
+
+ @Override
+ public void removeDevice(DeviceId deviceId) {
+ if (!netconfDeviceMap.containsKey(deviceId)) {
+ log.warn("Device {} is not present", deviceId);
+ for (NetconfDeviceListener l : netconfDeviceListeners) {
+ l.deviceRemoved(deviceId);
+ }
+ } else {
+ netconfDeviceMap.remove(deviceId);
+ for (NetconfDeviceListener l : netconfDeviceListeners) {
+ l.deviceRemoved(deviceId);
}
}
}
private NetconfDevice createDevice(NetconfDeviceInfo deviceInfo) throws NetconfException {
NetconfDevice netconfDevice = deviceFactory.createNetconfDevice(deviceInfo);
- for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceAdded(deviceInfo);
- }
netconfDeviceMap.put(deviceInfo.getDeviceId(), netconfDevice);
+ for (NetconfDeviceListener l : netconfDeviceListeners) {
+ l.deviceAdded(deviceInfo.getDeviceId());
+ }
return netconfDevice;
}
- private void stopDevice(NetconfDeviceInfo deviceInfo) {
- netconfDeviceMap.get(deviceInfo.getDeviceId()).disconnect();
- netconfDeviceMap.remove(deviceInfo.getDeviceId());
- for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceRemoved(deviceInfo);
- }
- }
@Override
public Map<DeviceId, NetconfDevice> getDevicesMap() {
@@ -155,6 +206,8 @@
return netconfDeviceMap.keySet();
}
+
+
//Device factory for the specific NetconfDeviceImpl
private class DefaultNetconfDeviceFactory implements NetconfDeviceFactory {
@@ -171,7 +224,7 @@
@Override
public void event(NetconfDeviceOutputEvent event) {
if (event.type().equals(NetconfDeviceOutputEvent.Type.DEVICE_UNREGISTERED)) {
- removeDevice(event.getDeviceInfo());
+ removeDevice(event.getDeviceInfo().getDeviceId());
}
}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
index d554880..ce37e80 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
@@ -375,13 +375,12 @@
private boolean close(boolean force) throws NetconfException {
StringBuilder rpc = new StringBuilder();
- rpc.append("<rpc>");
+ rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">");
if (force) {
- rpc.append("<kill-configuration/>");
+ rpc.append("<kill-session/>");
} else {
- rpc.append("<close-configuration/>");
+ rpc.append("<close-session/>");
}
- rpc.append("<close-configuration/>");
rpc.append("</rpc>");
rpc.append(ENDPATTERN);
return checkReply(sendRequest(rpc.toString())) || close(true);
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java
index 931bfd4..03bb53e 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java
@@ -22,6 +22,8 @@
import org.junit.Test;
import org.onlab.packet.IpAddress;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.key.DeviceKeyService;
import org.onosproject.netconf.NetconfDevice;
import org.onosproject.netconf.NetconfDeviceFactory;
import org.onosproject.netconf.NetconfDeviceInfo;
@@ -44,12 +46,14 @@
* Unit tests for the Netconf controller implementation test.
*/
public class NetconfControllerImplTest {
+
NetconfControllerImpl ctrl;
//DeviceInfo
NetconfDeviceInfo deviceInfo1;
NetconfDeviceInfo deviceInfo2;
NetconfDeviceInfo badDeviceInfo3;
+ NetconfDeviceInfo deviceInfoIpV6;
//Devices & DeviceId
NetconfDevice device1;
@@ -68,21 +72,29 @@
private static final String DEVICE_1_IP = "10.10.10.11";
private static final String DEVICE_2_IP = "10.10.10.12";
private static final String BAD_DEVICE_IP = "10.10.10.13";
+ private static final String DEVICE_IPV6 = "2001:db8::1";
private static final int DEVICE_1_PORT = 11;
private static final int DEVICE_2_PORT = 12;
private static final int BAD_DEVICE_PORT = 13;
+ private static final int IPV6_DEVICE_PORT = 14;
+
+ private static DeviceService deviceService = new NetconfDeviceServiceMock();
+ private static DeviceKeyService deviceKeyService = new NetconfDeviceKeyServiceMock();
@Before
public void setUp() throws Exception {
ctrl = new NetconfControllerImpl();
ctrl.deviceFactory = new TestNetconfDeviceFactory();
+ ctrl.deviceService = deviceService;
+ ctrl.deviceKeyService = deviceKeyService;
//Creating mock devices
deviceInfo1 = new NetconfDeviceInfo("device1", "001", IpAddress.valueOf(DEVICE_1_IP), DEVICE_1_PORT);
deviceInfo2 = new NetconfDeviceInfo("device2", "002", IpAddress.valueOf(DEVICE_2_IP), DEVICE_2_PORT);
badDeviceInfo3 = new NetconfDeviceInfo("device3", "003", IpAddress.valueOf(BAD_DEVICE_IP), BAD_DEVICE_PORT);
+ deviceInfoIpV6 = new NetconfDeviceInfo("deviceIpv6", "004", IpAddress.valueOf(DEVICE_IPV6), IPV6_DEVICE_PORT);
device1 = new TestNetconfDevice(deviceInfo1);
deviceId1 = deviceInfo1.getDeviceId();
@@ -102,9 +114,9 @@
reflectedDownListener = (NetconfDeviceOutputEventListener) field2.get(ctrl);
eventForDeviceInfo1 = new NetconfDeviceOutputEvent(NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION, null,
- null, Optional.of(1), deviceInfo1);
+ null, Optional.of(1), deviceInfo1);
eventForDeviceInfo2 = new NetconfDeviceOutputEvent(NetconfDeviceOutputEvent.Type.DEVICE_UNREGISTERED, null,
- null, Optional.of(2), deviceInfo2);
+ null, Optional.of(2), deviceInfo2);
}
@After
@@ -128,7 +140,7 @@
ctrl.addDeviceListener(deviceListener3);
assertThat("Incorrect number of listeners", ctrl.netconfDeviceListeners, hasSize(3));
assertThat("Not matching listeners", ctrl.netconfDeviceListeners, hasItems(deviceListener1,
- deviceListener2, deviceListener3));
+ deviceListener2, deviceListener3));
ctrl.removeDeviceListener(deviceListener1);
assertThat("Incorrect number of listeners", ctrl.netconfDeviceListeners, hasSize(2));
@@ -168,7 +180,7 @@
public void testConnectBadDevice() throws Exception {
reflectedDeviceMap.clear();
try {
- ctrl.connectDevice(badDeviceInfo3);
+ ctrl.connectDevice(badDeviceInfo3.getDeviceId());
} finally {
assertEquals("Incorrect device connection", 0, ctrl.getDevicesMap().size());
}
@@ -180,25 +192,37 @@
@Test
public void testConnectCorrectDevice() throws Exception {
reflectedDeviceMap.clear();
- ctrl.connectDevice(deviceInfo1);
- ctrl.connectDevice(deviceInfo2);
+ ctrl.connectDevice(deviceInfo1.getDeviceId());
+ ctrl.connectDevice(deviceInfo2.getDeviceId());
assertTrue("Incorrect device connection", ctrl.getDevicesMap().containsKey(deviceId1));
assertTrue("Incorrect device connection", ctrl.getDevicesMap().containsKey(deviceId2));
assertEquals("Incorrect device connection", 2, ctrl.getDevicesMap().size());
}
+ /**
+ * Check for correct ipv6 device connection. In this case the device map get modified.
+ */
+ @Test
+ public void testConnectCorrectIpv6Device() throws Exception {
+ reflectedDeviceMap.clear();
+ ctrl.connectDevice(deviceInfoIpV6.getDeviceId());
+ assertTrue("Incorrect device connection", ctrl.getDevicesMap()
+ .containsKey(deviceInfoIpV6.getDeviceId()));
+ assertEquals("Incorrect device connection", 1, ctrl.getDevicesMap().size());
+ }
+
/**
* Check for connect devices already added to the map.
*/
@Test
public void testConnectAlreadyExistingDevice() throws Exception {
- NetconfDevice alreadyExistingDevice1 = ctrl.connectDevice(deviceInfo1);
- NetconfDevice alreadyExistingDevice2 = ctrl.connectDevice(deviceInfo2);
+ NetconfDevice alreadyExistingDevice1 = ctrl.connectDevice(deviceInfo1.getDeviceId());
+ NetconfDevice alreadyExistingDevice2 = ctrl.connectDevice(deviceInfo2.getDeviceId());
assertEquals("Incorrect device connection", alreadyExistingDevice1.getDeviceInfo().getDeviceId(),
- deviceInfo1.getDeviceId());
+ deviceInfo1.getDeviceId());
assertEquals("Incorrect device connection", alreadyExistingDevice2.getDeviceInfo().getDeviceId(),
- deviceInfo2.getDeviceId());
+ deviceInfo2.getDeviceId());
}
/**
@@ -206,7 +230,7 @@
*/
@Test
public void testDisconnectDevice() throws Exception {
- ctrl.disconnectDevice(deviceInfo1);
+ ctrl.disconnectDevice(deviceInfo1.getDeviceId(), true);
assertFalse("Incorrect device removal", ctrl.getDevicesMap().containsKey(deviceId1));
}
@@ -215,7 +239,7 @@
*/
@Test
public void testRemoveDevice() throws Exception {
- ctrl.removeDevice(deviceInfo1);
+ ctrl.removeDevice(deviceInfo1.getDeviceId());
assertFalse("Incorrect device removal", ctrl.getDevicesMap().containsKey(deviceId1));
}
@@ -234,13 +258,13 @@
@Test
public void testDeviceDownEventListener() throws Exception {
reflectedDeviceMap.clear();
- ctrl.connectDevice(deviceInfo1);
+ ctrl.connectDevice(deviceInfo1.getDeviceId());
boolean result1 = reflectedDownListener.isRelevant(eventForDeviceInfo2);
assertFalse("Irrelevant Device Event", result1);
assertEquals("Incorrect device map size", 1, ctrl.getDevicesMap().size());
reflectedDownListener.event(eventForDeviceInfo1);
assertEquals("Incorrect device map size", 1, ctrl.getDevicesMap().size());
- ctrl.connectDevice(deviceInfo2);
+ ctrl.connectDevice(deviceInfo2.getDeviceId());
boolean result2 = reflectedDownListener.isRelevant(eventForDeviceInfo2);
assertTrue("Irrelevant Device Event", result2);
assertEquals("Incorrect device map size", 2, ctrl.getDevicesMap().size());
@@ -269,7 +293,7 @@
public TestNetconfDevice(NetconfDeviceInfo deviceInfo) throws NetconfException {
netconfDeviceInfo = deviceInfo;
- if (netconfDeviceInfo.ip() != badDeviceInfo3.ip()) {
+ if (!badDeviceInfo3.getDeviceId().equals(deviceInfo.getDeviceId())) {
netconfSession = EasyMock.createMock(NetconfSession.class);
deviceState = true;
} else {
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceKeyServiceMock.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceKeyServiceMock.java
new file mode 100644
index 0000000..ace87fb
--- /dev/null
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceKeyServiceMock.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.netconf.ctl;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.key.DeviceKey;
+import org.onosproject.net.key.DeviceKeyId;
+import org.onosproject.net.key.DeviceKeyListener;
+import org.onosproject.net.key.DeviceKeyService;
+import org.onosproject.netconf.NetconfDeviceInfo;
+
+import java.util.Collection;
+
+/**
+ * Mock DeviceKey service to return device keys.
+ */
+class NetconfDeviceKeyServiceMock implements DeviceKeyService {
+
+ private static final String DEVICE_1_IP = "10.10.10.11";
+ private static final String DEVICE_2_IP = "10.10.10.12";
+ private static final String BAD_DEVICE_IP = "10.10.10.13";
+ private static final String DEVICE_IPV6 = "2001:db8::1";
+
+ private static final int DEVICE_1_PORT = 11;
+ private static final int DEVICE_2_PORT = 12;
+ private static final int BAD_DEVICE_PORT = 13;
+ private static final int IPV6_DEVICE_PORT = 14;
+
+ //DeviceInfo
+ private NetconfDeviceInfo deviceInfo1 =
+ new NetconfDeviceInfo("device1", "001", IpAddress.valueOf(DEVICE_1_IP),
+ DEVICE_1_PORT);
+ private NetconfDeviceInfo deviceInfo2 =
+ new NetconfDeviceInfo("device2", "002", IpAddress.valueOf(DEVICE_2_IP),
+ DEVICE_2_PORT);
+ private NetconfDeviceInfo badDeviceInfo3 =
+ new NetconfDeviceInfo("device3", "003", IpAddress.valueOf(BAD_DEVICE_IP),
+ BAD_DEVICE_PORT);
+ private NetconfDeviceInfo deviceInfoIpV6 =
+ new NetconfDeviceInfo("deviceIpv6", "004", IpAddress.valueOf(DEVICE_IPV6), IPV6_DEVICE_PORT);
+
+ @Override
+ public Collection<DeviceKey> getDeviceKeys() {
+ return null;
+ }
+
+ @Override
+ public DeviceKey getDeviceKey(DeviceKeyId deviceKeyId) {
+ if (deviceKeyId.toString().equals(deviceInfo1.getDeviceId().toString())) {
+ return DeviceKey.createDeviceKeyUsingUsernamePassword(
+ DeviceKeyId.deviceKeyId(deviceInfo1.getDeviceId().toString()),
+ null, deviceInfo1.name(), deviceInfo1.password());
+ } else if (deviceKeyId.toString().equals(deviceInfo2.getDeviceId().toString())) {
+ return DeviceKey.createDeviceKeyUsingUsernamePassword(
+ DeviceKeyId.deviceKeyId(deviceInfo2.getDeviceId().toString()),
+ null, deviceInfo2.name(), deviceInfo2.password());
+ } else if (deviceKeyId.toString().equals(badDeviceInfo3.getDeviceId().toString())) {
+ return DeviceKey.createDeviceKeyUsingUsernamePassword(
+ DeviceKeyId.deviceKeyId(badDeviceInfo3.getDeviceId().toString()),
+ null, badDeviceInfo3.name(), badDeviceInfo3.password());
+ } else if (deviceKeyId.toString().equals(deviceInfoIpV6.getDeviceId().toString())) {
+ return DeviceKey.createDeviceKeyUsingUsernamePassword(
+ DeviceKeyId.deviceKeyId(deviceInfoIpV6.getDeviceId().toString()),
+ null, deviceInfoIpV6.name(), deviceInfoIpV6.password());
+ }
+ return null;
+ }
+
+ @Override
+ public void addListener(DeviceKeyListener listener) {
+
+ }
+
+ @Override
+ public void removeListener(DeviceKeyListener listener) {
+
+ }
+}
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceServiceMock.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceServiceMock.java
new file mode 100644
index 0000000..e355bbd
--- /dev/null
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceServiceMock.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.netconf.ctl;
+
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortStatistics;
+
+import java.util.List;
+
+/**
+ * Mock device Service.
+ */
+class NetconfDeviceServiceMock implements DeviceService {
+
+ @Override
+ public int getDeviceCount() {
+ return 0;
+ }
+
+ @Override
+ public Iterable<Device> getDevices() {
+ return null;
+ }
+
+ @Override
+ public Iterable<Device> getDevices(Device.Type type) {
+ return null;
+ }
+
+ @Override
+ public Iterable<Device> getAvailableDevices() {
+ return null;
+ }
+
+ @Override
+ public Iterable<Device> getAvailableDevices(Device.Type type) {
+ return null;
+ }
+
+ @Override
+ public Device getDevice(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public MastershipRole getRole(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public List<Port> getPorts(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public Port getPort(DeviceId deviceId, PortNumber portNumber) {
+ return null;
+ }
+
+ @Override
+ public boolean isAvailable(DeviceId deviceId) {
+ return false;
+ }
+
+ @Override
+ public void addListener(DeviceListener listener) {
+
+ }
+
+ @Override
+ public void removeListener(DeviceListener listener) {
+
+ }
+}
\ No newline at end of file