Search in sources :

Example 1 with ConfigException

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;
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) ConfigException(org.onosproject.net.config.ConfigException)

Example 2 with ConfigException

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;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ConfigException(org.onosproject.net.config.ConfigException) MacAddress(org.onlab.packet.MacAddress) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId)

Aggregations

ConfigException (org.onosproject.net.config.ConfigException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 MacAddress (org.onlab.packet.MacAddress)1 VlanId (org.onlab.packet.VlanId)1 InterfaceConfig (org.onosproject.net.config.basics.InterfaceConfig)1 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)1 Interface (org.onosproject.net.intf.Interface)1