diff options
author | CNlucius <lukai1@huawei.com> | 2016-09-13 11:40:12 +0800 |
---|---|---|
committer | CNlucius <lukai1@huawei.com> | 2016-09-13 11:41:53 +0800 |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config')
5 files changed, 0 insertions, 806 deletions
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfigNotFoundException.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfigNotFoundException.java deleted file mode 100644 index ae156e60..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfigNotFoundException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onosproject.segmentrouting.config; - -/** - * Signals that an error occurred during reading device configuration. - */ -public class DeviceConfigNotFoundException extends Exception { - - /** - * Creates a new ConfigNotFoundException with the given message. - * - * @param message exception message - */ - public DeviceConfigNotFoundException(String message) { - super(message); - } -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java deleted file mode 100644 index dbac596d..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.config; - -import com.google.common.collect.ImmutableSet; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip4Prefix; -import org.onlab.packet.MacAddress; -import org.onosproject.incubator.net.config.basics.ConfigException; -import org.onosproject.incubator.net.config.basics.InterfaceConfig; -import org.onosproject.incubator.net.intf.Interface; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.config.NetworkConfigRegistry; -import org.onosproject.net.host.InterfaceIpAddress; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Segment Routing configuration component that reads the - * segment routing related configuration from Network Configuration Manager - * component and organizes in more accessible formats. - */ -public class DeviceConfiguration implements DeviceProperties { - - private static final Logger log = LoggerFactory - .getLogger(DeviceConfiguration.class); - private final List<Integer> allSegmentIds = new ArrayList<>(); - private final ConcurrentHashMap<DeviceId, SegmentRouterInfo> deviceConfigMap - = new ConcurrentHashMap<>(); - - private class SegmentRouterInfo { - int nodeSid; - DeviceId deviceId; - Ip4Address ip; - MacAddress mac; - boolean isEdge; - HashMap<PortNumber, Ip4Address> gatewayIps; - HashMap<PortNumber, Ip4Prefix> subnets; - Map<Integer, Set<Integer>> adjacencySids; - - public SegmentRouterInfo() { - this.gatewayIps = new HashMap<>(); - this.subnets = new HashMap<>(); - } - } - - /** - * Constructor. Reads all the configuration for all devices of type - * Segment Router and organizes into various maps for easier access. - * - * @param cfgService config service - */ - public DeviceConfiguration(NetworkConfigRegistry cfgService) { - // Read config from device subject, excluding gatewayIps and subnets. - Set<DeviceId> deviceSubjects = - cfgService.getSubjects(DeviceId.class, SegmentRoutingConfig.class); - deviceSubjects.forEach(subject -> { - SegmentRoutingConfig config = - cfgService.getConfig(subject, SegmentRoutingConfig.class); - SegmentRouterInfo info = new SegmentRouterInfo(); - info.deviceId = subject; - info.nodeSid = config.nodeSid(); - info.ip = config.routerIp(); - info.mac = config.routerMac(); - info.isEdge = config.isEdgeRouter(); - info.adjacencySids = config.adjacencySids(); - - this.deviceConfigMap.put(info.deviceId, info); - this.allSegmentIds.add(info.nodeSid); - }); - - // Read gatewayIps and subnets from port subject. - Set<ConnectPoint> portSubjects = - cfgService.getSubjects(ConnectPoint.class, InterfaceConfig.class); - portSubjects.forEach(subject -> { - InterfaceConfig config = - cfgService.getConfig(subject, InterfaceConfig.class); - Set<Interface> networkInterfaces; - try { - networkInterfaces = config.getInterfaces(); - } catch (ConfigException e) { - log.error("Error loading port configuration"); - return; - } - networkInterfaces.forEach(networkInterface -> { - DeviceId dpid = networkInterface.connectPoint().deviceId(); - PortNumber port = networkInterface.connectPoint().port(); - SegmentRouterInfo info = this.deviceConfigMap.get(dpid); - - // skip if there is no corresponding device for this ConenctPoint - if (info != null) { - Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses(); - interfaceAddresses.forEach(interfaceAddress -> { - info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address()); - info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix()); - }); - } - }); - - }); - } - - @Override - public boolean isConfigured(DeviceId deviceId) { - return deviceConfigMap.get(deviceId) != null; - } - - @Override - public int getSegmentId(DeviceId deviceId) throws DeviceConfigNotFoundException { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - log.trace("getSegmentId for device{} is {}", deviceId, srinfo.nodeSid); - return srinfo.nodeSid; - } else { - String message = "getSegmentId fails for device: " + deviceId + "."; - throw new DeviceConfigNotFoundException(message); - } - } - - /** - * Returns the Node segment id of a segment router given its Router mac address. - * - * @param routerMac router mac address - * @return node segment id, or -1 if not found in config - */ - public int getSegmentId(MacAddress routerMac) { - for (Map.Entry<DeviceId, SegmentRouterInfo> entry: - deviceConfigMap.entrySet()) { - if (entry.getValue().mac.equals(routerMac)) { - return entry.getValue().nodeSid; - } - } - - return -1; - } - - /** - * Returns the Node segment id of a segment router given its Router ip address. - * - * @param routerAddress router ip address - * @return node segment id, or -1 if not found in config - */ - public int getSegmentId(Ip4Address routerAddress) { - for (Map.Entry<DeviceId, SegmentRouterInfo> entry: - deviceConfigMap.entrySet()) { - if (entry.getValue().ip.equals(routerAddress)) { - return entry.getValue().nodeSid; - } - } - - return -1; - } - - @Override - public MacAddress getDeviceMac(DeviceId deviceId) throws DeviceConfigNotFoundException { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - log.trace("getDeviceMac for device{} is {}", deviceId, srinfo.mac); - return srinfo.mac; - } else { - String message = "getDeviceMac fails for device: " + deviceId + "."; - throw new DeviceConfigNotFoundException(message); - } - } - - @Override - public Ip4Address getRouterIp(DeviceId deviceId) throws DeviceConfigNotFoundException { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - log.trace("getDeviceIp for device{} is {}", deviceId, srinfo.ip); - return srinfo.ip; - } else { - String message = "getRouterIp fails for device: " + deviceId + "."; - throw new DeviceConfigNotFoundException(message); - } - } - - @Override - public boolean isEdgeDevice(DeviceId deviceId) throws DeviceConfigNotFoundException { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - log.trace("isEdgeDevice for device{} is {}", deviceId, srinfo.isEdge); - return srinfo.isEdge; - } else { - String message = "isEdgeDevice fails for device: " + deviceId + "."; - throw new DeviceConfigNotFoundException(message); - } - } - - @Override - public List<Integer> getAllDeviceSegmentIds() { - return allSegmentIds; - } - - @Override - public Map<Ip4Prefix, List<PortNumber>> getSubnetPortsMap(DeviceId deviceId) { - Map<Ip4Prefix, List<PortNumber>> subnetPortMap = new HashMap<>(); - - // Construct subnet-port mapping from port-subnet mapping - Map<PortNumber, Ip4Prefix> portSubnetMap = - this.deviceConfigMap.get(deviceId).subnets; - portSubnetMap.forEach((port, subnet) -> { - if (subnetPortMap.containsKey(subnet)) { - subnetPortMap.get(subnet).add(port); - } else { - ArrayList<PortNumber> ports = new ArrayList<>(); - ports.add(port); - subnetPortMap.put(subnet, ports); - } - }); - - return subnetPortMap; - } - - /** - * Returns the device identifier or data plane identifier (dpid) - * of a segment router given its segment id. - * - * @param sid segment id - * @return deviceId device identifier - */ - public DeviceId getDeviceId(int sid) { - for (Map.Entry<DeviceId, SegmentRouterInfo> entry: - deviceConfigMap.entrySet()) { - if (entry.getValue().nodeSid == sid) { - return entry.getValue().deviceId; - } - } - - return null; - } - - /** - * Returns the device identifier or data plane identifier (dpid) - * of a segment router given its router ip address. - * - * @param ipAddress router ip address - * @return deviceId device identifier - */ - public DeviceId getDeviceId(Ip4Address ipAddress) { - for (Map.Entry<DeviceId, SegmentRouterInfo> entry: - deviceConfigMap.entrySet()) { - if (entry.getValue().ip.equals(ipAddress)) { - return entry.getValue().deviceId; - } - } - - return null; - } - - /** - * Returns the configured port ip addresses for a segment router. - * These addresses serve as gateway IP addresses for the subnets configured - * on those ports. - * - * @param deviceId device identifier - * @return immutable set of ip addresses configured on the ports or null if not found - */ - public Set<Ip4Address> getPortIPs(DeviceId deviceId) { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - log.trace("getSubnetGatewayIps for device{} is {}", deviceId, - srinfo.gatewayIps.values()); - return ImmutableSet.copyOf(srinfo.gatewayIps.values()); - } - return null; - } - - /** - * Returns the configured IP addresses per port - * for a segment router. - * - * @param deviceId device identifier - * @return map of port to gateway IP addresses or null if not found - */ - public Map<PortNumber, Ip4Address> getPortIPMap(DeviceId deviceId) { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - return srinfo.gatewayIps; - } - return null; - } - - /** - * Returns the configured subnet prefixes for a segment router. - * - * @param deviceId device identifier - * @return list of ip prefixes or null if not found - */ - public Set<Ip4Prefix> getSubnets(DeviceId deviceId) { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - log.trace("getSubnets for device{} is {}", deviceId, - srinfo.subnets.values()); - return ImmutableSet.copyOf(srinfo.subnets.values()); - } - return null; - } - - /** - * Returns the configured subnet on the given port, or null if no - * subnet has been configured on the port. - * - * @param deviceId device identifier - * @param pnum port identifier - * @return configured subnet on port, or null - */ - public Ip4Prefix getPortSubnet(DeviceId deviceId, PortNumber pnum) { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - if (srinfo != null) { - return srinfo.subnets.get(pnum); - } - return null; - } - - /** - * Returns the router ip address of segment router that has the - * specified ip address in its subnets. - * - * @param destIpAddress target ip address - * @return router ip address - */ - public Ip4Address getRouterIpAddressForASubnetHost(Ip4Address destIpAddress) { - for (Map.Entry<DeviceId, SegmentRouterInfo> entry: - deviceConfigMap.entrySet()) { - for (Ip4Prefix prefix:entry.getValue().subnets.values()) { - if (prefix.contains(destIpAddress)) { - return entry.getValue().ip; - } - } - } - - log.debug("No router was found for {}", destIpAddress); - return null; - } - - /** - * Returns the router mac address of segment router that has the - * specified ip address as one of its subnet gateway ip address. - * - * @param gatewayIpAddress router gateway ip address - * @return router mac address or null if not found - */ - public MacAddress getRouterMacForAGatewayIp(Ip4Address gatewayIpAddress) { - for (Map.Entry<DeviceId, SegmentRouterInfo> entry: - deviceConfigMap.entrySet()) { - if (entry.getValue().gatewayIps. - values().contains(gatewayIpAddress)) { - return entry.getValue().mac; - } - } - - log.debug("Cannot find a router for {}", gatewayIpAddress); - return null; - } - - - /** - * Checks if the host is in the subnet defined in the router with the - * device ID given. - * - * @param deviceId device identification of the router - * @param hostIp host IP address to check - * @return true if the host is within the subnet of the router, - * false if no subnet is defined under the router or if the host is not - * within the subnet defined in the router - */ - public boolean inSameSubnet(DeviceId deviceId, Ip4Address hostIp) { - - Set<Ip4Prefix> subnets = getSubnets(deviceId); - if (subnets == null) { - return false; - } - - for (Ip4Prefix subnet: subnets) { - if (subnet.contains(hostIp)) { - return true; - } - } - - return false; - } - - /** - * Returns the ports corresponding to the adjacency Sid given. - * - * @param deviceId device identification of the router - * @param sid adjacency Sid - * @return set of port numbers - */ - public Set<Integer> getPortsForAdjacencySid(DeviceId deviceId, int sid) { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - return srinfo != null ? - ImmutableSet.copyOf(srinfo.adjacencySids.get(sid)) : - ImmutableSet.copyOf(new HashSet<>()); - } - - /** - * Check if the Sid given is whether adjacency Sid of the router device or not. - * - * @param deviceId device identification of the router - * @param sid Sid to check - * @return true if the Sid given is the adjacency Sid of the device, - * otherwise false - */ - public boolean isAdjacencySid(DeviceId deviceId, int sid) { - SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId); - return srinfo != null && srinfo.adjacencySids.containsKey(sid); - } -}
\ No newline at end of file diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java deleted file mode 100644 index a39c9567..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.segmentrouting.config; - -import java.util.List; -import java.util.Map; - -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip4Prefix; -import org.onlab.packet.MacAddress; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; - -/** - * Mechanism through which group handler module retrieves - * the device specific attributes such as segment ID, - * Mac address...etc from group handler applications. - */ -public interface DeviceProperties { - /** - * Checks if the device is configured. - * - * @param deviceId device identifier - * @return true if the device is configured - */ - boolean isConfigured(DeviceId deviceId); - - /** - * Returns the segment id of a device to be used in group creation. - * - * @param deviceId device identifier - * @throws DeviceConfigNotFoundException if the device configuration is not found - * @return segment id of a device - */ - int getSegmentId(DeviceId deviceId) throws DeviceConfigNotFoundException; - - /** - * Returns the Mac address of a device to be used in group creation. - * - * @param deviceId device identifier - * @throws DeviceConfigNotFoundException if the device configuration is not found - * @return mac address of a device - */ - MacAddress getDeviceMac(DeviceId deviceId) throws DeviceConfigNotFoundException; - - /** - * Returns the router ip address of a segment router. - * - * @param deviceId device identifier - * @throws DeviceConfigNotFoundException if the device configuration is not found - * @return router ip address - */ - Ip4Address getRouterIp(DeviceId deviceId) throws DeviceConfigNotFoundException; - - /** - * Indicates whether a device is edge device or transit/core device. - * - * @param deviceId device identifier - * @throws DeviceConfigNotFoundException if the device configuration is not found - * @return boolean - */ - boolean isEdgeDevice(DeviceId deviceId) throws DeviceConfigNotFoundException; - - /** - * Returns all segment IDs to be considered in building auto - * - * created groups. - * @return list of segment IDs - */ - List<Integer> getAllDeviceSegmentIds(); - - /** - * Returns subnet-to-ports mapping of given device. - * - * For each entry of the map - * Key: a subnet - * Value: a list of ports, which are bound to the subnet - * - * @param deviceId device identifier - * @return a map that contains all subnet-to-ports mapping of given device - */ - Map<Ip4Prefix, List<PortNumber>> getSubnetPortsMap(DeviceId deviceId); -} diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingConfig.java deleted file mode 100644 index f788925c..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingConfig.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onosproject.segmentrouting.config; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableMap; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.MacAddress; -import org.onosproject.net.DeviceId; -import org.onosproject.net.config.Config; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -/** - * Configuration object for Segment Routing Application. - */ -public class SegmentRoutingConfig extends Config<DeviceId> { - public static final String NAME = "name"; - public static final String IP = "routerIp"; - public static final String MAC = "routerMac"; - public static final String SID = "nodeSid"; - public static final String EDGE = "isEdgeRouter"; - public static final String ADJSIDS = "adjacencySids"; - public static final String ADJSID = "adjSid"; - public static final String PORTS = "ports"; - - @Override - public boolean isValid() { - return hasOnlyFields(NAME, IP, MAC, SID, EDGE, ADJSIDS, ADJSID, PORTS) && - this.name() != null && - this.routerIp() != null && - this.routerMac() != null && - this.nodeSid() != -1 && - this.isEdgeRouter() != null && - this.adjacencySids() != null; - } - - /** - * Gets the name of the router. - * - * @return Optional name of the router. May be empty if not configured. - */ - public Optional<String> name() { - String name = get(NAME, null); - return name != null ? Optional.of(name) : Optional.empty(); - } - - /** - * Sets the name of the router. - * - * @param name name of the router. - * @return the config of the router. - */ - public SegmentRoutingConfig setName(String name) { - return (SegmentRoutingConfig) setOrClear(NAME, name); - } - - /** - * Gets the IP address of the router. - * - * @return IP address of the router. Or null if not configured. - */ - public Ip4Address routerIp() { - String ip = get(IP, null); - return ip != null ? Ip4Address.valueOf(ip) : null; - } - - /** - * Sets the IP address of the router. - * - * @param ip IP address of the router. - * @return the config of the router. - */ - public SegmentRoutingConfig setRouterIp(String ip) { - return (SegmentRoutingConfig) setOrClear(IP, ip); - } - - /** - * Gets the MAC address of the router. - * - * @return MAC address of the router. Or null if not configured. - */ - public MacAddress routerMac() { - String mac = get(MAC, null); - return mac != null ? MacAddress.valueOf(mac) : null; - } - - /** - * Sets the MAC address of the router. - * - * @param mac MAC address of the router. - * @return the config of the router. - */ - public SegmentRoutingConfig setRouterMac(String mac) { - return (SegmentRoutingConfig) setOrClear(MAC, mac); - } - - /** - * Gets the node SID of the router. - * - * @return node SID of the router. Or -1 if not configured. - */ - public int nodeSid() { - return get(SID, -1); - } - - /** - * Sets the node SID of the router. - * - * @param sid node SID of the router. - * @return the config of the router. - */ - public SegmentRoutingConfig setNodeSid(int sid) { - return (SegmentRoutingConfig) setOrClear(SID, sid); - } - - /** - * Checks if the router is an edge router. - * - * @return true if the router is an edge router. - * false if the router is not an edge router. - * null if the value is not configured. - */ - public Boolean isEdgeRouter() { - String isEdgeRouter = get(EDGE, null); - return isEdgeRouter != null ? - Boolean.valueOf(isEdgeRouter) : - null; - } - - /** - * Specifies if the router is an edge router. - * - * @param isEdgeRouter true if the router is an edge router. - * @return the config of the router. - */ - public SegmentRoutingConfig setIsEdgeRouter(boolean isEdgeRouter) { - return (SegmentRoutingConfig) setOrClear(EDGE, isEdgeRouter); - } - - /** - * Gets the adjacency SIDs of the router. - * - * @return adjacency SIDs of the router. Or null if not configured. - */ - public Map<Integer, Set<Integer>> adjacencySids() { - if (!object.has(ADJSIDS)) { - return null; - } - - Map<Integer, Set<Integer>> adjacencySids = new HashMap<>(); - ArrayNode adjacencySidsNode = (ArrayNode) object.path(ADJSIDS); - for (JsonNode adjacencySidNode : adjacencySidsNode) { - int asid = adjacencySidNode.path(ADJSID).asInt(-1); - if (asid == -1) { - return null; - } - - HashSet<Integer> ports = new HashSet<>(); - ArrayNode portsNode = (ArrayNode) adjacencySidNode.path(PORTS); - for (JsonNode portNode : portsNode) { - int port = portNode.asInt(-1); - if (port == -1) { - return null; - } - ports.add(port); - } - adjacencySids.put(asid, ports); - } - - return ImmutableMap.copyOf(adjacencySids); - } - - /** - * Sets the adjacency SIDs of the router. - * - * @param adjacencySids adjacency SIDs of the router. - * @return the config of the router. - */ - public SegmentRoutingConfig setAdjacencySids(Map<Integer, Set<Integer>> adjacencySids) { - if (adjacencySids == null) { - object.remove(ADJSIDS); - } else { - ArrayNode adjacencySidsNode = mapper.createArrayNode(); - - adjacencySids.forEach((sid, ports) -> { - ObjectNode adjacencySidNode = mapper.createObjectNode(); - - adjacencySidNode.put(ADJSID, sid); - - ArrayNode portsNode = mapper.createArrayNode(); - ports.forEach(port -> { - portsNode.add(port.toString()); - }); - adjacencySidNode.set(PORTS, portsNode); - - adjacencySidsNode.add(adjacencySidNode); - }); - - object.set(ADJSIDS, adjacencySidsNode); - } - - return this; - } -}
\ No newline at end of file diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/package-info.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/package-info.java deleted file mode 100644 index 95f7e244..00000000 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Segment routing network configuration mechanism. - */ -package org.onosproject.segmentrouting.config;
\ No newline at end of file |