Committed by
Gerrit Code Review
[GEANT] Rate limit on port via NetConf and refactoring.
Change-Id: Id5b5a196bed3b28159160b94bc5ae838d00cb765
Showing
5 changed files
with
381 additions
and
134 deletions
... | @@ -35,17 +35,20 @@ import java.util.List; | ... | @@ -35,17 +35,20 @@ import java.util.List; |
35 | description = "Configures a device interface") | 35 | description = "Configures a device interface") |
36 | public class DeviceInterfaceAddCommand extends AbstractShellCommand { | 36 | public class DeviceInterfaceAddCommand extends AbstractShellCommand { |
37 | 37 | ||
38 | + private static final String ONE_ACTION_ALLOWED = | ||
39 | + "One configuration action allowed at a time"; | ||
38 | private static final String CONFIG_VLAN_SUCCESS = | 40 | private static final String CONFIG_VLAN_SUCCESS = |
39 | "VLAN %s added on device %s interface %s."; | 41 | "VLAN %s added on device %s interface %s."; |
40 | private static final String CONFIG_VLAN_FAILURE = | 42 | private static final String CONFIG_VLAN_FAILURE = |
41 | "Failed to add VLAN %s on device %s interface %s."; | 43 | "Failed to add VLAN %s on device %s interface %s."; |
42 | - private static final String ONE_VLAN_ALLOWED = | ||
43 | - "Only one VLAN allowed for access mode on device %s interface %s."; | ||
44 | - | ||
45 | private static final String CONFIG_TRUNK_SUCCESS = | 44 | private static final String CONFIG_TRUNK_SUCCESS = |
46 | "Trunk mode added for VLAN %s on device %s interface %s."; | 45 | "Trunk mode added for VLAN %s on device %s interface %s."; |
47 | private static final String CONFIG_TRUNK_FAILURE = | 46 | private static final String CONFIG_TRUNK_FAILURE = |
48 | "Failed to add trunk mode for VLAN %s on device %s interface %s."; | 47 | "Failed to add trunk mode for VLAN %s on device %s interface %s."; |
48 | + private static final String CONFIG_RATE_SUCCESS = | ||
49 | + "Rate limit %d%% added on device %s interface %s."; | ||
50 | + private static final String CONFIG_RATE_FAILURE = | ||
51 | + "Failed to add rate limit %d%% on device %s interface %s."; | ||
49 | 52 | ||
50 | @Argument(index = 0, name = "uri", description = "Device ID", | 53 | @Argument(index = 0, name = "uri", description = "Device ID", |
51 | required = true, multiValued = false) | 54 | required = true, multiValued = false) |
... | @@ -56,15 +59,20 @@ public class DeviceInterfaceAddCommand extends AbstractShellCommand { | ... | @@ -56,15 +59,20 @@ public class DeviceInterfaceAddCommand extends AbstractShellCommand { |
56 | required = true, multiValued = false) | 59 | required = true, multiValued = false) |
57 | private String portName = null; | 60 | private String portName = null; |
58 | 61 | ||
59 | - @Argument(index = 2, name = "vlan", | 62 | + @Option(name = "-r", aliases = "--rate-limit", |
60 | - description = "VLAN ID", | 63 | + description = "Percentage for egress bandwidth limit", |
61 | - required = true, multiValued = true) | 64 | + required = false, multiValued = false) |
62 | - private String[] vlanStrings = null; | 65 | + private String limitString = null; |
63 | 66 | ||
64 | @Option(name = "-t", aliases = "--trunk", | 67 | @Option(name = "-t", aliases = "--trunk", |
65 | - description = "Configure interface as trunk for VLAN(s)", | 68 | + description = "VLAN(s) for trunk port (multiple values are allowed)", |
69 | + required = false, multiValued = true) | ||
70 | + private String[] trunkVlanStrings = null; | ||
71 | + | ||
72 | + @Option(name = "-a", aliases = "--access", | ||
73 | + description = "VLAN for access port", | ||
66 | required = false, multiValued = false) | 74 | required = false, multiValued = false) |
67 | - private boolean trunkMode = false; | 75 | + private String accessVlanString = null; |
68 | 76 | ||
69 | @Override | 77 | @Override |
70 | protected void execute() { | 78 | protected void execute() { |
... | @@ -73,31 +81,51 @@ public class DeviceInterfaceAddCommand extends AbstractShellCommand { | ... | @@ -73,31 +81,51 @@ public class DeviceInterfaceAddCommand extends AbstractShellCommand { |
73 | DriverHandler h = service.createHandler(deviceId); | 81 | DriverHandler h = service.createHandler(deviceId); |
74 | InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class); | 82 | InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class); |
75 | 83 | ||
76 | - List<VlanId> vlanIds = new ArrayList<>(); | 84 | + if (accessVlanString != null && trunkVlanStrings == null && |
77 | - for (String vlanString : vlanStrings) { | 85 | + limitString == null) { |
78 | - vlanIds.add(VlanId.vlanId(Short.parseShort(vlanString))); | 86 | + // Access mode to be enabled for VLAN. |
87 | + addAccessModeToIntf(interfaceConfig); | ||
88 | + } else if (trunkVlanStrings != null && accessVlanString == null && | ||
89 | + limitString == null) { | ||
90 | + // Trunk mode to be enabled for VLANs. | ||
91 | + addTrunkModeToIntf(interfaceConfig); | ||
92 | + } else if (limitString != null && accessVlanString == null && | ||
93 | + trunkVlanStrings == null) { | ||
94 | + // Rate limit to be set on interface. | ||
95 | + addRateLimitToIntf(interfaceConfig); | ||
96 | + } else { | ||
97 | + // Option has not been correctly set. | ||
98 | + print(ONE_ACTION_ALLOWED); | ||
79 | } | 99 | } |
100 | + } | ||
80 | 101 | ||
81 | - if (trunkMode) { | 102 | + private void addRateLimitToIntf(InterfaceConfig config) { |
82 | - // Trunk mode to be enabled for VLAN. | 103 | + short rate = Short.parseShort(limitString); |
83 | - if (interfaceConfig.addTrunkInterface(deviceId, portName, vlanIds)) { | 104 | + if (config.addRateLimit(portName, rate)) { |
84 | - print(CONFIG_TRUNK_SUCCESS, vlanIds, deviceId, portName); | 105 | + print(CONFIG_RATE_SUCCESS, rate, uri, portName); |
85 | - } else { | 106 | + } else { |
86 | - print(CONFIG_TRUNK_FAILURE, vlanIds, deviceId, portName); | 107 | + print(CONFIG_RATE_FAILURE, rate, uri, portName); |
87 | - } | ||
88 | - return; | ||
89 | } | 108 | } |
109 | + } | ||
90 | 110 | ||
91 | - // Access mode to be enabled for VLAN. | 111 | + private void addTrunkModeToIntf(InterfaceConfig config) { |
92 | - if (vlanIds.size() != 1) { | 112 | + List<VlanId> vlanIds = new ArrayList<>(); |
93 | - print(ONE_VLAN_ALLOWED, deviceId, portName); | 113 | + for (String vlanString : trunkVlanStrings) { |
94 | - return; | 114 | + vlanIds.add(VlanId.vlanId(Short.parseShort(vlanString))); |
95 | } | 115 | } |
96 | - VlanId accessVlanId = vlanIds.get(0); | 116 | + if (config.addTrunkMode(portName, vlanIds)) { |
97 | - if (interfaceConfig.addAccessInterface(deviceId, portName, accessVlanId)) { | 117 | + print(CONFIG_TRUNK_SUCCESS, vlanIds, uri, portName); |
98 | - print(CONFIG_VLAN_SUCCESS, accessVlanId, deviceId, portName); | 118 | + } else { |
119 | + print(CONFIG_TRUNK_FAILURE, vlanIds, uri, portName); | ||
120 | + } | ||
121 | + } | ||
122 | + | ||
123 | + private void addAccessModeToIntf(InterfaceConfig config) { | ||
124 | + VlanId accessVlanId = VlanId.vlanId(Short.parseShort(accessVlanString)); | ||
125 | + if (config.addAccessMode(portName, accessVlanId)) { | ||
126 | + print(CONFIG_VLAN_SUCCESS, accessVlanId, uri, portName); | ||
99 | } else { | 127 | } else { |
100 | - print(CONFIG_VLAN_FAILURE, accessVlanId, deviceId, portName); | 128 | + print(CONFIG_VLAN_FAILURE, accessVlanId, uri, portName); |
101 | } | 129 | } |
102 | } | 130 | } |
103 | 131 | ... | ... |
... | @@ -25,36 +25,51 @@ import org.onosproject.net.driver.DriverHandler; | ... | @@ -25,36 +25,51 @@ import org.onosproject.net.driver.DriverHandler; |
25 | import org.onosproject.net.driver.DriverService; | 25 | import org.onosproject.net.driver.DriverService; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | - * Removes configured interface from a device. | 28 | + * Removes an interface configurion from a device. |
29 | */ | 29 | */ |
30 | @Command(scope = "onos", name = "device-remove-interface", | 30 | @Command(scope = "onos", name = "device-remove-interface", |
31 | description = "Removes an interface configuration from a device") | 31 | description = "Removes an interface configuration from a device") |
32 | public class DeviceInterfaceRemoveCommand extends AbstractShellCommand { | 32 | public class DeviceInterfaceRemoveCommand extends AbstractShellCommand { |
33 | 33 | ||
34 | + private static final String ONE_ACTION_ALLOWED = | ||
35 | + "One configuration removal allowed at a time"; | ||
34 | private static final String REMOVE_ACCESS_SUCCESS = | 36 | private static final String REMOVE_ACCESS_SUCCESS = |
35 | - "Access mode deleted from device %s interface %s."; | 37 | + "Access mode removed from device %s interface %s."; |
36 | private static final String REMOVE_ACCESS_FAILURE = | 38 | private static final String REMOVE_ACCESS_FAILURE = |
37 | - "Failed to delete access mode from device %s interface %s."; | 39 | + "Failed to remove access mode from device %s interface %s."; |
38 | - | ||
39 | private static final String REMOVE_TRUNK_SUCCESS = | 40 | private static final String REMOVE_TRUNK_SUCCESS = |
40 | - "Trunk mode deleted from device %s interface %s."; | 41 | + "Trunk mode removed from device %s interface %s."; |
41 | private static final String REMOVE_TRUNK_FAILURE = | 42 | private static final String REMOVE_TRUNK_FAILURE = |
42 | - "Failed to delete trunk mode from device %s interface %s."; | 43 | + "Failed to remove trunk mode from device %s interface %s."; |
44 | + private static final String REMOVE_RATE_SUCCESS = | ||
45 | + "Rate limit removed from device %s interface %s."; | ||
46 | + private static final String REMOVE_RATE_FAILURE = | ||
47 | + "Failed to remove rate limit from device %s interface %s."; | ||
43 | 48 | ||
44 | @Argument(index = 0, name = "uri", description = "Device ID", | 49 | @Argument(index = 0, name = "uri", description = "Device ID", |
45 | required = true, multiValued = false) | 50 | required = true, multiValued = false) |
46 | private String uri = null; | 51 | private String uri = null; |
47 | 52 | ||
48 | @Argument(index = 1, name = "interface", | 53 | @Argument(index = 1, name = "interface", |
49 | - description = "Interface name", | 54 | + description = "Interface name", |
50 | - required = true, multiValued = false) | 55 | + required = true, multiValued = false) |
51 | private String portName = null; | 56 | private String portName = null; |
52 | 57 | ||
58 | + @Option(name = "-r", aliases = "--rate-limit", | ||
59 | + description = "Percentage for egress bandwidth limit", | ||
60 | + required = false, multiValued = false) | ||
61 | + private boolean rateLimit = false; | ||
62 | + | ||
53 | @Option(name = "-t", aliases = "--trunk", | 63 | @Option(name = "-t", aliases = "--trunk", |
54 | description = "Remove trunk mode for VLAN(s)", | 64 | description = "Remove trunk mode for VLAN(s)", |
55 | required = false, multiValued = false) | 65 | required = false, multiValued = false) |
56 | private boolean trunkMode = false; | 66 | private boolean trunkMode = false; |
57 | 67 | ||
68 | + @Option(name = "-a", aliases = "--access", | ||
69 | + description = "Remove access mode for VLAN", | ||
70 | + required = false, multiValued = false) | ||
71 | + private boolean accessMode = false; | ||
72 | + | ||
58 | @Override | 73 | @Override |
59 | protected void execute() { | 74 | protected void execute() { |
60 | DriverService service = get(DriverService.class); | 75 | DriverService service = get(DriverService.class); |
... | @@ -62,21 +77,42 @@ public class DeviceInterfaceRemoveCommand extends AbstractShellCommand { | ... | @@ -62,21 +77,42 @@ public class DeviceInterfaceRemoveCommand extends AbstractShellCommand { |
62 | DriverHandler h = service.createHandler(deviceId); | 77 | DriverHandler h = service.createHandler(deviceId); |
63 | InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class); | 78 | InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class); |
64 | 79 | ||
65 | - if (trunkMode) { | 80 | + if (trunkMode && !accessMode && !rateLimit) { |
66 | // Trunk mode for VLAN to be removed. | 81 | // Trunk mode for VLAN to be removed. |
67 | - if (interfaceConfig.removeTrunkInterface(deviceId, portName)) { | 82 | + removeTrunkModeFromIntf(interfaceConfig); |
68 | - print(REMOVE_TRUNK_SUCCESS, deviceId, portName); | 83 | + } else if (accessMode && !trunkMode && !rateLimit) { |
69 | - } else { | 84 | + // Access mode for VLAN to be removed. |
70 | - print(REMOVE_TRUNK_FAILURE, deviceId, portName); | 85 | + removeAccessModeFromIntf(interfaceConfig); |
71 | - } | 86 | + } else if (rateLimit && !trunkMode && !accessMode) { |
72 | - return; | 87 | + // Rate limit to be removed. |
88 | + removeRateLimitFromIntf(interfaceConfig); | ||
89 | + } else { | ||
90 | + // Option has not been correctly set. | ||
91 | + print(ONE_ACTION_ALLOWED); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + private void removeAccessModeFromIntf(InterfaceConfig interfaceConfig) { | ||
96 | + if (interfaceConfig.removeAccessMode(portName)) { | ||
97 | + print(REMOVE_ACCESS_SUCCESS, uri, portName); | ||
98 | + } else { | ||
99 | + print(REMOVE_ACCESS_FAILURE, uri, portName); | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + private void removeTrunkModeFromIntf(InterfaceConfig interfaceConfig) { | ||
104 | + if (interfaceConfig.removeTrunkMode(portName)) { | ||
105 | + print(REMOVE_TRUNK_SUCCESS, uri, portName); | ||
106 | + } else { | ||
107 | + print(REMOVE_TRUNK_FAILURE, uri, portName); | ||
73 | } | 108 | } |
109 | + } | ||
74 | 110 | ||
75 | - // Access mode for VLAN to be removed. | 111 | + private void removeRateLimitFromIntf(InterfaceConfig config) { |
76 | - if (interfaceConfig.removeAccessInterface(deviceId, portName)) { | 112 | + if (config.removeRateLimit(portName)) { |
77 | - print(REMOVE_ACCESS_SUCCESS, deviceId, portName); | 113 | + print(REMOVE_RATE_SUCCESS, uri, portName); |
78 | } else { | 114 | } else { |
79 | - print(REMOVE_ACCESS_FAILURE, deviceId, portName); | 115 | + print(REMOVE_RATE_FAILURE, uri, portName); |
80 | } | 116 | } |
81 | } | 117 | } |
82 | 118 | ... | ... |
... | @@ -78,7 +78,7 @@ public class DeviceInterfacesListCommand extends DevicesListCommand { | ... | @@ -78,7 +78,7 @@ public class DeviceInterfacesListCommand extends DevicesListCommand { |
78 | InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class); | 78 | InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class); |
79 | 79 | ||
80 | List<DeviceInterfaceDescription> interfaces = | 80 | List<DeviceInterfaceDescription> interfaces = |
81 | - interfaceConfig.getInterfaces(device.id()); | 81 | + interfaceConfig.getInterfaces(); |
82 | if (interfaces == null) { | 82 | if (interfaces == null) { |
83 | print(ERROR_RESULT); | 83 | print(ERROR_RESULT); |
84 | } else if (interfaces.isEmpty()) { | 84 | } else if (interfaces.isEmpty()) { | ... | ... |
... | @@ -34,8 +34,19 @@ public interface InterfaceConfig extends HandlerBehaviour { | ... | @@ -34,8 +34,19 @@ public interface InterfaceConfig extends HandlerBehaviour { |
34 | * @param intf the name of the interface | 34 | * @param intf the name of the interface |
35 | * @param vlanId the VLAN ID | 35 | * @param vlanId the VLAN ID |
36 | * @return the result of operation | 36 | * @return the result of operation |
37 | + * @deprecated in 1.7.0 Hummingbird release - use of addAccessMode() instead | ||
37 | */ | 38 | */ |
38 | - boolean addAccessInterface(DeviceId deviceId, String intf, VlanId vlanId); | 39 | + @Deprecated |
40 | + public boolean addAccessInterface(DeviceId deviceId, String intf, VlanId vlanId); | ||
41 | + | ||
42 | + /** | ||
43 | + * Adds an access interface to a VLAN. | ||
44 | + * | ||
45 | + * @param intf the name of the interface | ||
46 | + * @param vlanId the VLAN ID | ||
47 | + * @return the result of operation | ||
48 | + */ | ||
49 | + boolean addAccessMode(String intf, VlanId vlanId); | ||
39 | 50 | ||
40 | /** | 51 | /** |
41 | * Removes an access interface to a VLAN. | 52 | * Removes an access interface to a VLAN. |
... | @@ -43,40 +54,99 @@ public interface InterfaceConfig extends HandlerBehaviour { | ... | @@ -43,40 +54,99 @@ public interface InterfaceConfig extends HandlerBehaviour { |
43 | * @param deviceId the device ID | 54 | * @param deviceId the device ID |
44 | * @param intf the name of the interface | 55 | * @param intf the name of the interface |
45 | * @return the result of operation | 56 | * @return the result of operation |
57 | + * @deprecated in 1.7.0 Hummingbird release - use of removeAccessMode() instead | ||
46 | */ | 58 | */ |
59 | + @Deprecated | ||
47 | boolean removeAccessInterface(DeviceId deviceId, String intf); | 60 | boolean removeAccessInterface(DeviceId deviceId, String intf); |
48 | 61 | ||
49 | /** | 62 | /** |
63 | + * Removes an access interface to a VLAN. | ||
64 | + * | ||
65 | + * @param intf the name of the interface | ||
66 | + * @return the result of operation | ||
67 | + */ | ||
68 | + boolean removeAccessMode(String intf); | ||
69 | + | ||
70 | + /** | ||
50 | * Adds a trunk interface for VLANs. | 71 | * Adds a trunk interface for VLANs. |
51 | * | 72 | * |
52 | * @param deviceId the device ID | 73 | * @param deviceId the device ID |
53 | * @param intf the name of the interface | 74 | * @param intf the name of the interface |
54 | * @param vlanIds the VLAN IDs | 75 | * @param vlanIds the VLAN IDs |
55 | * @return the result of operation | 76 | * @return the result of operation |
77 | + * @deprecated in 1.7.0 Hummingbird release - use of addTrunkMode() instead | ||
56 | */ | 78 | */ |
79 | + @Deprecated | ||
57 | boolean addTrunkInterface(DeviceId deviceId, String intf, List<VlanId> vlanIds); | 80 | boolean addTrunkInterface(DeviceId deviceId, String intf, List<VlanId> vlanIds); |
58 | 81 | ||
59 | /** | 82 | /** |
60 | - * Removes trunk mode configuration from an interface. | 83 | + * Adds a trunk interface for VLANs. |
84 | + * | ||
85 | + * @param intf the name of the interface | ||
86 | + * @param vlanIds the VLAN IDs | ||
87 | + * @return the result of operation | ||
88 | + */ | ||
89 | + boolean addTrunkMode(String intf, List<VlanId> vlanIds); | ||
90 | + | ||
91 | + /** | ||
92 | + * Removes trunk mode configuration from an interface. | ||
61 | * | 93 | * |
62 | * @param deviceId the device ID | 94 | * @param deviceId the device ID |
63 | * @param intf the name of the interface | 95 | * @param intf the name of the interface |
64 | * @return the result of operation | 96 | * @return the result of operation |
97 | + * @deprecated in 1.7.0 Hummingbird release - use of removeTrunkMode() instead | ||
65 | */ | 98 | */ |
99 | + @Deprecated | ||
66 | boolean removeTrunkInterface(DeviceId deviceId, String intf); | 100 | boolean removeTrunkInterface(DeviceId deviceId, String intf); |
67 | 101 | ||
68 | /** | 102 | /** |
103 | + * Removes trunk mode configuration from an interface. | ||
104 | + * | ||
105 | + * @param intf the name of the interface | ||
106 | + * @return the result of operation | ||
107 | + */ | ||
108 | + boolean removeTrunkMode(String intf); | ||
109 | + | ||
110 | + /** | ||
111 | + * Adds a rate limit on an interface. | ||
112 | + * | ||
113 | + * @param intf the name of the interface | ||
114 | + * @param limit the limit as a percentage | ||
115 | + * @return the result of operation | ||
116 | + */ | ||
117 | + boolean addRateLimit(String intf, short limit); | ||
118 | + | ||
119 | + /** | ||
120 | + * Removes rate limit from an interface. | ||
121 | + * | ||
122 | + * @param intf the name of the interface | ||
123 | + * @return the result of operation | ||
124 | + */ | ||
125 | + boolean removeRateLimit(String intf); | ||
126 | + | ||
127 | + /** | ||
69 | * Provides the interfaces configured on a device. | 128 | * Provides the interfaces configured on a device. |
70 | * | 129 | * |
71 | * @param deviceId the device ID | 130 | * @param deviceId the device ID |
72 | * @return the list of the configured interfaces | 131 | * @return the list of the configured interfaces |
132 | + * @deprecated in 1.7.0 Hummingbird release - use of getInterfaces() without | ||
133 | + * deviceId as parameter instead | ||
134 | + */ | ||
135 | + @Deprecated | ||
136 | + public List<DeviceInterfaceDescription> getInterfaces(DeviceId deviceId); | ||
137 | + | ||
138 | + /** | ||
139 | + * Provides the interfaces configured on a device. | ||
140 | + * | ||
141 | + * @return the list of the configured interfaces | ||
73 | */ | 142 | */ |
74 | - List<DeviceInterfaceDescription> getInterfaces(DeviceId deviceId); | 143 | + List<DeviceInterfaceDescription> getInterfaces(); |
75 | 144 | ||
76 | /** | 145 | /** |
77 | * TODO Addition of more methods to make the behavior symmetrical. | 146 | * TODO Addition of more methods to make the behavior symmetrical. |
78 | - * Methods getInterfacesForVlan, getVlansForInterface, getTrunkforInterface, | 147 | + * Methods getInterfacesForVlan(VlanId), hasAccessMode(), hasTrunkMode(), |
79 | - * getInterfacesForTrunk should be added to complete the behavior. | 148 | + * getTrunkVlans(Interface), getAccessVlan(Interface) should be added to |
149 | + * complete the behavior. | ||
80 | */ | 150 | */ |
81 | 151 | ||
82 | } | 152 | } | ... | ... |
... | @@ -54,6 +54,18 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -54,6 +54,18 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
54 | */ | 54 | */ |
55 | @Override | 55 | @Override |
56 | public boolean addAccessInterface(DeviceId deviceId, String intf, VlanId vlanId) { | 56 | public boolean addAccessInterface(DeviceId deviceId, String intf, VlanId vlanId) { |
57 | + return addAccessMode(intf, vlanId); | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * Adds an access interface to a VLAN. | ||
62 | + * | ||
63 | + * @param intf the name of the interface | ||
64 | + * @param vlanId the VLAN ID | ||
65 | + * @return the result of operation | ||
66 | + */ | ||
67 | + @Override | ||
68 | + public boolean addAccessMode(String intf, VlanId vlanId) { | ||
57 | NetconfController controller = checkNotNull(handler() | 69 | NetconfController controller = checkNotNull(handler() |
58 | .get(NetconfController.class)); | 70 | .get(NetconfController.class)); |
59 | 71 | ||
... | @@ -61,10 +73,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -61,10 +73,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
61 | .data().deviceId()).getSession(); | 73 | .data().deviceId()).getSession(); |
62 | String reply; | 74 | String reply; |
63 | try { | 75 | try { |
64 | - reply = session.requestSync(addAccessInterfaceBuilder(intf, vlanId)); | 76 | + reply = session.requestSync(addAccessModeBuilder(intf, vlanId)); |
65 | } catch (NetconfException e) { | 77 | } catch (NetconfException e) { |
66 | log.error("Failed to configure VLAN ID {} on device {} interface {}.", | 78 | log.error("Failed to configure VLAN ID {} on device {} interface {}.", |
67 | - vlanId, deviceId, intf, e); | 79 | + vlanId, handler().data().deviceId(), intf, e); |
68 | return false; | 80 | return false; |
69 | } | 81 | } |
70 | 82 | ||
... | @@ -79,31 +91,13 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -79,31 +91,13 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
79 | * @param vlanId the VLAN ID | 91 | * @param vlanId the VLAN ID |
80 | * @return the request string. | 92 | * @return the request string. |
81 | */ | 93 | */ |
82 | - private String addAccessInterfaceBuilder(String intf, VlanId vlanId) { | 94 | + private String addAccessModeBuilder(String intf, VlanId vlanId) { |
83 | - StringBuilder rpc = | 95 | + StringBuilder rpc = new StringBuilder(getOpeningString(intf)); |
84 | - new StringBuilder("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "); | ||
85 | - rpc.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); | ||
86 | - rpc.append("<edit-config>"); | ||
87 | - rpc.append("<target>"); | ||
88 | - rpc.append("<running/>"); | ||
89 | - rpc.append("</target>"); | ||
90 | - rpc.append("<config>"); | ||
91 | - rpc.append("<xml-config-data>"); | ||
92 | - rpc.append("<Device-Configuration><interface><Param>"); | ||
93 | - rpc.append(intf); | ||
94 | - rpc.append("</Param>"); | ||
95 | - rpc.append("<ConfigIf-Configuration>"); | ||
96 | rpc.append("<switchport><access><vlan><VLANIDVLANPortAccessMode>"); | 96 | rpc.append("<switchport><access><vlan><VLANIDVLANPortAccessMode>"); |
97 | rpc.append(vlanId); | 97 | rpc.append(vlanId); |
98 | rpc.append("</VLANIDVLANPortAccessMode></vlan></access></switchport>"); | 98 | rpc.append("</VLANIDVLANPortAccessMode></vlan></access></switchport>"); |
99 | rpc.append("<switchport><mode><access/></mode></switchport>"); | 99 | rpc.append("<switchport><mode><access/></mode></switchport>"); |
100 | - rpc.append("</ConfigIf-Configuration>"); | 100 | + rpc.append(getClosingString()); |
101 | - rpc.append("</interface>"); | ||
102 | - rpc.append("</Device-Configuration>"); | ||
103 | - rpc.append("</xml-config-data>"); | ||
104 | - rpc.append("</config>"); | ||
105 | - rpc.append("</edit-config>"); | ||
106 | - rpc.append("</rpc>"); | ||
107 | 101 | ||
108 | return rpc.toString(); | 102 | return rpc.toString(); |
109 | } | 103 | } |
... | @@ -117,6 +111,17 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -117,6 +111,17 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
117 | */ | 111 | */ |
118 | @Override | 112 | @Override |
119 | public boolean removeAccessInterface(DeviceId deviceId, String intf) { | 113 | public boolean removeAccessInterface(DeviceId deviceId, String intf) { |
114 | + return removeAccessMode(intf); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Removes an access interface to a VLAN. | ||
119 | + * | ||
120 | + * @param intf the name of the interface | ||
121 | + * @return the result of operation | ||
122 | + */ | ||
123 | + @Override | ||
124 | + public boolean removeAccessMode(String intf) { | ||
120 | NetconfController controller = checkNotNull(handler() | 125 | NetconfController controller = checkNotNull(handler() |
121 | .get(NetconfController.class)); | 126 | .get(NetconfController.class)); |
122 | 127 | ||
... | @@ -124,10 +129,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -124,10 +129,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
124 | .data().deviceId()).getSession(); | 129 | .data().deviceId()).getSession(); |
125 | String reply; | 130 | String reply; |
126 | try { | 131 | try { |
127 | - reply = session.requestSync(removeAccessInterfaceBuilder(intf)); | 132 | + reply = session.requestSync(removeAccessModeBuilder(intf)); |
128 | } catch (NetconfException e) { | 133 | } catch (NetconfException e) { |
129 | log.error("Failed to remove access mode from device {} interface {}.", | 134 | log.error("Failed to remove access mode from device {} interface {}.", |
130 | - deviceId, intf, e); | 135 | + handler().data().deviceId(), intf, e); |
131 | return false; | 136 | return false; |
132 | } | 137 | } |
133 | 138 | ||
... | @@ -141,30 +146,12 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -141,30 +146,12 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
141 | * @param intf the name of the interface | 146 | * @param intf the name of the interface |
142 | * @return the request string. | 147 | * @return the request string. |
143 | */ | 148 | */ |
144 | - private String removeAccessInterfaceBuilder(String intf) { | 149 | + private String removeAccessModeBuilder(String intf) { |
145 | - StringBuilder rpc = | 150 | + StringBuilder rpc = new StringBuilder(getOpeningString(intf)); |
146 | - new StringBuilder("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "); | ||
147 | - rpc.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); | ||
148 | - rpc.append("<edit-config>"); | ||
149 | - rpc.append("<target>"); | ||
150 | - rpc.append("<running/>"); | ||
151 | - rpc.append("</target>"); | ||
152 | - rpc.append("<config>"); | ||
153 | - rpc.append("<xml-config-data>"); | ||
154 | - rpc.append("<Device-Configuration><interface><Param>"); | ||
155 | - rpc.append(intf); | ||
156 | - rpc.append("</Param>"); | ||
157 | - rpc.append("<ConfigIf-Configuration>"); | ||
158 | rpc.append("<switchport operation=\"delete\"><access><vlan><VLANIDVLANPortAccessMode>"); | 151 | rpc.append("<switchport operation=\"delete\"><access><vlan><VLANIDVLANPortAccessMode>"); |
159 | rpc.append("</VLANIDVLANPortAccessMode></vlan></access></switchport>"); | 152 | rpc.append("</VLANIDVLANPortAccessMode></vlan></access></switchport>"); |
160 | rpc.append("<switchport operation=\"delete\"><mode><access/></mode></switchport>"); | 153 | rpc.append("<switchport operation=\"delete\"><mode><access/></mode></switchport>"); |
161 | - rpc.append("</ConfigIf-Configuration>"); | 154 | + rpc.append(getClosingString()); |
162 | - rpc.append("</interface>"); | ||
163 | - rpc.append("</Device-Configuration>"); | ||
164 | - rpc.append("</xml-config-data>"); | ||
165 | - rpc.append("</config>"); | ||
166 | - rpc.append("</edit-config>"); | ||
167 | - rpc.append("</rpc>"); | ||
168 | 155 | ||
169 | return rpc.toString(); | 156 | return rpc.toString(); |
170 | } | 157 | } |
... | @@ -179,6 +166,18 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -179,6 +166,18 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
179 | */ | 166 | */ |
180 | @Override | 167 | @Override |
181 | public boolean addTrunkInterface(DeviceId deviceId, String intf, List<VlanId> vlanIds) { | 168 | public boolean addTrunkInterface(DeviceId deviceId, String intf, List<VlanId> vlanIds) { |
169 | + return addTrunkMode(intf, vlanIds); | ||
170 | + } | ||
171 | + | ||
172 | + /** | ||
173 | + * Adds a trunk interface for VLANs. | ||
174 | + * | ||
175 | + * @param intf the name of the interface | ||
176 | + * @param vlanIds the VLAN IDs | ||
177 | + * @return the result of operation | ||
178 | + */ | ||
179 | + @Override | ||
180 | + public boolean addTrunkMode(String intf, List<VlanId> vlanIds) { | ||
182 | NetconfController controller = checkNotNull(handler() | 181 | NetconfController controller = checkNotNull(handler() |
183 | .get(NetconfController.class)); | 182 | .get(NetconfController.class)); |
184 | 183 | ||
... | @@ -186,10 +185,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -186,10 +185,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
186 | .data().deviceId()).getSession(); | 185 | .data().deviceId()).getSession(); |
187 | String reply; | 186 | String reply; |
188 | try { | 187 | try { |
189 | - reply = session.requestSync(addTrunkInterfaceBuilder(intf, vlanIds)); | 188 | + reply = session.requestSync(addTrunkModeBuilder(intf, vlanIds)); |
190 | } catch (NetconfException e) { | 189 | } catch (NetconfException e) { |
191 | log.error("Failed to configure trunk mode for VLAN ID {} on device {} interface {}.", | 190 | log.error("Failed to configure trunk mode for VLAN ID {} on device {} interface {}.", |
192 | - vlanIds, deviceId, intf, e); | 191 | + vlanIds, handler().data().deviceId(), intf, e); |
193 | return false; | 192 | return false; |
194 | } | 193 | } |
195 | 194 | ||
... | @@ -204,33 +203,15 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -204,33 +203,15 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
204 | * @param vlanIds the VLAN IDs | 203 | * @param vlanIds the VLAN IDs |
205 | * @return the request string. | 204 | * @return the request string. |
206 | */ | 205 | */ |
207 | - private String addTrunkInterfaceBuilder(String intf, List<VlanId> vlanIds) { | 206 | + private String addTrunkModeBuilder(String intf, List<VlanId> vlanIds) { |
208 | - StringBuilder rpc = | 207 | + StringBuilder rpc = new StringBuilder(getOpeningString(intf)); |
209 | - new StringBuilder("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "); | ||
210 | - rpc.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); | ||
211 | - rpc.append("<edit-config>"); | ||
212 | - rpc.append("<target>"); | ||
213 | - rpc.append("<running/>"); | ||
214 | - rpc.append("</target>"); | ||
215 | - rpc.append("<config>"); | ||
216 | - rpc.append("<xml-config-data>"); | ||
217 | - rpc.append("<Device-Configuration><interface><Param>"); | ||
218 | - rpc.append(intf); | ||
219 | - rpc.append("</Param>"); | ||
220 | - rpc.append("<ConfigIf-Configuration>"); | ||
221 | rpc.append("<switchport><trunk><encapsulation><dot1q/></encapsulation>"); | 208 | rpc.append("<switchport><trunk><encapsulation><dot1q/></encapsulation>"); |
222 | rpc.append("</trunk></switchport><switchport><trunk><allowed><vlan>"); | 209 | rpc.append("</trunk></switchport><switchport><trunk><allowed><vlan>"); |
223 | rpc.append("<VLANIDsAllowedVLANsPortTrunkingMode>"); | 210 | rpc.append("<VLANIDsAllowedVLANsPortTrunkingMode>"); |
224 | rpc.append(getVlansString(vlanIds)); | 211 | rpc.append(getVlansString(vlanIds)); |
225 | rpc.append("</VLANIDsAllowedVLANsPortTrunkingMode></vlan></allowed></trunk>"); | 212 | rpc.append("</VLANIDsAllowedVLANsPortTrunkingMode></vlan></allowed></trunk>"); |
226 | rpc.append("</switchport><switchport><mode><trunk/></mode></switchport>"); | 213 | rpc.append("</switchport><switchport><mode><trunk/></mode></switchport>"); |
227 | - rpc.append("</ConfigIf-Configuration>"); | 214 | + rpc.append(getClosingString()); |
228 | - rpc.append("</interface>"); | ||
229 | - rpc.append("</Device-Configuration>"); | ||
230 | - rpc.append("</xml-config-data>"); | ||
231 | - rpc.append("</config>"); | ||
232 | - rpc.append("</edit-config>"); | ||
233 | - rpc.append("</rpc>"); | ||
234 | 215 | ||
235 | return rpc.toString(); | 216 | return rpc.toString(); |
236 | } | 217 | } |
... | @@ -244,6 +225,17 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -244,6 +225,17 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
244 | */ | 225 | */ |
245 | @Override | 226 | @Override |
246 | public boolean removeTrunkInterface(DeviceId deviceId, String intf) { | 227 | public boolean removeTrunkInterface(DeviceId deviceId, String intf) { |
228 | + return removeTrunkMode(intf); | ||
229 | + } | ||
230 | + | ||
231 | + /** | ||
232 | + * Removes trunk mode configuration from an interface. | ||
233 | + * | ||
234 | + * @param intf the name of the interface | ||
235 | + * @return the result of operation | ||
236 | + */ | ||
237 | + @Override | ||
238 | + public boolean removeTrunkMode(String intf) { | ||
247 | NetconfController controller = checkNotNull(handler() | 239 | NetconfController controller = checkNotNull(handler() |
248 | .get(NetconfController.class)); | 240 | .get(NetconfController.class)); |
249 | 241 | ||
... | @@ -251,10 +243,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -251,10 +243,10 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
251 | .data().deviceId()).getSession(); | 243 | .data().deviceId()).getSession(); |
252 | String reply; | 244 | String reply; |
253 | try { | 245 | try { |
254 | - reply = session.requestSync(removeTrunkInterfaceBuilder(intf)); | 246 | + reply = session.requestSync(removeTrunkModeBuilder(intf)); |
255 | } catch (NetconfException e) { | 247 | } catch (NetconfException e) { |
256 | - log.error("Failed to remove trunk mode on device {} interface {}.", | 248 | + log.error("Failed to remove trunk mode from device {} interface {}.", |
257 | - deviceId, intf, e); | 249 | + handler().data().deviceId(), intf, e); |
258 | return false; | 250 | return false; |
259 | } | 251 | } |
260 | 252 | ||
... | @@ -268,7 +260,114 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -268,7 +260,114 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
268 | * @param intf the name of the interface | 260 | * @param intf the name of the interface |
269 | * @return the request string. | 261 | * @return the request string. |
270 | */ | 262 | */ |
271 | - private String removeTrunkInterfaceBuilder(String intf) { | 263 | + private String removeTrunkModeBuilder(String intf) { |
264 | + StringBuilder rpc = new StringBuilder(getOpeningString(intf)); | ||
265 | + rpc.append("<switchport><mode operation=\"delete\"><trunk/></mode></switchport>"); | ||
266 | + rpc.append("<switchport><trunk operation=\"delete\"><encapsulation>"); | ||
267 | + rpc.append("<dot1q/></encapsulation></trunk></switchport>"); | ||
268 | + rpc.append("<switchport><trunk operation=\"delete\"><allowed><vlan>"); | ||
269 | + rpc.append("<VLANIDsAllowedVLANsPortTrunkingMode>"); | ||
270 | + rpc.append("</VLANIDsAllowedVLANsPortTrunkingMode></vlan></allowed>"); | ||
271 | + rpc.append("</trunk></switchport>"); | ||
272 | + rpc.append(getClosingString()); | ||
273 | + | ||
274 | + return rpc.toString(); | ||
275 | + } | ||
276 | + | ||
277 | + /** | ||
278 | + * Adds a rate limit on an interface. | ||
279 | + * | ||
280 | + * @param intf the name of the interface | ||
281 | + * @param limit the limit as a percentage | ||
282 | + * @return the result of operation | ||
283 | + */ | ||
284 | + @Override | ||
285 | + public boolean addRateLimit(String intf, short limit) { | ||
286 | + NetconfController controller = checkNotNull(handler() | ||
287 | + .get(NetconfController.class)); | ||
288 | + | ||
289 | + NetconfSession session = controller.getDevicesMap().get(handler() | ||
290 | + .data().deviceId()).getSession(); | ||
291 | + String reply; | ||
292 | + try { | ||
293 | + reply = session.requestSync(addRateLimitBuilder(intf, limit)); | ||
294 | + } catch (NetconfException e) { | ||
295 | + log.error("Failed to configure rate limit {}%% on device {} interface {}.", | ||
296 | + limit, handler().data().deviceId(), intf, e); | ||
297 | + return false; | ||
298 | + } | ||
299 | + | ||
300 | + return XmlConfigParser.configSuccess(XmlConfigParser.loadXml( | ||
301 | + new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))); | ||
302 | + } | ||
303 | + | ||
304 | + /** | ||
305 | + * Builds a request to configure an interface with rate limit. | ||
306 | + * | ||
307 | + * @param intf the name of the interface | ||
308 | + * @param limit the limit as a percentage | ||
309 | + * @return the request string. | ||
310 | + */ | ||
311 | + private String addRateLimitBuilder(String intf, short limit) { | ||
312 | + StringBuilder rpc = new StringBuilder(getOpeningString(intf)); | ||
313 | + rpc.append("<srr-queue><bandwidth><limit>"); | ||
314 | + rpc.append("<EnterBandwidthLimitInterfaceAsPercentage>"); | ||
315 | + rpc.append(limit); | ||
316 | + rpc.append("</EnterBandwidthLimitInterfaceAsPercentage>"); | ||
317 | + rpc.append("</limit></bandwidth></srr-queue>"); | ||
318 | + rpc.append(getClosingString()); | ||
319 | + | ||
320 | + return rpc.toString(); | ||
321 | + } | ||
322 | + | ||
323 | + /** | ||
324 | + * Removes rate limit from an interface. | ||
325 | + * | ||
326 | + * @param intf the name of the interface | ||
327 | + * @return the result of operation | ||
328 | + */ | ||
329 | + @Override | ||
330 | + public boolean removeRateLimit(String intf) { | ||
331 | + NetconfController controller = checkNotNull(handler() | ||
332 | + .get(NetconfController.class)); | ||
333 | + | ||
334 | + NetconfSession session = controller.getDevicesMap().get(handler() | ||
335 | + .data().deviceId()).getSession(); | ||
336 | + String reply; | ||
337 | + try { | ||
338 | + reply = session.requestSync(removeRateLimitBuilder(intf)); | ||
339 | + } catch (NetconfException e) { | ||
340 | + log.error("Failed to remove rate limit from device {} interface {}.", | ||
341 | + handler().data().deviceId(), intf, e); | ||
342 | + return false; | ||
343 | + } | ||
344 | + | ||
345 | + return XmlConfigParser.configSuccess(XmlConfigParser.loadXml( | ||
346 | + new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))); | ||
347 | + } | ||
348 | + | ||
349 | + /** | ||
350 | + * Builds a request to remove a rate limit from an interface. | ||
351 | + * | ||
352 | + * @param intf the name of the interface | ||
353 | + * @return the request string. | ||
354 | + */ | ||
355 | + private String removeRateLimitBuilder(String intf) { | ||
356 | + StringBuilder rpc = new StringBuilder(getOpeningString(intf)); | ||
357 | + rpc.append("<srr-queue operation=\"delete\"><bandwidth><limit>"); | ||
358 | + rpc.append("</limit></bandwidth></srr-queue>"); | ||
359 | + rpc.append(getClosingString()); | ||
360 | + | ||
361 | + return rpc.toString(); | ||
362 | + } | ||
363 | + | ||
364 | + /** | ||
365 | + * Builds the opening of a request for the configuration of an interface. | ||
366 | + * | ||
367 | + * @param intf the interface to be configured | ||
368 | + * @return the opening string | ||
369 | + */ | ||
370 | + private String getOpeningString(String intf) { | ||
272 | StringBuilder rpc = | 371 | StringBuilder rpc = |
273 | new StringBuilder("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "); | 372 | new StringBuilder("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "); |
274 | rpc.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); | 373 | rpc.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); |
... | @@ -282,13 +381,17 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -282,13 +381,17 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
282 | rpc.append(intf); | 381 | rpc.append(intf); |
283 | rpc.append("</Param>"); | 382 | rpc.append("</Param>"); |
284 | rpc.append("<ConfigIf-Configuration>"); | 383 | rpc.append("<ConfigIf-Configuration>"); |
285 | - rpc.append("<switchport><mode operation=\"delete\"><trunk/></mode></switchport>"); | 384 | + |
286 | - rpc.append("<switchport><trunk operation=\"delete\"><encapsulation>"); | 385 | + return rpc.toString(); |
287 | - rpc.append("<dot1q/></encapsulation></trunk></switchport>"); | 386 | + } |
288 | - rpc.append("<switchport><trunk operation=\"delete\"><allowed><vlan>"); | 387 | + |
289 | - rpc.append("<VLANIDsAllowedVLANsPortTrunkingMode>"); | 388 | + /** |
290 | - rpc.append("</VLANIDsAllowedVLANsPortTrunkingMode></vlan></allowed>"); | 389 | + * Builds the closing of a request for the configuration of an interface. |
291 | - rpc.append("</trunk></switchport></ConfigIf-Configuration>"); | 390 | + * |
391 | + * @return the closing string | ||
392 | + */ | ||
393 | + private String getClosingString() { | ||
394 | + StringBuilder rpc = new StringBuilder("</ConfigIf-Configuration>"); | ||
292 | rpc.append("</interface>"); | 395 | rpc.append("</interface>"); |
293 | rpc.append("</Device-Configuration>"); | 396 | rpc.append("</Device-Configuration>"); |
294 | rpc.append("</xml-config-data>"); | 397 | rpc.append("</xml-config-data>"); |
... | @@ -326,6 +429,16 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -326,6 +429,16 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
326 | */ | 429 | */ |
327 | @Override | 430 | @Override |
328 | public List<DeviceInterfaceDescription> getInterfaces(DeviceId deviceId) { | 431 | public List<DeviceInterfaceDescription> getInterfaces(DeviceId deviceId) { |
432 | + return getInterfaces(); | ||
433 | + } | ||
434 | + | ||
435 | + /** | ||
436 | + * Provides the interfaces configured on a device. | ||
437 | + * | ||
438 | + * @return the list of the configured interfaces | ||
439 | + */ | ||
440 | + @Override | ||
441 | + public List<DeviceInterfaceDescription> getInterfaces() { | ||
329 | NetconfController controller = | 442 | NetconfController controller = |
330 | checkNotNull(handler().get(NetconfController.class)); | 443 | checkNotNull(handler().get(NetconfController.class)); |
331 | 444 | ||
... | @@ -336,7 +449,7 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -336,7 +449,7 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
336 | reply = session.requestSync(getConfigBuilder()); | 449 | reply = session.requestSync(getConfigBuilder()); |
337 | } catch (NetconfException e) { | 450 | } catch (NetconfException e) { |
338 | log.error("Failed to retrieve configuration from device {}.", | 451 | log.error("Failed to retrieve configuration from device {}.", |
339 | - deviceId, e); | 452 | + handler().data().deviceId(), e); |
340 | return null; | 453 | return null; |
341 | } | 454 | } |
342 | 455 | ... | ... |
-
Please register or login to post a comment