use of org.onosproject.net.config.ConfigException in project onos by opennetworkinglab.
the class InterfaceManager method remove.
@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;
}
use of org.onosproject.net.config.ConfigException in project onos by opennetworkinglab.
the class InterfaceConfig method getInterfaces.
/**
* Retrieves all interfaces configured on this port.
*
* @return set of interfaces
* @throws ConfigException if there is any error in the JSON config
*/
public Set<Interface> getInterfaces() throws ConfigException {
Set<Interface> interfaces = Sets.newHashSet();
try {
for (JsonNode intfNode : array) {
String name = intfNode.path(NAME).asText(null);
List<InterfaceIpAddress> ips = getIps(intfNode);
String mac = intfNode.path(MAC).asText();
MacAddress macAddr = mac.isEmpty() ? null : MacAddress.valueOf(mac);
VlanId vlan = getVlan(intfNode, VLAN);
VlanId vlanUntagged = getVlan(intfNode, VLAN_UNTAGGED);
Set<VlanId> vlanTagged = getVlans(intfNode, VLAN_TAGGED);
VlanId vlanNative = getVlan(intfNode, VLAN_NATIVE);
interfaces.add(new Interface(name, subject, ips, macAddr, vlan, vlanUntagged, vlanTagged, vlanNative));
}
} catch (IllegalArgumentException e) {
throw new ConfigException(CONFIG_VALUE_ERROR, e);
}
return interfaces;
}
Aggregations