本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
}
示例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();
}
示例11: getDevicesInfo
import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
@Override
public Set<SnmpProviderConfig.SnmpDeviceInfo> getDevicesInfo() throws ConfigException {
return ImmutableSet.of(deviceInfo);
}
示例12: getInterfaces
import org.onosproject.incubator.net.config.basics.ConfigException; //导入依赖的package包/类
@Override
public Set<Interface> getInterfaces() throws ConfigException {
return interfaces;
}