当前位置: 首页>>代码示例>>Java>>正文


Java NetconfDevice类代码示例

本文整理汇总了Java中org.onosproject.netconf.NetconfDevice的典型用法代码示例。如果您正苦于以下问题:Java NetconfDevice类的具体用法?Java NetconfDevice怎么用?Java NetconfDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetconfDevice类属于org.onosproject.netconf包,在下文中一共展示了NetconfDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Override
public NetconfDevice connectDevice(DeviceId deviceId) throws NetconfException {
    NetconfDevice mockNetconfDevice = null;

    String[] nameParts = deviceId.uri().toASCIIString().split(":");
    IpAddress ipAddress = Ip4Address.valueOf(nameParts[1]);
    int port = Integer.parseInt(nameParts[2]);
    NetconfDeviceInfo ncdi = new NetconfDeviceInfo("mock", "mock", ipAddress, port);
    try {
        mockNetconfDevice = (new MockNetconfDeviceFactory()).createNetconfDevice(ncdi);
        devicesMap.put(deviceId, mockNetconfDevice);
    } catch (NetconfException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return mockNetconfDevice;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:MockNetconfController.java

示例2: setControllers

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Override
public void setControllers(List<ControllerInfo> controllers) {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId ncdeviceId = handler.data().deviceId();
    checkNotNull(controller, "Netconf controller is null");
    if (mastershipService.isLocalMaster(ncdeviceId)) {
        try {
            NetconfDevice device = controller.getNetconfDevice(ncdeviceId);
            String config = createVoltControllersConfig(
                    XmlConfigParser.loadXml(getClass().
                            getResourceAsStream(RESOURCE_XML)),
                    RUNNING, MERGE, controllers);
            device.getSession().editConfig(config.substring(
                    config.indexOf(END_LICENSE_HEADER) + END_LICENSE_HEADER.length()));
        } catch (NetconfException e) {
            log.error("Cannot communicate to device {} , exception {}", ncdeviceId, e);
        }
    } else {
        log.warn("I'm not master for {} please use master, {} to execute command",
                 ncdeviceId,
                 mastershipService.getMasterFor(ncdeviceId));
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:FujitsuVoltControllerConfig.java

示例3: testConnectDeviceNetConfig10

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
/**
 * Check for connection by netconfDeviceConfig.
 */
@Test
public void testConnectDeviceNetConfig10() throws Exception {
    NetconfDevice fetchedDevice10 = ctrl.connectDevice(deviceConfig10Id);
    assertEquals("Incorrect device fetched - ip",
            fetchedDevice10.getDeviceInfo().ip().toString(), DEVICE_10_IP);
    assertEquals("Incorrect device fetched - port",
            fetchedDevice10.getDeviceInfo().port(), DEVICE_10_PORT);
    assertEquals("Incorrect device fetched - username",
            fetchedDevice10.getDeviceInfo().name(), DEVICE_10_USERNAME);
    assertEquals("Incorrect device fetched - password",
            fetchedDevice10.getDeviceInfo().password(), DEVICE_10_PASSWORD);
    assertEquals("Incorrect device fetched - connectTimeout",
            fetchedDevice10.getDeviceInfo().getConnectTimeoutSec().getAsInt(),
            DEVICE_10_CONNECT_TIMEOUT);
    assertEquals("Incorrect device fetched - replyTimeout",
            fetchedDevice10.getDeviceInfo().getReplyTimeoutSec().getAsInt(),
            DEVICE_10_REPLY_TIMEOUT);
    assertEquals("Incorrect device fetched - idleTimeout",
            fetchedDevice10.getDeviceInfo().getIdleTimeoutSec().getAsInt(),
            DEVICE_10_IDLE_TIMEOUT);
    assertEquals("Incorrect device fetched - sshClient",
            fetchedDevice10.getDeviceInfo().sshClientLib().get(),
            NetconfSshClientLib.ETHZ_SSH2);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:28,代码来源:NetconfControllerImplTest.java

示例4: getNetconfDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Override
public NetconfDevice getNetconfDevice(IpAddress ip, int port) {
    for (DeviceId info : netconfDeviceMap.keySet()) {
        if (info.uri().getSchemeSpecificPart().equals(ip.toString() + ":" + port)) {
            return netconfDeviceMap.get(info);
        }
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:NetconfControllerImpl.java

示例5: createDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
private NetconfDevice createDevice(NetconfDeviceInfo deviceInfo) throws NetconfException {
    NetconfDevice netconfDevice = deviceFactory.createNetconfDevice(deviceInfo);
    netconfDeviceMap.put(deviceInfo.getDeviceId(), netconfDevice);
    for (NetconfDeviceListener l : netconfDeviceListeners) {
        l.deviceAdded(deviceInfo.getDeviceId());
    }
    return netconfDevice;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:NetconfControllerImpl.java

示例6: setUp

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    ctrl = new NetconfControllerImpl();
    ctrl.deviceFactory = new TestNetconfDeviceFactory();
    ctrl.cfgService = cfgService;
    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();
    device2 = new TestNetconfDevice(deviceInfo2);
    deviceId2 = deviceInfo2.getDeviceId();

    //Adding to the map for testing get device calls.
    Field field1 = ctrl.getClass().getDeclaredField("netconfDeviceMap");
    field1.setAccessible(true);
    reflectedDeviceMap = (Map<DeviceId, NetconfDevice>) field1.get(ctrl);
    reflectedDeviceMap.put(deviceId1, device1);
    reflectedDeviceMap.put(deviceId2, device2);

    //Creating mock events for testing NetconfDeviceOutputEventListener
    Field field2 = ctrl.getClass().getDeclaredField("downListener");
    field2.setAccessible(true);
    reflectedDownListener = (NetconfDeviceOutputEventListener) field2.get(ctrl);

    eventForDeviceInfo1 = new NetconfDeviceOutputEvent(NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION, null,
                                                       null, Optional.of(1), deviceInfo1);
    eventForDeviceInfo2 = new NetconfDeviceOutputEvent(NetconfDeviceOutputEvent.Type.DEVICE_UNREGISTERED, null,
                                                       null, Optional.of(2), deviceInfo2);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:NetconfControllerImplTest.java

示例7: testGetNetconfDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Test
public void testGetNetconfDevice() {
    NetconfDevice fetchedDevice1 = ctrl.getNetconfDevice(deviceId1);
    assertThat("Incorrect device fetched", fetchedDevice1, is(device1));

    NetconfDevice fetchedDevice2 = ctrl.getNetconfDevice(deviceId2);
    assertThat("Incorrect device fetched", fetchedDevice2, is(device2));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:NetconfControllerImplTest.java

示例8: testGetNetconfDeviceWithIPPort

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Test
public void testGetNetconfDeviceWithIPPort() {
    NetconfDevice fetchedDevice1 = ctrl.getNetconfDevice(IpAddress.valueOf(DEVICE_1_IP), DEVICE_1_PORT);
    assertEquals("Incorrect device fetched", fetchedDevice1.getDeviceInfo().ip(), device1.getDeviceInfo().ip());

    NetconfDevice fetchedDevice2 = ctrl.getNetconfDevice(IpAddress.valueOf(DEVICE_2_IP), DEVICE_2_PORT);
    assertEquals("Incorrect device fetched", fetchedDevice2.getDeviceInfo().ip(), device2.getDeviceInfo().ip());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:NetconfControllerImplTest.java

示例9: testConnectAlreadyExistingDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
/**
 * Check for connect devices already added to the map.
 */
@Test
public void testConnectAlreadyExistingDevice() throws Exception {
    NetconfDevice alreadyExistingDevice1 = ctrl.connectDevice(deviceInfo1.getDeviceId());
    NetconfDevice alreadyExistingDevice2 = ctrl.connectDevice(deviceInfo2.getDeviceId());
    assertEquals("Incorrect device connection", alreadyExistingDevice1.getDeviceInfo().getDeviceId(),
                 deviceInfo1.getDeviceId());
    assertEquals("Incorrect device connection", alreadyExistingDevice2.getDeviceInfo().getDeviceId(),
                 deviceInfo2.getDeviceId());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:NetconfControllerImplTest.java

示例10: connectDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Override
public NetconfDevice connectDevice(DeviceId deviceId) throws NetconfException {
    if (netconfDeviceMap.containsKey(deviceId)) {
        log.debug("Device {} is already present", deviceId);
        return netconfDeviceMap.get(deviceId);
    } else {
        log.debug("Creating NETCONF device {}", deviceId);
        String ip;
        int port;
        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 {
            NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo(
                                           VOLT_DEVICE_USERNAME,
                                           VOLT_DEVICE_PASSWORD,
                                           IpAddress.valueOf(ip),
                                           port);
            NetconfDevice netconfDevice = new FujitsuNetconfDeviceMock(deviceInfo);
            netconfDeviceMap.put(deviceInfo.getDeviceId(), netconfDevice);
            return netconfDevice;
        } catch (NullPointerException e) {
            throw new NetconfException("Cannot connect a device " + deviceId, e);
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:36,代码来源:FujitsuNetconfControllerMock.java

示例11: setUp

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
/**
 * Sets up initial test environment.
 *
 * @param listener listener to be added
 * @return driver handler
 * @throws NetconfException when there is a problem
 */
public FujitsuDriverHandlerAdapter setUp(FujitsuNetconfSessionListenerTest listener) throws NetconfException {
    try {
        NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo(
                VOLT_DEVICE_USERNAME, VOLT_DEVICE_PASSWORD,
                IpAddress.valueOf(VOLT_DEVICE_IP), VOLT_DEVICE_PORT);

        NetconfDevice netconfDevice = connectDevice(deviceInfo.getDeviceId());

        FujitsuNetconfSessionMock session = (FujitsuNetconfSessionMock) netconfDevice.getSession();
        session.setListener(listener);

        DeviceId deviceId = deviceInfo.getDeviceId();
        DefaultDriver driver = new DefaultDriver(
                VOLT_DRIVER_NAME, new ArrayList<>(),
                "Fujitsu", "1.0", "1.0",
                ImmutableMap.of(), ImmutableMap.of());

        DefaultDriverData driverData = new DefaultDriverData(driver, deviceId);

        FujitsuDriverHandlerAdapter driverHandler;
        driverHandler = new FujitsuDriverHandlerAdapter(driverData);
        driverHandler.setUp(this);

        return driverHandler;
    } catch (NetconfException e) {
        throw new NetconfException("Cannot create a device ", e);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:36,代码来源:FujitsuNetconfControllerMock.java

示例12: createNetconfDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Override
public NetconfDevice createNetconfDevice(NetconfDeviceInfo netconfDeviceInfo)
        throws NetconfException {
    if (NetconfSshClientLib.ETHZ_SSH2.equals(netconfDeviceInfo.sshClientLib().orElse(null)) ||
            NetconfSshClientLib.ETHZ_SSH2.equals(sshLibrary)) {
        log.info("Creating NETCONF session to {} with {}",
                    netconfDeviceInfo.name(), NetconfSshClientLib.ETHZ_SSH2);
        return new DefaultNetconfDevice(netconfDeviceInfo,
                    new NetconfSessionImpl.SshNetconfSessionFactory());
    }
    log.info("Creating NETCONF session to {} with {}",
            netconfDeviceInfo.getDeviceId(), NetconfSshClientLib.APACHE_MINA);
    return new DefaultNetconfDevice(netconfDeviceInfo);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:15,代码来源:NetconfControllerImpl.java

示例13: execute

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Override
protected void execute() {
    deviceId = DeviceId.deviceId(uri);

    NetconfController controller = get(NetconfController.class);
    checkNotNull(controller, "Netconf controller is null");

    NetconfDevice device = controller.getDevicesMap().get(deviceId);
    if (device == null) {
        print("Netconf device object not found for %s", deviceId);
        return;
    }

    NetconfSession session = device.getSession();
    if (session == null) {
        print("Netconf session not found for %s", deviceId);
        return;
    }

    try {
        String res = session.getConfig(datastore(cfgType.toLowerCase()));
        print("%s", res);
    } catch (NetconfException e) {
        log.error("Configuration could not be retrieved", e);
        print("Error occurred retrieving configuration");
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:28,代码来源:NetconfConfigGetCommand.java

示例14: testConnectCorrectDevice

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
/**
 * Check for correct device connection. In this case the device map get modified.
 */
@Test
public void testConnectCorrectDevice() throws Exception {
    reflectedDeviceMap.clear();
    NetconfDevice device1 = ctrl.connectDevice(deviceInfo1.getDeviceId());
    NetconfDevice device2 = 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());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:13,代码来源:NetconfControllerImplTest.java

示例15: activate

import org.onosproject.netconf.NetconfDevice; //导入依赖的package包/类
@Activate
public void activate() {
    providerService = providerRegistry.register(this);
    controller.getNetconfDevices().forEach(id -> {
        NetconfDevice device = controller.getNetconfDevice(id);
        NetconfSession session = device.getSession();
        InternalNotificationListener listener = new InternalNotificationListener(device.getDeviceInfo());
        session.addDeviceOutputListener(listener);
        idNotificationListenerMap.put(id, listener);
    });
    controller.addDeviceListener(deviceListener);
    log.info("NetconfAlarmProvider Started");
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:14,代码来源:NetconfAlarmProvider.java


注:本文中的org.onosproject.netconf.NetconfDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。