Jonathan Hart

Add static factory method to create ConnectPoints from strings.

Change-Id: I743b4a4fb433ad07cf6f2cbed3da7b6e19a74ebb
......@@ -63,7 +63,6 @@ public class AddFlowsCommand extends AbstractShellCommand {
@Override
protected void execute() {
FlowRuleService flowService = get(FlowRuleService.class);
DeviceService deviceService = get(DeviceService.class);
CoreService coreService = get(CoreService.class);
......@@ -99,7 +98,6 @@ public class AddFlowsCommand extends AbstractShellCommand {
}
for (int i = 0; i < num; i++) {
latch = new CountDownLatch(2);
flowService.apply(rules.build(new FlowRuleOperationsContext() {
......@@ -121,7 +119,6 @@ public class AddFlowsCommand extends AbstractShellCommand {
}
}));
flowService.apply(remove.build(new FlowRuleOperationsContext() {
@Override
public void onSuccess(FlowRuleOperations ops) {
......@@ -135,14 +132,8 @@ public class AddFlowsCommand extends AbstractShellCommand {
}
}
}
private Object json(ObjectMapper mapper, boolean isSuccess, ArrayList<Long> elapsed) {
ObjectNode result = mapper.createObjectNode();
result.put("Success", isSuccess);
......@@ -159,6 +150,4 @@ public class AddFlowsCommand extends AbstractShellCommand {
print(" Run %s : %s", i, elapsed.get(i));
}
}
}
......
package org.onosproject.cli.net;
import java.util.List;
import java.util.Optional;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.onlab.packet.MplsLabel;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.MplsIntent;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
import java.util.List;
import java.util.Optional;
/**
* Installs MPLS intents.
......@@ -53,19 +48,14 @@ public class AddMplsIntent extends ConnectivityIntentCommand {
protected void execute() {
IntentService service = get(IntentService.class);
DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
ConnectPoint ingress = new ConnectPoint(ingressDeviceId,
ingressPortNumber);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Optional<MplsLabel> ingressLabel = Optional.empty();
if (!ingressLabelString.isEmpty()) {
ingressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString)));
}
DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
Optional<MplsLabel> egressLabel = Optional.empty();
if (!ingressLabelString.isEmpty()) {
......@@ -92,34 +82,6 @@ public class AddMplsIntent extends ConnectivityIntentCommand {
service.submit(intent);
}
/**
* Extracts the port number portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return port number as a string, empty string if the port is not found
*/
public static String getPortNumber(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(slash + 1, deviceString.length());
}
/**
* Extracts the device ID portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return device ID string
*/
public static String getDeviceId(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(0, slash);
}
protected Integer parseInt(String value) {
try {
return Integer.parseInt(value);
......
......@@ -18,8 +18,6 @@ package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.Constraint;
......@@ -31,9 +29,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
/**
* Installs connectivity intent between multiple ingress devices and a single egress device.
*/
......@@ -55,16 +50,12 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC
}
String egressDeviceString = deviceStrings[deviceStrings.length - 1];
DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
Set<ConnectPoint> ingressPoints = new HashSet<>();
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
Set<ConnectPoint> ingressPoints = new HashSet<>();
for (int index = 0; index < deviceStrings.length - 1; index++) {
String ingressDeviceString = deviceStrings[index];
DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
ingressPoints.add(ingress);
}
......@@ -85,32 +76,4 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC
service.submit(intent);
print("Multipoint to single point intent submitted:\n%s", intent.toString());
}
/**
* Extracts the port number portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return port number as a string, empty string if the port is not found
*/
private String getPortNumber(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(slash + 1, deviceString.length());
}
/**
* Extracts the device ID portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return device ID string
*/
private String getDeviceId(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(0, slash);
}
}
......
......@@ -15,14 +15,9 @@
*/
package org.onosproject.cli.net;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.OpticalConnectivityIntent;
......@@ -48,13 +43,9 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
protected void execute() {
IntentService service = get(IntentService.class);
DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
Intent intent = OpticalConnectivityIntent.builder()
.appId(appId())
......@@ -65,32 +56,4 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
service.submit(intent);
print("Optical intent submitted:\n%s", intent.toString());
}
/**
* Extracts the port number portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return port number as a string, empty string if the port is not found
*/
private String getPortNumber(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(slash + 1, deviceString.length());
}
/**
* Extracts the device ID portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return device ID string
*/
private String getDeviceId(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(0, slash);
}
}
......
......@@ -15,13 +15,9 @@
*/
package org.onosproject.cli.net;
import java.util.List;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.Constraint;
......@@ -29,8 +25,7 @@ import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.PointToPointIntent;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
import java.util.List;
/**
* Installs point-to-point connectivity intents.
......@@ -49,18 +44,13 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand {
required = true, multiValued = false)
String egressDeviceString = null;
@Override
protected void execute() {
IntentService service = get(IntentService.class);
DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
......@@ -80,32 +70,4 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand {
service.submit(intent);
print("Point to point intent submitted:\n%s", intent.toString());
}
/**
* Extracts the port number portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return port number as a string, empty string if the port is not found
*/
public static String getPortNumber(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(slash + 1, deviceString.length());
}
/**
* Extracts the device ID portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return device ID string
*/
public static String getDeviceId(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(0, slash);
}
}
......
......@@ -15,15 +15,9 @@
*/
package org.onosproject.cli.net;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
......@@ -31,8 +25,9 @@ import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Installs connectivity intent between a single ingress device and multiple egress devices.
......@@ -54,18 +49,12 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC
}
String ingressDeviceString = deviceStrings[0];
DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
ConnectPoint ingressPoint = new ConnectPoint(ingressDeviceId,
ingressPortNumber);
ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Set<ConnectPoint> egressPoints = new HashSet<>();
for (int index = 1; index < deviceStrings.length; index++) {
String egressDeviceString = deviceStrings[index];
DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
ConnectPoint egress = new ConnectPoint(egressDeviceId,
egressPortNumber);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
egressPoints.add(egress);
}
......@@ -88,32 +77,4 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC
print("Single point to multipoint intent submitted:\n%s", intent.toString());
}
/**
* Extracts the port number portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return port number as a string, empty string if the port is not found
*/
private String getPortNumber(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(slash + 1, deviceString.length());
}
/**
* Extracts the device ID portion of the ConnectPoint.
*
* @param deviceString string representing the device/port
* @return device ID string
*/
private String getDeviceId(String deviceString) {
int slash = deviceString.indexOf('/');
if (slash <= 0) {
return "";
}
return deviceString.substring(0, slash);
}
}
......
......@@ -25,11 +25,6 @@ import org.onosproject.net.link.LinkService;
import java.util.List;
import java.util.SortedSet;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
/**
* Link destination end-point completer.
*/
......@@ -49,8 +44,7 @@ public class LinkDstCompleter extends AbstractCompleter {
// Generate the device ID/port number identifiers
SortedSet<String> strings = delegate.getStrings();
try {
ConnectPoint src = new ConnectPoint(deviceId(getDeviceId(srcArg)),
portNumber(getPortNumber(srcArg)));
ConnectPoint src = ConnectPoint.deviceConnectPoint(srcArg);
service.getEgressLinks(src)
.forEach(link -> strings.add(link.dst().elementId().toString() +
"/" + link.dst().port()));
......
......@@ -19,18 +19,11 @@ import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.PortNumber;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceService;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
/**
* Lists allocations by link.
*/
......@@ -55,13 +48,9 @@ public class ResourceAllocationsCommand extends AbstractShellCommand {
Iterable<LinkResourceAllocations> itr = null;
try {
DeviceId ingressDeviceId = deviceId(getDeviceId(srcString));
PortNumber ingressPortNumber = portNumber(getPortNumber(srcString));
ConnectPoint src = new ConnectPoint(ingressDeviceId, ingressPortNumber);
ConnectPoint src = ConnectPoint.deviceConnectPoint(srcString);
DeviceId egressDeviceId = deviceId(getDeviceId(dstString));
PortNumber egressPortNumber = portNumber(getPortNumber(dstString));
ConnectPoint dst = new ConnectPoint(egressDeviceId, egressPortNumber);
ConnectPoint dst = ConnectPoint.deviceConnectPoint(dstString);
Link link = linkService.getLink(src, dst);
......
......@@ -19,18 +19,11 @@ import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.PortNumber;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.resource.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
/**
* Lists allocations by link.
*/
......@@ -55,13 +48,9 @@ public class ResourceAvailableCommand extends AbstractShellCommand {
Iterable<ResourceRequest> itr = null;
try {
DeviceId ingressDeviceId = deviceId(getDeviceId(srcString));
PortNumber ingressPortNumber = portNumber(getPortNumber(srcString));
ConnectPoint src = new ConnectPoint(ingressDeviceId, ingressPortNumber);
ConnectPoint src = ConnectPoint.deviceConnectPoint(srcString);
DeviceId egressDeviceId = deviceId(getDeviceId(dstString));
PortNumber egressPortNumber = portNumber(getPortNumber(dstString));
ConnectPoint dst = new ConnectPoint(egressDeviceId, egressPortNumber);
ConnectPoint dst = ConnectPoint.deviceConnectPoint(dstString);
Link link = linkService.getLink(src, dst);
......
......@@ -15,9 +15,12 @@
*/
package org.onosproject.net;
import com.google.common.base.MoreObjects;
import java.util.Objects;
import com.google.common.base.MoreObjects;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Abstraction of a network connection point expressed as a pair of the
......@@ -90,6 +93,42 @@ public class ConnectPoint {
return portNumber;
}
/**
* Parse a device connect point from a string.
* The connect point should be in the format "deviceUri/portNumber".
*
* @param string string to parse
* @return a ConnectPoint based on the information in the string.
*/
public static ConnectPoint deviceConnectPoint(String string) {
checkNotNull(string);
String[] splitted = string.split("/");
checkArgument(splitted.length == 2,
"Connect point must be in \"deviceUri/portNumber\" format");
return new ConnectPoint(DeviceId.deviceId(splitted[0]),
PortNumber.portNumber(splitted[1]));
}
/**
* Parse a host connect point from a string.
* The connect point should be in the format "hostId/vlanId/portNumber".
*
* @param string string to parse
* @return a ConnectPoint based on the information in the string.
*/
public static ConnectPoint hostConnectPoint(String string) {
checkNotNull(string);
String[] splitted = string.split("/");
checkArgument(splitted.length == 3,
"Connect point must be in \"hostId/vlanId/portNumber\" format");
int lastSlash = string.lastIndexOf("/");
return new ConnectPoint(HostId.hostId(string.substring(0, lastSlash)),
PortNumber.portNumber(string.substring(lastSlash + 1, string.length())));
}
@Override
public int hashCode() {
return Objects.hash(elementId, portNumber);
......
......@@ -18,12 +18,14 @@ package org.onosproject.net;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
/**
* Test of the connetion point entity.
* Test of the connection point entity.
*/
public class ConnectPointTest {
......@@ -39,7 +41,6 @@ public class ConnectPointTest {
assertEquals("incorrect element id", P2, p.port());
}
@Test
public void testEquality() {
new EqualsTester()
......@@ -48,4 +49,62 @@ public class ConnectPointTest {
.addEqualityGroup(new ConnectPoint(DID2, P1), new ConnectPoint(DID2, P1))
.testEquals();
}
@Test
public void testParseDeviceConnectPoint() {
String cp = "of:0011223344556677/1";
ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(cp);
assertEquals("of:0011223344556677", connectPoint.deviceId().toString());
assertEquals("1", connectPoint.port().toString());
expectDeviceParseException("");
expectDeviceParseException("1/");
expectDeviceParseException("1/1/1");
expectDeviceParseException("of:0011223344556677/word");
}
/**
* Parse a device connect point and expect an exception to be thrown.
*
* @param string string to parse
*/
private static void expectDeviceParseException(String string) {
try {
ConnectPoint.deviceConnectPoint(string);
fail("Expected exception was not thrown");
} catch (Exception e) {
assertTrue(true);
}
}
@Test
public void testParseHostConnectPoint() {
String cp = "16:3A:BD:6E:31:E4/-1/1";
ConnectPoint connectPoint = ConnectPoint.hostConnectPoint(cp);
assertEquals("16:3A:BD:6E:31:E4/-1", connectPoint.hostId().toString());
assertEquals("1", connectPoint.port().toString());
expectHostParseException("");
expectHostParseException("1/");
expectHostParseException("1/1");
expectHostParseException("1/1/1/1");
expectHostParseException("16:3A:BD:6E:31:E4/word/1");
expectHostParseException("16:3A:BD:6E:31:E4/1/word");
}
/**
* Parse a host connect point and expect an exception to be thrown.
*
* @param string string to parse
*/
private static void expectHostParseException(String string) {
try {
ConnectPoint.hostConnectPoint(string);
fail("Expected exception was not thrown");
} catch (Exception e) {
assertTrue(true);
}
}
}
......
......@@ -19,16 +19,10 @@ import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.provider.nil.NullProviders;
import static org.onosproject.cli.UpDownCompleter.DOWN;
import static org.onosproject.cli.UpDownCompleter.UP;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getDeviceId;
import static org.onosproject.cli.net.AddPointToPointIntentCommand.getPortNumber;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
/**
* Servers or repairs a simulated link.
......@@ -55,13 +49,9 @@ public class NullLinkCommand extends AbstractShellCommand {
NullProviders service = get(NullProviders.class);
try {
DeviceId oneId = deviceId(getDeviceId(one));
PortNumber onePort = portNumber(getPortNumber(one));
ConnectPoint onePoint = new ConnectPoint(oneId, onePort);
ConnectPoint onePoint = ConnectPoint.deviceConnectPoint(one);
DeviceId twoId = deviceId(getDeviceId(two));
PortNumber twoPort = portNumber(getPortNumber(two));
ConnectPoint twoPoint = new ConnectPoint(twoId, twoPort);
ConnectPoint twoPoint = ConnectPoint.deviceConnectPoint(two);
if (cmd.equals(UP)) {
service.repairLink(onePoint, twoPoint);
......