Java Code Examples for org.onosproject.net.ConnectPoint#fromString()
The following examples show how to use
org.onosproject.net.ConnectPoint#fromString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultFabricNetworkTest.java From onos with Apache License 2.0 | 5 votes |
private static Interface createInterface(int index) { String name = "INTF_NAME_" + index; ConnectPoint cp = ConnectPoint.fromString("of:0011223344556677/" + index); InterfaceIpAddress intfIp1 = InterfaceIpAddress.valueOf("10.10.10." + index + "/32"); InterfaceIpAddress intfIp2 = InterfaceIpAddress.valueOf("20.20.20." + index + "/32"); List<InterfaceIpAddress> intfIps = ImmutableList.of(intfIp1, intfIp2); MacAddress mac = MacAddress.valueOf("00:00:00:00:00:00"); VlanId vlanId = VlanId.NONE; return new Interface(name, cp, intfIps, mac, vlanId); }
Example 2
Source File: GnpyManagerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testCreateGnpyRequest() { ConnectPoint ingress = ConnectPoint.fromString("netconf:10.0.254.93:830/1"); ConnectPoint egress = ConnectPoint.fromString("netconf:10.0.254.94:830/1"); String output = manager.createGnpyRequest(ingress, egress, true).toString(); System.out.println(output); assertEquals("Json to create network connectivity is wrong", REQUEST, output); }
Example 3
Source File: OpticalIntentsWebResource.java From onos with Apache License 2.0 | 4 votes |
private Intent decode(ObjectNode json) { JsonNode ingressJson = json.get(INGRESS_POINT); if (!ingressJson.isObject()) { throw new IllegalArgumentException(JSON_INVALID); } ConnectPoint ingress = codec(ConnectPoint.class).decode((ObjectNode) ingressJson, this); JsonNode egressJson = json.get(EGRESS_POINT); if (!egressJson.isObject()) { throw new IllegalArgumentException(JSON_INVALID); } ConnectPoint egress = codec(ConnectPoint.class).decode((ObjectNode) egressJson, this); JsonNode bidirectionalJson = json.get(BIDIRECTIONAL); boolean bidirectional = bidirectionalJson != null ? bidirectionalJson.asBoolean() : false; JsonNode signalJson = json.get(SIGNAL); OchSignal signal = null; if (signalJson != null) { if (!signalJson.isObject()) { throw new IllegalArgumentException(JSON_INVALID); } else { signal = OchSignalCodec.decode((ObjectNode) signalJson); } } String appIdString = nullIsIllegal(json.get(APP_ID), APP_ID + MISSING_MEMBER_MESSAGE).asText(); CoreService service = getService(CoreService.class); ApplicationId appId = nullIsNotFound(service.getAppId(appIdString), E_APP_ID_NOT_FOUND); Key key = null; DeviceService deviceService = get(DeviceService.class); JsonNode suggestedPathJson = json.get(SUGGESTEDPATH); DefaultPath suggestedPath = null; LinkService linkService = get(LinkService.class); if (suggestedPathJson != null) { if (!suggestedPathJson.isObject()) { throw new IllegalArgumentException(JSON_INVALID); } else { ArrayNode linksJson = nullIsIllegal((ArrayNode) suggestedPathJson.get("links"), "Suggested path specified without links"); List<Link> listLinks = new ArrayList<>(); for (JsonNode node : linksJson) { String srcString = node.get("src").asText(); String dstString = node.get("dst").asText(); ConnectPoint srcConnectPoint = ConnectPoint.fromString(srcString); ConnectPoint dstConnectPoint = ConnectPoint.fromString(dstString); Link link = linkService.getLink(srcConnectPoint, dstConnectPoint); if (link == null) { throw new IllegalArgumentException("Not existing link in the suggested path"); } listLinks.add(link); } if ((!listLinks.get(0).src().deviceId().equals(ingress.deviceId())) || (!listLinks.get(0).src().port().equals(ingress.port())) || (!listLinks.get(listLinks.size() - 1).dst().deviceId().equals(egress.deviceId())) || (!listLinks.get(listLinks.size() - 1).dst().port().equals(egress.port()))) { throw new IllegalArgumentException( "Suggested path not compatible with ingress or egress connect points"); } if (!isPathContiguous(listLinks)) { throw new IllegalArgumentException( "Links specified in the suggested path are not contiguous"); } suggestedPath = new DefaultPath(PROVIDER_ID, listLinks, new ScalarWeight(1)); log.debug("OpticalIntent along suggestedPath {}", suggestedPath); } } return createExplicitOpticalIntent( ingress, egress, deviceService, key, appId, bidirectional, signal, suggestedPath); }