blob: 3141aafc9802487664893d2321befb38789971ff [file] [log] [blame]
andreaeb70a942015-10-16 21:34:46 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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
17package org.onosproject.netconf.ctl;
18
19import org.onosproject.netconf.NetconfDevice;
20import org.onosproject.netconf.NetconfDeviceInfo;
21import org.onosproject.netconf.NetconfSession;
22
23import java.io.IOException;
24
25/**
26 * Implementation of a NETCONF device.
27 */
28public class NetconfDeviceImpl implements NetconfDevice {
29
30 private NetconfDeviceInfo netconfDeviceInfo;
31 private boolean deviceState = false;
32 private NetconfSession netconfSession;
33 //private String config;
34
35 public NetconfDeviceImpl(NetconfDeviceInfo deviceInfo) throws IOException {
36 netconfDeviceInfo = deviceInfo;
37 try {
38 netconfSession = new NetconfSessionImpl(netconfDeviceInfo);
39 } catch (IOException e) {
40 throw new IOException("Cannot create connection and session", e);
41 }
42 deviceState = true;
43 //config = netconfSession.getConfig("running");
44 }
45
46 @Override
47 public boolean isActive() {
48 return deviceState;
49 }
50
51 @Override
52 public NetconfSession getSession() {
53 return netconfSession;
54 }
55
56 @Override
57 public void disconnect() {
58 deviceState = false;
59 netconfSession.close();
60 }
61
62 @Override
63 public NetconfDeviceInfo getDeviceInfo() {
64 return netconfDeviceInfo;
65 }
66}