Add static factory method to create ConnectPoints from strings.
Change-Id: I743b4a4fb433ad07cf6f2cbed3da7b6e19a74ebb
Showing
12 changed files
with
125 additions
and
265 deletions
| ... | @@ -63,7 +63,6 @@ public class AddFlowsCommand extends AbstractShellCommand { | ... | @@ -63,7 +63,6 @@ public class AddFlowsCommand extends AbstractShellCommand { |
| 63 | 63 | ||
| 64 | @Override | 64 | @Override |
| 65 | protected void execute() { | 65 | protected void execute() { |
| 66 | - | ||
| 67 | FlowRuleService flowService = get(FlowRuleService.class); | 66 | FlowRuleService flowService = get(FlowRuleService.class); |
| 68 | DeviceService deviceService = get(DeviceService.class); | 67 | DeviceService deviceService = get(DeviceService.class); |
| 69 | CoreService coreService = get(CoreService.class); | 68 | CoreService coreService = get(CoreService.class); |
| ... | @@ -99,7 +98,6 @@ public class AddFlowsCommand extends AbstractShellCommand { | ... | @@ -99,7 +98,6 @@ public class AddFlowsCommand extends AbstractShellCommand { |
| 99 | } | 98 | } |
| 100 | 99 | ||
| 101 | for (int i = 0; i < num; i++) { | 100 | for (int i = 0; i < num; i++) { |
| 102 | - | ||
| 103 | latch = new CountDownLatch(2); | 101 | latch = new CountDownLatch(2); |
| 104 | flowService.apply(rules.build(new FlowRuleOperationsContext() { | 102 | flowService.apply(rules.build(new FlowRuleOperationsContext() { |
| 105 | 103 | ||
| ... | @@ -121,7 +119,6 @@ public class AddFlowsCommand extends AbstractShellCommand { | ... | @@ -121,7 +119,6 @@ public class AddFlowsCommand extends AbstractShellCommand { |
| 121 | } | 119 | } |
| 122 | })); | 120 | })); |
| 123 | 121 | ||
| 124 | - | ||
| 125 | flowService.apply(remove.build(new FlowRuleOperationsContext() { | 122 | flowService.apply(remove.build(new FlowRuleOperationsContext() { |
| 126 | @Override | 123 | @Override |
| 127 | public void onSuccess(FlowRuleOperations ops) { | 124 | public void onSuccess(FlowRuleOperations ops) { |
| ... | @@ -135,14 +132,8 @@ public class AddFlowsCommand extends AbstractShellCommand { | ... | @@ -135,14 +132,8 @@ public class AddFlowsCommand extends AbstractShellCommand { |
| 135 | } | 132 | } |
| 136 | 133 | ||
| 137 | } | 134 | } |
| 138 | - | ||
| 139 | - | ||
| 140 | - | ||
| 141 | - | ||
| 142 | } | 135 | } |
| 143 | 136 | ||
| 144 | - | ||
| 145 | - | ||
| 146 | private Object json(ObjectMapper mapper, boolean isSuccess, ArrayList<Long> elapsed) { | 137 | private Object json(ObjectMapper mapper, boolean isSuccess, ArrayList<Long> elapsed) { |
| 147 | ObjectNode result = mapper.createObjectNode(); | 138 | ObjectNode result = mapper.createObjectNode(); |
| 148 | result.put("Success", isSuccess); | 139 | result.put("Success", isSuccess); |
| ... | @@ -159,6 +150,4 @@ public class AddFlowsCommand extends AbstractShellCommand { | ... | @@ -159,6 +150,4 @@ public class AddFlowsCommand extends AbstractShellCommand { |
| 159 | print(" Run %s : %s", i, elapsed.get(i)); | 150 | print(" Run %s : %s", i, elapsed.get(i)); |
| 160 | } | 151 | } |
| 161 | } | 152 | } |
| 162 | - | ||
| 163 | - | ||
| 164 | } | 153 | } | ... | ... |
| 1 | package org.onosproject.cli.net; | 1 | package org.onosproject.cli.net; |
| 2 | 2 | ||
| 3 | -import java.util.List; | ||
| 4 | -import java.util.Optional; | ||
| 5 | - | ||
| 6 | import org.apache.karaf.shell.commands.Argument; | 3 | import org.apache.karaf.shell.commands.Argument; |
| 7 | import org.apache.karaf.shell.commands.Command; | 4 | import org.apache.karaf.shell.commands.Command; |
| 8 | import org.apache.karaf.shell.commands.Option; | 5 | import org.apache.karaf.shell.commands.Option; |
| 9 | import org.onlab.packet.MplsLabel; | 6 | import org.onlab.packet.MplsLabel; |
| 10 | import org.onosproject.net.ConnectPoint; | 7 | import org.onosproject.net.ConnectPoint; |
| 11 | -import org.onosproject.net.DeviceId; | ||
| 12 | -import org.onosproject.net.PortNumber; | ||
| 13 | import org.onosproject.net.flow.TrafficSelector; | 8 | import org.onosproject.net.flow.TrafficSelector; |
| 14 | import org.onosproject.net.flow.TrafficTreatment; | 9 | import org.onosproject.net.flow.TrafficTreatment; |
| 15 | import org.onosproject.net.intent.Constraint; | 10 | import org.onosproject.net.intent.Constraint; |
| 16 | import org.onosproject.net.intent.IntentService; | 11 | import org.onosproject.net.intent.IntentService; |
| 17 | import org.onosproject.net.intent.MplsIntent; | 12 | import org.onosproject.net.intent.MplsIntent; |
| 18 | 13 | ||
| 19 | -import static org.onosproject.net.DeviceId.deviceId; | 14 | +import java.util.List; |
| 20 | -import static org.onosproject.net.PortNumber.portNumber; | 15 | +import java.util.Optional; |
| 21 | 16 | ||
| 22 | /** | 17 | /** |
| 23 | * Installs MPLS intents. | 18 | * Installs MPLS intents. |
| ... | @@ -53,19 +48,14 @@ public class AddMplsIntent extends ConnectivityIntentCommand { | ... | @@ -53,19 +48,14 @@ public class AddMplsIntent extends ConnectivityIntentCommand { |
| 53 | protected void execute() { | 48 | protected void execute() { |
| 54 | IntentService service = get(IntentService.class); | 49 | IntentService service = get(IntentService.class); |
| 55 | 50 | ||
| 56 | - DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString)); | 51 | + ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString); |
| 57 | - PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString)); | ||
| 58 | - ConnectPoint ingress = new ConnectPoint(ingressDeviceId, | ||
| 59 | - ingressPortNumber); | ||
| 60 | Optional<MplsLabel> ingressLabel = Optional.empty(); | 52 | Optional<MplsLabel> ingressLabel = Optional.empty(); |
| 61 | if (!ingressLabelString.isEmpty()) { | 53 | if (!ingressLabelString.isEmpty()) { |
| 62 | ingressLabel = Optional | 54 | ingressLabel = Optional |
| 63 | .ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString))); | 55 | .ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString))); |
| 64 | } | 56 | } |
| 65 | 57 | ||
| 66 | - DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString)); | 58 | + ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); |
| 67 | - PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | ||
| 68 | - ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 69 | 59 | ||
| 70 | Optional<MplsLabel> egressLabel = Optional.empty(); | 60 | Optional<MplsLabel> egressLabel = Optional.empty(); |
| 71 | if (!ingressLabelString.isEmpty()) { | 61 | if (!ingressLabelString.isEmpty()) { |
| ... | @@ -92,34 +82,6 @@ public class AddMplsIntent extends ConnectivityIntentCommand { | ... | @@ -92,34 +82,6 @@ public class AddMplsIntent extends ConnectivityIntentCommand { |
| 92 | service.submit(intent); | 82 | service.submit(intent); |
| 93 | } | 83 | } |
| 94 | 84 | ||
| 95 | - /** | ||
| 96 | - * Extracts the port number portion of the ConnectPoint. | ||
| 97 | - * | ||
| 98 | - * @param deviceString string representing the device/port | ||
| 99 | - * @return port number as a string, empty string if the port is not found | ||
| 100 | - */ | ||
| 101 | - public static String getPortNumber(String deviceString) { | ||
| 102 | - int slash = deviceString.indexOf('/'); | ||
| 103 | - if (slash <= 0) { | ||
| 104 | - return ""; | ||
| 105 | - } | ||
| 106 | - return deviceString.substring(slash + 1, deviceString.length()); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - /** | ||
| 110 | - * Extracts the device ID portion of the ConnectPoint. | ||
| 111 | - * | ||
| 112 | - * @param deviceString string representing the device/port | ||
| 113 | - * @return device ID string | ||
| 114 | - */ | ||
| 115 | - public static String getDeviceId(String deviceString) { | ||
| 116 | - int slash = deviceString.indexOf('/'); | ||
| 117 | - if (slash <= 0) { | ||
| 118 | - return ""; | ||
| 119 | - } | ||
| 120 | - return deviceString.substring(0, slash); | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | protected Integer parseInt(String value) { | 85 | protected Integer parseInt(String value) { |
| 124 | try { | 86 | try { |
| 125 | return Integer.parseInt(value); | 87 | return Integer.parseInt(value); | ... | ... |
| ... | @@ -18,8 +18,6 @@ package org.onosproject.cli.net; | ... | @@ -18,8 +18,6 @@ package org.onosproject.cli.net; |
| 18 | import org.apache.karaf.shell.commands.Argument; | 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.net.ConnectPoint; | 20 | import org.onosproject.net.ConnectPoint; |
| 21 | -import org.onosproject.net.DeviceId; | ||
| 22 | -import org.onosproject.net.PortNumber; | ||
| 23 | import org.onosproject.net.flow.TrafficSelector; | 21 | import org.onosproject.net.flow.TrafficSelector; |
| 24 | import org.onosproject.net.flow.TrafficTreatment; | 22 | import org.onosproject.net.flow.TrafficTreatment; |
| 25 | import org.onosproject.net.intent.Constraint; | 23 | import org.onosproject.net.intent.Constraint; |
| ... | @@ -31,9 +29,6 @@ import java.util.HashSet; | ... | @@ -31,9 +29,6 @@ import java.util.HashSet; |
| 31 | import java.util.List; | 29 | import java.util.List; |
| 32 | import java.util.Set; | 30 | import java.util.Set; |
| 33 | 31 | ||
| 34 | -import static org.onosproject.net.DeviceId.deviceId; | ||
| 35 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 36 | - | ||
| 37 | /** | 32 | /** |
| 38 | * Installs connectivity intent between multiple ingress devices and a single egress device. | 33 | * Installs connectivity intent between multiple ingress devices and a single egress device. |
| 39 | */ | 34 | */ |
| ... | @@ -55,16 +50,12 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC | ... | @@ -55,16 +50,12 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC |
| 55 | } | 50 | } |
| 56 | 51 | ||
| 57 | String egressDeviceString = deviceStrings[deviceStrings.length - 1]; | 52 | String egressDeviceString = deviceStrings[deviceStrings.length - 1]; |
| 58 | - DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString)); | 53 | + ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); |
| 59 | - PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | ||
| 60 | - ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 61 | - Set<ConnectPoint> ingressPoints = new HashSet<>(); | ||
| 62 | 54 | ||
| 55 | + Set<ConnectPoint> ingressPoints = new HashSet<>(); | ||
| 63 | for (int index = 0; index < deviceStrings.length - 1; index++) { | 56 | for (int index = 0; index < deviceStrings.length - 1; index++) { |
| 64 | String ingressDeviceString = deviceStrings[index]; | 57 | String ingressDeviceString = deviceStrings[index]; |
| 65 | - DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString)); | 58 | + ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString); |
| 66 | - PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString)); | ||
| 67 | - ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber); | ||
| 68 | ingressPoints.add(ingress); | 59 | ingressPoints.add(ingress); |
| 69 | } | 60 | } |
| 70 | 61 | ||
| ... | @@ -85,32 +76,4 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC | ... | @@ -85,32 +76,4 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC |
| 85 | service.submit(intent); | 76 | service.submit(intent); |
| 86 | print("Multipoint to single point intent submitted:\n%s", intent.toString()); | 77 | print("Multipoint to single point intent submitted:\n%s", intent.toString()); |
| 87 | } | 78 | } |
| 88 | - | ||
| 89 | - /** | ||
| 90 | - * Extracts the port number portion of the ConnectPoint. | ||
| 91 | - * | ||
| 92 | - * @param deviceString string representing the device/port | ||
| 93 | - * @return port number as a string, empty string if the port is not found | ||
| 94 | - */ | ||
| 95 | - private String getPortNumber(String deviceString) { | ||
| 96 | - int slash = deviceString.indexOf('/'); | ||
| 97 | - if (slash <= 0) { | ||
| 98 | - return ""; | ||
| 99 | - } | ||
| 100 | - return deviceString.substring(slash + 1, deviceString.length()); | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * Extracts the device ID portion of the ConnectPoint. | ||
| 105 | - * | ||
| 106 | - * @param deviceString string representing the device/port | ||
| 107 | - * @return device ID string | ||
| 108 | - */ | ||
| 109 | - private String getDeviceId(String deviceString) { | ||
| 110 | - int slash = deviceString.indexOf('/'); | ||
| 111 | - if (slash <= 0) { | ||
| 112 | - return ""; | ||
| 113 | - } | ||
| 114 | - return deviceString.substring(0, slash); | ||
| 115 | - } | ||
| 116 | } | 79 | } | ... | ... |
| ... | @@ -15,14 +15,9 @@ | ... | @@ -15,14 +15,9 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
| 17 | 17 | ||
| 18 | -import static org.onosproject.net.DeviceId.deviceId; | ||
| 19 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 20 | - | ||
| 21 | import org.apache.karaf.shell.commands.Argument; | 18 | import org.apache.karaf.shell.commands.Argument; |
| 22 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 23 | import org.onosproject.net.ConnectPoint; | 20 | import org.onosproject.net.ConnectPoint; |
| 24 | -import org.onosproject.net.DeviceId; | ||
| 25 | -import org.onosproject.net.PortNumber; | ||
| 26 | import org.onosproject.net.intent.Intent; | 21 | import org.onosproject.net.intent.Intent; |
| 27 | import org.onosproject.net.intent.IntentService; | 22 | import org.onosproject.net.intent.IntentService; |
| 28 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 23 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
| ... | @@ -48,13 +43,9 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | ... | @@ -48,13 +43,9 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
| 48 | protected void execute() { | 43 | protected void execute() { |
| 49 | IntentService service = get(IntentService.class); | 44 | IntentService service = get(IntentService.class); |
| 50 | 45 | ||
| 51 | - DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString)); | 46 | + ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString); |
| 52 | - PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString)); | ||
| 53 | - ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber); | ||
| 54 | 47 | ||
| 55 | - DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString)); | 48 | + ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); |
| 56 | - PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | ||
| 57 | - ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 58 | 49 | ||
| 59 | Intent intent = OpticalConnectivityIntent.builder() | 50 | Intent intent = OpticalConnectivityIntent.builder() |
| 60 | .appId(appId()) | 51 | .appId(appId()) |
| ... | @@ -65,32 +56,4 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | ... | @@ -65,32 +56,4 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
| 65 | service.submit(intent); | 56 | service.submit(intent); |
| 66 | print("Optical intent submitted:\n%s", intent.toString()); | 57 | print("Optical intent submitted:\n%s", intent.toString()); |
| 67 | } | 58 | } |
| 68 | - | ||
| 69 | - /** | ||
| 70 | - * Extracts the port number portion of the ConnectPoint. | ||
| 71 | - * | ||
| 72 | - * @param deviceString string representing the device/port | ||
| 73 | - * @return port number as a string, empty string if the port is not found | ||
| 74 | - */ | ||
| 75 | - private String getPortNumber(String deviceString) { | ||
| 76 | - int slash = deviceString.indexOf('/'); | ||
| 77 | - if (slash <= 0) { | ||
| 78 | - return ""; | ||
| 79 | - } | ||
| 80 | - return deviceString.substring(slash + 1, deviceString.length()); | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - /** | ||
| 84 | - * Extracts the device ID portion of the ConnectPoint. | ||
| 85 | - * | ||
| 86 | - * @param deviceString string representing the device/port | ||
| 87 | - * @return device ID string | ||
| 88 | - */ | ||
| 89 | - private String getDeviceId(String deviceString) { | ||
| 90 | - int slash = deviceString.indexOf('/'); | ||
| 91 | - if (slash <= 0) { | ||
| 92 | - return ""; | ||
| 93 | - } | ||
| 94 | - return deviceString.substring(0, slash); | ||
| 95 | - } | ||
| 96 | } | 59 | } | ... | ... |
| ... | @@ -15,13 +15,9 @@ | ... | @@ -15,13 +15,9 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
| 17 | 17 | ||
| 18 | -import java.util.List; | ||
| 19 | - | ||
| 20 | import org.apache.karaf.shell.commands.Argument; | 18 | import org.apache.karaf.shell.commands.Argument; |
| 21 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 22 | import org.onosproject.net.ConnectPoint; | 20 | import org.onosproject.net.ConnectPoint; |
| 23 | -import org.onosproject.net.DeviceId; | ||
| 24 | -import org.onosproject.net.PortNumber; | ||
| 25 | import org.onosproject.net.flow.TrafficSelector; | 21 | import org.onosproject.net.flow.TrafficSelector; |
| 26 | import org.onosproject.net.flow.TrafficTreatment; | 22 | import org.onosproject.net.flow.TrafficTreatment; |
| 27 | import org.onosproject.net.intent.Constraint; | 23 | import org.onosproject.net.intent.Constraint; |
| ... | @@ -29,8 +25,7 @@ import org.onosproject.net.intent.Intent; | ... | @@ -29,8 +25,7 @@ import org.onosproject.net.intent.Intent; |
| 29 | import org.onosproject.net.intent.IntentService; | 25 | import org.onosproject.net.intent.IntentService; |
| 30 | import org.onosproject.net.intent.PointToPointIntent; | 26 | import org.onosproject.net.intent.PointToPointIntent; |
| 31 | 27 | ||
| 32 | -import static org.onosproject.net.DeviceId.deviceId; | 28 | +import java.util.List; |
| 33 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 34 | 29 | ||
| 35 | /** | 30 | /** |
| 36 | * Installs point-to-point connectivity intents. | 31 | * Installs point-to-point connectivity intents. |
| ... | @@ -49,18 +44,13 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { | ... | @@ -49,18 +44,13 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { |
| 49 | required = true, multiValued = false) | 44 | required = true, multiValued = false) |
| 50 | String egressDeviceString = null; | 45 | String egressDeviceString = null; |
| 51 | 46 | ||
| 52 | - | ||
| 53 | @Override | 47 | @Override |
| 54 | protected void execute() { | 48 | protected void execute() { |
| 55 | IntentService service = get(IntentService.class); | 49 | IntentService service = get(IntentService.class); |
| 56 | 50 | ||
| 57 | - DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString)); | 51 | + ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString); |
| 58 | - PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString)); | ||
| 59 | - ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber); | ||
| 60 | 52 | ||
| 61 | - DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString)); | 53 | + ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); |
| 62 | - PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | ||
| 63 | - ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 64 | 54 | ||
| 65 | TrafficSelector selector = buildTrafficSelector(); | 55 | TrafficSelector selector = buildTrafficSelector(); |
| 66 | TrafficTreatment treatment = buildTrafficTreatment(); | 56 | TrafficTreatment treatment = buildTrafficTreatment(); |
| ... | @@ -80,32 +70,4 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { | ... | @@ -80,32 +70,4 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { |
| 80 | service.submit(intent); | 70 | service.submit(intent); |
| 81 | print("Point to point intent submitted:\n%s", intent.toString()); | 71 | print("Point to point intent submitted:\n%s", intent.toString()); |
| 82 | } | 72 | } |
| 83 | - | ||
| 84 | - /** | ||
| 85 | - * Extracts the port number portion of the ConnectPoint. | ||
| 86 | - * | ||
| 87 | - * @param deviceString string representing the device/port | ||
| 88 | - * @return port number as a string, empty string if the port is not found | ||
| 89 | - */ | ||
| 90 | - public static String getPortNumber(String deviceString) { | ||
| 91 | - int slash = deviceString.indexOf('/'); | ||
| 92 | - if (slash <= 0) { | ||
| 93 | - return ""; | ||
| 94 | - } | ||
| 95 | - return deviceString.substring(slash + 1, deviceString.length()); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - /** | ||
| 99 | - * Extracts the device ID portion of the ConnectPoint. | ||
| 100 | - * | ||
| 101 | - * @param deviceString string representing the device/port | ||
| 102 | - * @return device ID string | ||
| 103 | - */ | ||
| 104 | - public static String getDeviceId(String deviceString) { | ||
| 105 | - int slash = deviceString.indexOf('/'); | ||
| 106 | - if (slash <= 0) { | ||
| 107 | - return ""; | ||
| 108 | - } | ||
| 109 | - return deviceString.substring(0, slash); | ||
| 110 | - } | ||
| 111 | } | 73 | } | ... | ... |
| ... | @@ -15,15 +15,9 @@ | ... | @@ -15,15 +15,9 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
| 17 | 17 | ||
| 18 | -import java.util.HashSet; | ||
| 19 | -import java.util.List; | ||
| 20 | -import java.util.Set; | ||
| 21 | - | ||
| 22 | import org.apache.karaf.shell.commands.Argument; | 18 | import org.apache.karaf.shell.commands.Argument; |
| 23 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 24 | import org.onosproject.net.ConnectPoint; | 20 | import org.onosproject.net.ConnectPoint; |
| 25 | -import org.onosproject.net.DeviceId; | ||
| 26 | -import org.onosproject.net.PortNumber; | ||
| 27 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 21 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 28 | import org.onosproject.net.flow.TrafficSelector; | 22 | import org.onosproject.net.flow.TrafficSelector; |
| 29 | import org.onosproject.net.flow.TrafficTreatment; | 23 | import org.onosproject.net.flow.TrafficTreatment; |
| ... | @@ -31,8 +25,9 @@ import org.onosproject.net.intent.Constraint; | ... | @@ -31,8 +25,9 @@ import org.onosproject.net.intent.Constraint; |
| 31 | import org.onosproject.net.intent.IntentService; | 25 | import org.onosproject.net.intent.IntentService; |
| 32 | import org.onosproject.net.intent.SinglePointToMultiPointIntent; | 26 | import org.onosproject.net.intent.SinglePointToMultiPointIntent; |
| 33 | 27 | ||
| 34 | -import static org.onosproject.net.DeviceId.deviceId; | 28 | +import java.util.HashSet; |
| 35 | -import static org.onosproject.net.PortNumber.portNumber; | 29 | +import java.util.List; |
| 30 | +import java.util.Set; | ||
| 36 | 31 | ||
| 37 | /** | 32 | /** |
| 38 | * Installs connectivity intent between a single ingress device and multiple egress devices. | 33 | * Installs connectivity intent between a single ingress device and multiple egress devices. |
| ... | @@ -54,18 +49,12 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC | ... | @@ -54,18 +49,12 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC |
| 54 | } | 49 | } |
| 55 | 50 | ||
| 56 | String ingressDeviceString = deviceStrings[0]; | 51 | String ingressDeviceString = deviceStrings[0]; |
| 57 | - DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString)); | 52 | + ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString); |
| 58 | - PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString)); | ||
| 59 | - ConnectPoint ingressPoint = new ConnectPoint(ingressDeviceId, | ||
| 60 | - ingressPortNumber); | ||
| 61 | 53 | ||
| 62 | Set<ConnectPoint> egressPoints = new HashSet<>(); | 54 | Set<ConnectPoint> egressPoints = new HashSet<>(); |
| 63 | for (int index = 1; index < deviceStrings.length; index++) { | 55 | for (int index = 1; index < deviceStrings.length; index++) { |
| 64 | String egressDeviceString = deviceStrings[index]; | 56 | String egressDeviceString = deviceStrings[index]; |
| 65 | - DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString)); | 57 | + ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); |
| 66 | - PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | ||
| 67 | - ConnectPoint egress = new ConnectPoint(egressDeviceId, | ||
| 68 | - egressPortNumber); | ||
| 69 | egressPoints.add(egress); | 58 | egressPoints.add(egress); |
| 70 | } | 59 | } |
| 71 | 60 | ||
| ... | @@ -88,32 +77,4 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC | ... | @@ -88,32 +77,4 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC |
| 88 | print("Single point to multipoint intent submitted:\n%s", intent.toString()); | 77 | print("Single point to multipoint intent submitted:\n%s", intent.toString()); |
| 89 | } | 78 | } |
| 90 | 79 | ||
| 91 | - /** | ||
| 92 | - * Extracts the port number portion of the ConnectPoint. | ||
| 93 | - * | ||
| 94 | - * @param deviceString string representing the device/port | ||
| 95 | - * @return port number as a string, empty string if the port is not found | ||
| 96 | - */ | ||
| 97 | - private String getPortNumber(String deviceString) { | ||
| 98 | - int slash = deviceString.indexOf('/'); | ||
| 99 | - if (slash <= 0) { | ||
| 100 | - return ""; | ||
| 101 | - } | ||
| 102 | - return deviceString.substring(slash + 1, deviceString.length()); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - /** | ||
| 106 | - * Extracts the device ID portion of the ConnectPoint. | ||
| 107 | - * | ||
| 108 | - * @param deviceString string representing the device/port | ||
| 109 | - * @return device ID string | ||
| 110 | - */ | ||
| 111 | - private String getDeviceId(String deviceString) { | ||
| 112 | - int slash = deviceString.indexOf('/'); | ||
| 113 | - if (slash <= 0) { | ||
| 114 | - return ""; | ||
| 115 | - } | ||
| 116 | - return deviceString.substring(0, slash); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | } | 80 | } | ... | ... |
| ... | @@ -25,11 +25,6 @@ import org.onosproject.net.link.LinkService; | ... | @@ -25,11 +25,6 @@ import org.onosproject.net.link.LinkService; |
| 25 | import java.util.List; | 25 | import java.util.List; |
| 26 | import java.util.SortedSet; | 26 | import java.util.SortedSet; |
| 27 | 27 | ||
| 28 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId; | ||
| 29 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber; | ||
| 30 | -import static org.onosproject.net.DeviceId.deviceId; | ||
| 31 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 32 | - | ||
| 33 | /** | 28 | /** |
| 34 | * Link destination end-point completer. | 29 | * Link destination end-point completer. |
| 35 | */ | 30 | */ |
| ... | @@ -49,8 +44,7 @@ public class LinkDstCompleter extends AbstractCompleter { | ... | @@ -49,8 +44,7 @@ public class LinkDstCompleter extends AbstractCompleter { |
| 49 | // Generate the device ID/port number identifiers | 44 | // Generate the device ID/port number identifiers |
| 50 | SortedSet<String> strings = delegate.getStrings(); | 45 | SortedSet<String> strings = delegate.getStrings(); |
| 51 | try { | 46 | try { |
| 52 | - ConnectPoint src = new ConnectPoint(deviceId(getDeviceId(srcArg)), | 47 | + ConnectPoint src = ConnectPoint.deviceConnectPoint(srcArg); |
| 53 | - portNumber(getPortNumber(srcArg))); | ||
| 54 | service.getEgressLinks(src) | 48 | service.getEgressLinks(src) |
| 55 | .forEach(link -> strings.add(link.dst().elementId().toString() + | 49 | .forEach(link -> strings.add(link.dst().elementId().toString() + |
| 56 | "/" + link.dst().port())); | 50 | "/" + link.dst().port())); | ... | ... |
| ... | @@ -19,18 +19,11 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -19,18 +19,11 @@ import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; | 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | -import org.onosproject.net.DeviceId; | ||
| 23 | import org.onosproject.net.Link; | 22 | import org.onosproject.net.Link; |
| 24 | -import org.onosproject.net.PortNumber; | ||
| 25 | import org.onosproject.net.link.LinkService; | 23 | import org.onosproject.net.link.LinkService; |
| 26 | import org.onosproject.net.resource.LinkResourceAllocations; | 24 | import org.onosproject.net.resource.LinkResourceAllocations; |
| 27 | import org.onosproject.net.resource.LinkResourceService; | 25 | import org.onosproject.net.resource.LinkResourceService; |
| 28 | 26 | ||
| 29 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId; | ||
| 30 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber; | ||
| 31 | -import static org.onosproject.net.DeviceId.deviceId; | ||
| 32 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 33 | - | ||
| 34 | /** | 27 | /** |
| 35 | * Lists allocations by link. | 28 | * Lists allocations by link. |
| 36 | */ | 29 | */ |
| ... | @@ -55,13 +48,9 @@ public class ResourceAllocationsCommand extends AbstractShellCommand { | ... | @@ -55,13 +48,9 @@ public class ResourceAllocationsCommand extends AbstractShellCommand { |
| 55 | 48 | ||
| 56 | Iterable<LinkResourceAllocations> itr = null; | 49 | Iterable<LinkResourceAllocations> itr = null; |
| 57 | try { | 50 | try { |
| 58 | - DeviceId ingressDeviceId = deviceId(getDeviceId(srcString)); | 51 | + ConnectPoint src = ConnectPoint.deviceConnectPoint(srcString); |
| 59 | - PortNumber ingressPortNumber = portNumber(getPortNumber(srcString)); | ||
| 60 | - ConnectPoint src = new ConnectPoint(ingressDeviceId, ingressPortNumber); | ||
| 61 | 52 | ||
| 62 | - DeviceId egressDeviceId = deviceId(getDeviceId(dstString)); | 53 | + ConnectPoint dst = ConnectPoint.deviceConnectPoint(dstString); |
| 63 | - PortNumber egressPortNumber = portNumber(getPortNumber(dstString)); | ||
| 64 | - ConnectPoint dst = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 65 | 54 | ||
| 66 | Link link = linkService.getLink(src, dst); | 55 | Link link = linkService.getLink(src, dst); |
| 67 | 56 | ... | ... |
| ... | @@ -19,18 +19,11 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -19,18 +19,11 @@ import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; | 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | -import org.onosproject.net.DeviceId; | ||
| 23 | import org.onosproject.net.Link; | 22 | import org.onosproject.net.Link; |
| 24 | -import org.onosproject.net.PortNumber; | ||
| 25 | import org.onosproject.net.link.LinkService; | 23 | import org.onosproject.net.link.LinkService; |
| 26 | import org.onosproject.net.resource.LinkResourceService; | 24 | import org.onosproject.net.resource.LinkResourceService; |
| 27 | import org.onosproject.net.resource.ResourceRequest; | 25 | import org.onosproject.net.resource.ResourceRequest; |
| 28 | 26 | ||
| 29 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId; | ||
| 30 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber; | ||
| 31 | -import static org.onosproject.net.DeviceId.deviceId; | ||
| 32 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 33 | - | ||
| 34 | /** | 27 | /** |
| 35 | * Lists allocations by link. | 28 | * Lists allocations by link. |
| 36 | */ | 29 | */ |
| ... | @@ -55,13 +48,9 @@ public class ResourceAvailableCommand extends AbstractShellCommand { | ... | @@ -55,13 +48,9 @@ public class ResourceAvailableCommand extends AbstractShellCommand { |
| 55 | 48 | ||
| 56 | Iterable<ResourceRequest> itr = null; | 49 | Iterable<ResourceRequest> itr = null; |
| 57 | try { | 50 | try { |
| 58 | - DeviceId ingressDeviceId = deviceId(getDeviceId(srcString)); | 51 | + ConnectPoint src = ConnectPoint.deviceConnectPoint(srcString); |
| 59 | - PortNumber ingressPortNumber = portNumber(getPortNumber(srcString)); | ||
| 60 | - ConnectPoint src = new ConnectPoint(ingressDeviceId, ingressPortNumber); | ||
| 61 | 52 | ||
| 62 | - DeviceId egressDeviceId = deviceId(getDeviceId(dstString)); | 53 | + ConnectPoint dst = ConnectPoint.deviceConnectPoint(dstString); |
| 63 | - PortNumber egressPortNumber = portNumber(getPortNumber(dstString)); | ||
| 64 | - ConnectPoint dst = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 65 | 54 | ||
| 66 | Link link = linkService.getLink(src, dst); | 55 | Link link = linkService.getLink(src, dst); |
| 67 | 56 | ... | ... |
| ... | @@ -15,9 +15,12 @@ | ... | @@ -15,9 +15,12 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net; | 16 | package org.onosproject.net; |
| 17 | 17 | ||
| 18 | +import com.google.common.base.MoreObjects; | ||
| 19 | + | ||
| 18 | import java.util.Objects; | 20 | import java.util.Objects; |
| 19 | 21 | ||
| 20 | -import com.google.common.base.MoreObjects; | 22 | +import static com.google.common.base.Preconditions.checkArgument; |
| 23 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 21 | 24 | ||
| 22 | /** | 25 | /** |
| 23 | * Abstraction of a network connection point expressed as a pair of the | 26 | * Abstraction of a network connection point expressed as a pair of the |
| ... | @@ -90,6 +93,42 @@ public class ConnectPoint { | ... | @@ -90,6 +93,42 @@ public class ConnectPoint { |
| 90 | return portNumber; | 93 | return portNumber; |
| 91 | } | 94 | } |
| 92 | 95 | ||
| 96 | + /** | ||
| 97 | + * Parse a device connect point from a string. | ||
| 98 | + * The connect point should be in the format "deviceUri/portNumber". | ||
| 99 | + * | ||
| 100 | + * @param string string to parse | ||
| 101 | + * @return a ConnectPoint based on the information in the string. | ||
| 102 | + */ | ||
| 103 | + public static ConnectPoint deviceConnectPoint(String string) { | ||
| 104 | + checkNotNull(string); | ||
| 105 | + String[] splitted = string.split("/"); | ||
| 106 | + checkArgument(splitted.length == 2, | ||
| 107 | + "Connect point must be in \"deviceUri/portNumber\" format"); | ||
| 108 | + | ||
| 109 | + return new ConnectPoint(DeviceId.deviceId(splitted[0]), | ||
| 110 | + PortNumber.portNumber(splitted[1])); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * Parse a host connect point from a string. | ||
| 115 | + * The connect point should be in the format "hostId/vlanId/portNumber". | ||
| 116 | + * | ||
| 117 | + * @param string string to parse | ||
| 118 | + * @return a ConnectPoint based on the information in the string. | ||
| 119 | + */ | ||
| 120 | + public static ConnectPoint hostConnectPoint(String string) { | ||
| 121 | + checkNotNull(string); | ||
| 122 | + String[] splitted = string.split("/"); | ||
| 123 | + checkArgument(splitted.length == 3, | ||
| 124 | + "Connect point must be in \"hostId/vlanId/portNumber\" format"); | ||
| 125 | + | ||
| 126 | + int lastSlash = string.lastIndexOf("/"); | ||
| 127 | + | ||
| 128 | + return new ConnectPoint(HostId.hostId(string.substring(0, lastSlash)), | ||
| 129 | + PortNumber.portNumber(string.substring(lastSlash + 1, string.length()))); | ||
| 130 | + } | ||
| 131 | + | ||
| 93 | @Override | 132 | @Override |
| 94 | public int hashCode() { | 133 | public int hashCode() { |
| 95 | return Objects.hash(elementId, portNumber); | 134 | return Objects.hash(elementId, portNumber); | ... | ... |
| ... | @@ -18,12 +18,14 @@ package org.onosproject.net; | ... | @@ -18,12 +18,14 @@ package org.onosproject.net; |
| 18 | import com.google.common.testing.EqualsTester; | 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.junit.Test; | 19 | import org.junit.Test; |
| 20 | 20 | ||
| 21 | +import static junit.framework.TestCase.fail; | ||
| 21 | import static org.junit.Assert.assertEquals; | 22 | import static org.junit.Assert.assertEquals; |
| 23 | +import static org.junit.Assert.assertTrue; | ||
| 22 | import static org.onosproject.net.DeviceId.deviceId; | 24 | import static org.onosproject.net.DeviceId.deviceId; |
| 23 | import static org.onosproject.net.PortNumber.portNumber; | 25 | import static org.onosproject.net.PortNumber.portNumber; |
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 26 | - * Test of the connetion point entity. | 28 | + * Test of the connection point entity. |
| 27 | */ | 29 | */ |
| 28 | public class ConnectPointTest { | 30 | public class ConnectPointTest { |
| 29 | 31 | ||
| ... | @@ -39,7 +41,6 @@ public class ConnectPointTest { | ... | @@ -39,7 +41,6 @@ public class ConnectPointTest { |
| 39 | assertEquals("incorrect element id", P2, p.port()); | 41 | assertEquals("incorrect element id", P2, p.port()); |
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | - | ||
| 43 | @Test | 44 | @Test |
| 44 | public void testEquality() { | 45 | public void testEquality() { |
| 45 | new EqualsTester() | 46 | new EqualsTester() |
| ... | @@ -48,4 +49,62 @@ public class ConnectPointTest { | ... | @@ -48,4 +49,62 @@ public class ConnectPointTest { |
| 48 | .addEqualityGroup(new ConnectPoint(DID2, P1), new ConnectPoint(DID2, P1)) | 49 | .addEqualityGroup(new ConnectPoint(DID2, P1), new ConnectPoint(DID2, P1)) |
| 49 | .testEquals(); | 50 | .testEquals(); |
| 50 | } | 51 | } |
| 52 | + | ||
| 53 | + @Test | ||
| 54 | + public void testParseDeviceConnectPoint() { | ||
| 55 | + String cp = "of:0011223344556677/1"; | ||
| 56 | + | ||
| 57 | + ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(cp); | ||
| 58 | + assertEquals("of:0011223344556677", connectPoint.deviceId().toString()); | ||
| 59 | + assertEquals("1", connectPoint.port().toString()); | ||
| 60 | + | ||
| 61 | + expectDeviceParseException(""); | ||
| 62 | + expectDeviceParseException("1/"); | ||
| 63 | + expectDeviceParseException("1/1/1"); | ||
| 64 | + expectDeviceParseException("of:0011223344556677/word"); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * Parse a device connect point and expect an exception to be thrown. | ||
| 69 | + * | ||
| 70 | + * @param string string to parse | ||
| 71 | + */ | ||
| 72 | + private static void expectDeviceParseException(String string) { | ||
| 73 | + try { | ||
| 74 | + ConnectPoint.deviceConnectPoint(string); | ||
| 75 | + fail("Expected exception was not thrown"); | ||
| 76 | + } catch (Exception e) { | ||
| 77 | + assertTrue(true); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Test | ||
| 82 | + public void testParseHostConnectPoint() { | ||
| 83 | + String cp = "16:3A:BD:6E:31:E4/-1/1"; | ||
| 84 | + | ||
| 85 | + ConnectPoint connectPoint = ConnectPoint.hostConnectPoint(cp); | ||
| 86 | + assertEquals("16:3A:BD:6E:31:E4/-1", connectPoint.hostId().toString()); | ||
| 87 | + assertEquals("1", connectPoint.port().toString()); | ||
| 88 | + | ||
| 89 | + expectHostParseException(""); | ||
| 90 | + expectHostParseException("1/"); | ||
| 91 | + expectHostParseException("1/1"); | ||
| 92 | + expectHostParseException("1/1/1/1"); | ||
| 93 | + expectHostParseException("16:3A:BD:6E:31:E4/word/1"); | ||
| 94 | + expectHostParseException("16:3A:BD:6E:31:E4/1/word"); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * Parse a host connect point and expect an exception to be thrown. | ||
| 99 | + * | ||
| 100 | + * @param string string to parse | ||
| 101 | + */ | ||
| 102 | + private static void expectHostParseException(String string) { | ||
| 103 | + try { | ||
| 104 | + ConnectPoint.hostConnectPoint(string); | ||
| 105 | + fail("Expected exception was not thrown"); | ||
| 106 | + } catch (Exception e) { | ||
| 107 | + assertTrue(true); | ||
| 108 | + } | ||
| 109 | + } | ||
| 51 | } | 110 | } | ... | ... |
| ... | @@ -19,16 +19,10 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -19,16 +19,10 @@ import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; | 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | -import org.onosproject.net.DeviceId; | ||
| 23 | -import org.onosproject.net.PortNumber; | ||
| 24 | import org.onosproject.provider.nil.NullProviders; | 22 | import org.onosproject.provider.nil.NullProviders; |
| 25 | 23 | ||
| 26 | import static org.onosproject.cli.UpDownCompleter.DOWN; | 24 | import static org.onosproject.cli.UpDownCompleter.DOWN; |
| 27 | import static org.onosproject.cli.UpDownCompleter.UP; | 25 | import static org.onosproject.cli.UpDownCompleter.UP; |
| 28 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId; | ||
| 29 | -import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber; | ||
| 30 | -import static org.onosproject.net.DeviceId.deviceId; | ||
| 31 | -import static org.onosproject.net.PortNumber.portNumber; | ||
| 32 | 26 | ||
| 33 | /** | 27 | /** |
| 34 | * Servers or repairs a simulated link. | 28 | * Servers or repairs a simulated link. |
| ... | @@ -55,13 +49,9 @@ public class NullLinkCommand extends AbstractShellCommand { | ... | @@ -55,13 +49,9 @@ public class NullLinkCommand extends AbstractShellCommand { |
| 55 | NullProviders service = get(NullProviders.class); | 49 | NullProviders service = get(NullProviders.class); |
| 56 | 50 | ||
| 57 | try { | 51 | try { |
| 58 | - DeviceId oneId = deviceId(getDeviceId(one)); | 52 | + ConnectPoint onePoint = ConnectPoint.deviceConnectPoint(one); |
| 59 | - PortNumber onePort = portNumber(getPortNumber(one)); | ||
| 60 | - ConnectPoint onePoint = new ConnectPoint(oneId, onePort); | ||
| 61 | 53 | ||
| 62 | - DeviceId twoId = deviceId(getDeviceId(two)); | 54 | + ConnectPoint twoPoint = ConnectPoint.deviceConnectPoint(two); |
| 63 | - PortNumber twoPort = portNumber(getPortNumber(two)); | ||
| 64 | - ConnectPoint twoPoint = new ConnectPoint(twoId, twoPort); | ||
| 65 | 55 | ||
| 66 | if (cmd.equals(UP)) { | 56 | if (cmd.equals(UP)) { |
| 67 | service.repairLink(onePoint, twoPoint); | 57 | service.repairLink(onePoint, twoPoint); | ... | ... |
-
Please register or login to post a comment