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


Java ConfigException类代码示例

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


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

示例1: getDevicesAddresses

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
public Set<NetconfDeviceAddress> getDevicesAddresses() throws ConfigException {
    Set<NetconfDeviceAddress> devicesAddresses = Sets.newHashSet();

    try {
        for (JsonNode node : array) {
            String ip = node.path(IP).asText();
            IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
            int port = node.path(PORT).asInt(DEFAULT_TCP_PORT);
            String name = node.path(NAME).asText();
            String password = node.path(PASSWORD).asText();
            devicesAddresses.add(new NetconfDeviceAddress(ipAddr, port, name, password));

        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }

    return devicesAddresses;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:NetconfProviderConfig.java

示例2: getDevicesAddresses

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
public Set<RestSBDevice> getDevicesAddresses() throws ConfigException {
    Set<RestSBDevice> devicesAddresses = Sets.newHashSet();

    try {
        for (JsonNode node : array) {
            String ip = node.path(IP).asText();
            IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
            int port = node.path(PORT).asInt(DEFAULT_HTTP_PORT);
            String username = node.path(USERNAME).asText();
            String password = node.path(PASSWORD).asText();
            String protocol = node.path(PROTOCOL).asText();
            String url = node.path(URL).asText();
            devicesAddresses.add(new DefaultRestSBDevice(ipAddr, port, username,
                                                         password, protocol,
                                                         url, false));

        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }

    return devicesAddresses;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:RestProviderConfig.java

示例3: getDevicesInfo

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
/**
 * Retrieves a set of SnmpDeviceInfo containing all the device
 * configuration pertaining to the SNMP device provider.
 * @return set of device configurations.
 *
 * @throws ConfigException if configuration can't be read
 */
public Set<SnmpDeviceInfo> getDevicesInfo() throws ConfigException {
    Set<SnmpDeviceInfo> deviceInfos = Sets.newHashSet();

    try {
        for (JsonNode node : array) {
            String ip = node.path(IP).asText();
            IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
            int port = node.path(PORT).asInt(DEFAULT_TCP_PORT);
            String name = node.path(NAME).asText();
            String password = node.path(PASSWORD).asText();
            deviceInfos.add(new SnmpDeviceInfo(ipAddr, port, name, password));

        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }

    return deviceInfos;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:SnmpProviderConfig.java

示例4: getDevicesInfo

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
/**
 * Retrieves a set of Bmv2DeviceInfo containing all the device
 * configuration pertaining to the Bmv2 device provider.
 *
 * @return set of device configurations.
 * @throws ConfigException if configuration can't be read
 */
public Set<Bmv2DeviceInfo> getDevicesInfo() throws ConfigException {
    Set<Bmv2DeviceInfo> deviceInfos = Sets.newHashSet();

    try {
        for (JsonNode node : array) {
            String ip = node.path(IP).asText();
            IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
            int port = node.path(PORT).asInt(DEFAULT_THRIFT_PORT);
            deviceInfos.add(new Bmv2DeviceInfo(ipAddr, port));

        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }

    return deviceInfos;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:Bmv2ProviderConfig.java

示例5: remove

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
@Override
public boolean remove(ConnectPoint connectPoint, String name) {
    InterfaceConfig config = configService.addConfig(connectPoint, CONFIG_CLASS);
    config.removeInterface(name);

    try {
        if (config.getInterfaces().isEmpty()) {
            configService.removeConfig(connectPoint, CONFIG_CLASS);
        } else {
            configService.applyConfig(connectPoint, CONFIG_CLASS, config.node());
        }
    } catch (ConfigException e) {
        log.error("Error reading interfaces JSON", e);
        return false;
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:InterfaceManager.java

示例6: getDevicesAddresses

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
/**
 * Returns the device addresses from JSON.
 *
 * @return A set of RESTCONF Server devices
 * @throws ConfigException if there is a configuration error
 */
public Set<RestSBDevice> getDevicesAddresses() throws ConfigException {
    Set<RestSBDevice> devicesAddresses = Sets.newHashSet();

    try {
        for (JsonNode node : array) {
            String ip = node.path(IP).asText();
            IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
            int port = node.path(PORT).asInt(DEFAULT_HTTP_PORT);
            String username = node.path(USERNAME).asText();
            String password = node.path(PASSWORD).asText();
            String protocol = node.path(PROTOCOL).asText();
            String url = node.path(URL).asText();
            devicesAddresses.add(new DefaultRestSBDevice(ipAddr, port, username,
                                                         password, protocol,
                                                         url, false));

        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }

    return devicesAddresses;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:30,代码来源:RestconfServerConfig.java

示例7: connectDevices

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
private void connectDevices() {
    NetconfProviderConfig cfg = cfgService.getConfig(appId, NetconfProviderConfig.class);
    if (cfg != null) {
        try {
            cfg.getDevicesAddresses().stream().forEach(addr -> {
                DeviceId deviceId = getDeviceId(addr.ip().toString(), addr.port());
                Preconditions.checkNotNull(deviceId, ISNULL);
                //Netconf configuration object
                ChassisId cid = new ChassisId();
                String ipAddress = addr.ip().toString();
                SparseAnnotations annotations = DefaultAnnotations.builder()
                        .set(IPADDRESS, ipAddress)
                        .set(PORT, String.valueOf(addr.port()))
                        .set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase())
                        .build();
                DeviceDescription deviceDescription = new DefaultDeviceDescription(
                        deviceId.uri(),
                        Device.Type.SWITCH,
                        UNKNOWN, UNKNOWN,
                        UNKNOWN, UNKNOWN,
                        cid,
                        annotations);
                deviceKeyAdminService.addKey(
                        DeviceKey.createDeviceKeyUsingUsernamePassword(
                                DeviceKeyId.deviceKeyId(deviceId.toString()),
                                null, addr.name(), addr.password()));
                providerService.deviceConnected(deviceId, deviceDescription);


            });
        } catch (ConfigException e) {
            log.error("Cannot read config error " + e);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:NetconfDeviceProvider.java

示例8: connectDevices

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
private void connectDevices() {
    RestProviderConfig cfg = cfgService.getConfig(appId, RestProviderConfig.class);
    try {
        if (cfg != null && cfg.getDevicesAddresses() != null) {
            //Precomputing the devices to be removed
            Set<RestSBDevice> toBeRemoved = new HashSet<>(controller.getDevices().values());
            toBeRemoved.removeAll(cfg.getDevicesAddresses());
            //Adding new devices
            cfg.getDevicesAddresses().stream()
                    .filter(device -> {
                        device.setActive(false);
                        controller.addDevice(device);
                        return testDeviceConnection(device);
                    })
                    .forEach(device -> {
                        deviceAdded(device);
                    });
            //Removing devices not wanted anymore
            toBeRemoved.stream().forEach(device -> deviceRemoved(device.deviceId()));

        }
    } catch (ConfigException e) {
        log.error("Configuration error {}", e);
    }
    log.debug("REST Devices {}", controller.getDevices());
    addedDevices.forEach(deviceId -> {
        DriverHandler h = driverService.createHandler(deviceId);
        PortDiscovery portConfig = h.behaviour(PortDiscovery.class);
        if (portConfig != null) {
            providerService.updatePorts(deviceId, portConfig.getPorts());
        } else {
            log.warn("No portGetter behaviour for device {}", deviceId);
        }
    });
    addedDevices.clear();

}
 
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:RestDeviceProvider.java

示例9: addOrRemoveDevicesConfig

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
private void addOrRemoveDevicesConfig() {
    SnmpProviderConfig cfg = netCfgService.getConfig(appId, SnmpProviderConfig.class);
    if (cfg != null) {
        try {
            cfg.getDevicesInfo().stream().forEach(info -> {
                SnmpDevice device = new DefaultSnmpDevice(info.ip().toString(),
                                                          info.port(), info.username(), info.password());
                buildDevice(device);
            });
        } catch (ConfigException e) {
            log.error("Cannot read config error " + e);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:SnmpDeviceProvider.java

示例10: connectDevices

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
private void connectDevices() {

        RestconfServerConfig cfg = cfgService.getConfig(appId,
                                                        RestconfServerConfig.class);
        try {
            if (cfg != null && cfg.getDevicesAddresses() != null) {
                //Precomputing the devices to be removed
                Set<RestSBDevice> toBeRemoved = new HashSet<>(restconfClient.
                        getDevices().values());
                toBeRemoved.removeAll(cfg.getDevicesAddresses());
                //Adding new devices
                for (RestSBDevice device : cfg.getDevicesAddresses()) {
                    device.setActive(false);
                    restconfClient.addDevice(device);
                    deviceAdded(device);
                }

                //Removing devices not wanted anymore
                toBeRemoved.forEach(device -> deviceRemoved(device.deviceId()));
            }
        } catch (ConfigException e) {
            log.error("Configuration error {}", e);
        }

        // Discover the topology from RESTCONF server
        addedDevices.forEach(this::retrieveTopology);
        addedDevices.clear();
    }
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:29,代码来源:TeTopologyRestconfProvider.java

示例11: getDevicesInfo

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
@Override
public Set<SnmpProviderConfig.SnmpDeviceInfo> getDevicesInfo() throws ConfigException {
    return ImmutableSet.of(deviceInfo);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:SnmpDeviceProviderTest.java

示例12: getInterfaces

import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
@Override
public Set<Interface> getInterfaces() throws ConfigException {
    return interfaces;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:InterfaceManagerTest.java


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