Java Code Examples for org.onosproject.net.ConnectPoint#deviceConnectPoint()
The following examples show how to use
org.onosproject.net.ConnectPoint#deviceConnectPoint() .
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: PseudowireCodec.java From onos with Apache License 2.0 | 6 votes |
@Override public DefaultL2TunnelDescription decode(ObjectNode json, CodecContext context) { Integer id = parsePwId(json.path(PW_ID).asText()); ConnectPoint cP1, cP2; cP1 = ConnectPoint.deviceConnectPoint(json.path(CP1).asText()); cP2 = ConnectPoint.deviceConnectPoint(json.path(CP2).asText()); VlanId cP1InnerVlan, cP1OuterVlan, cP2InnerVlan, cP2OuterVlan, sdTag; cP1InnerVlan = parseVlan(json.path(CP1_INNER_TAG).asText()); cP1OuterVlan = parseVlan(json.path(CP1_OUTER_TAG).asText()); cP2InnerVlan = parseVlan(json.path(CP2_INNER_TAG).asText()); cP2OuterVlan = parseVlan(json.path(CP2_OUTER_TAG).asText()); sdTag = parseVlan(json.path(SERVICE_DELIM_TAG).asText()); L2Mode mode = parseMode(json.path(MODE).asText()); MplsLabel pwLabel = parsePWLabel(json.path(PW_LABEL).asText()); DefaultL2Tunnel l2Tunnel = new DefaultL2Tunnel(mode, sdTag, id, pwLabel); DefaultL2TunnelPolicy l2Policy = new DefaultL2TunnelPolicy(id, cP1, cP1InnerVlan, cP1OuterVlan, cP2, cP2InnerVlan, cP2OuterVlan); return new DefaultL2TunnelDescription(l2Tunnel, l2Policy); }
Example 2
Source File: AddTunnelCommand.java From onos with Apache License 2.0 | 6 votes |
@Override protected void doExecute() { IntentDomainService service = get(IntentDomainService.class); ConnectPoint one = ConnectPoint.deviceConnectPoint(oneString); ConnectPoint two = ConnectPoint.deviceConnectPoint(twoString); TunnelPrimitive tunnel = new TunnelPrimitive(appId(), one, two); // get the first domain (there should only be one) final IntentDomainId domainId; try { domainId = service.getDomains().iterator().next().id(); } catch (NoSuchElementException | NullPointerException e) { print("No domains found"); return; } service.request(domainId, tunnel).forEach(r -> service.submit(domainId, r)); print("Intent domain tunnel submitted:\n%s", tunnel); }
Example 3
Source File: InterfaceAddCommand.java From onos with Apache License 2.0 | 6 votes |
@Override protected void doExecute() { InterfaceAdminService interfaceService = get(InterfaceAdminService.class); List<InterfaceIpAddress> ipAddresses = Lists.newArrayList(); if (ips != null) { for (String strIp : ips) { ipAddresses.add(InterfaceIpAddress.valueOf(strIp)); } } MacAddress macAddr = mac == null ? null : MacAddress.valueOf(mac); VlanId vlanId = vlan == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(vlan)); Interface intf = new Interface(name, ConnectPoint.deviceConnectPoint(connectPoint), ipAddresses, macAddr, vlanId); interfaceService.add(intf); print("Interface added"); }
Example 4
Source File: BitErrorCommand.java From onos with Apache License 2.0 | 6 votes |
@Override protected void doExecute() throws Exception { DeviceService deviceService = get(DeviceService.class); ConnectPoint cp = ConnectPoint.deviceConnectPoint(connectPoint); Port port = deviceService.getPort(cp); if (port == null) { print("[ERROR] %s does not exist", cp); return; } Device device = deviceService.getDevice(cp.deviceId()); BitErrorRateState bitErrorRateState = device.as(BitErrorRateState.class); Optional<Double> preFecBerVal = bitErrorRateState.getPreFecBer(cp.deviceId(), cp.port()); if (preFecBerVal.isPresent()) { double preFecBer = preFecBerVal.orElse(Double.MIN_VALUE); print("The pre-fec-ber value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), preFecBer); } Optional<Double> postFecBerVal = bitErrorRateState.getPostFecBer(cp.deviceId(), cp.port()); if (postFecBerVal.isPresent()) { double postFecBer = postFecBerVal.orElse(Double.MIN_VALUE); print("The post-fec-ber value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), postFecBer); } }
Example 5
Source File: ConnectivityManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void setUpL2(Peer peer) { // First update all the previous existing intents. Update ingress points. if (!castorStore.getLayer2Intents().isEmpty()) { updateExistingL2Intents(peer); } Set<FilteredConnectPoint> ingressPorts = new HashSet<>(); ConnectPoint egressPort = ConnectPoint.deviceConnectPoint(peer.getPort()); for (Peer inPeer : castorStore.getAllPeers()) { if (!inPeer.getName().equals(peer.getName())) { ingressPorts.add(new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(inPeer.getPort()))); } } TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); MacAddress macAddress = castorStore.getAddressMap().get(IpAddress.valueOf(peer.getIpAddress())); selector.matchEthDst(macAddress); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); Key key = Key.of(peer.getIpAddress(), appId); MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder() .appId(appId) .key(key) .selector(selector.build()) .treatment(treatment) .filteredIngressPoints(ingressPorts) .filteredEgressPoint(new FilteredConnectPoint(egressPort)) .priority(FLOW_PRIORITY) .build(); intentSynchronizer.submit(intent); castorStore.storeLayer2Intent(peer.getIpAddress(), intent); castorStore.removeCustomer(peer); peer.setL2(true); castorStore.storeCustomer(peer); }
Example 6
Source File: AddSpeakerCommand.java From onos with Apache License 2.0 | 5 votes |
private BgpConfig.BgpSpeakerConfig getSpeaker() { ConnectPoint connectPoint = ConnectPoint. deviceConnectPoint(connectionPoint); return new BgpConfig.BgpSpeakerConfig(Optional.ofNullable(name), vlanIdObj, connectPoint, new HashSet<IpAddress>()); }
Example 7
Source File: AnnotatePortCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { DeviceService deviceService = get(DeviceService.class); NetworkConfigService netcfgService = get(NetworkConfigService.class); ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(port); if (deviceService.getPort(connectPoint) == null) { print("Port %s does not exist.", port); return; } if (removeCfg && key == null) { // remove whole port annotation config netcfgService.removeConfig(connectPoint, PortAnnotationConfig.class); print("Annotation Config about %s removed", connectPoint); return; } if (key == null) { print("[ERROR] Annotation key not specified."); return; } PortAnnotationConfig cfg = netcfgService.addConfig(connectPoint, PortAnnotationConfig.class); if (removeCfg) { // remove config about entry cfg.annotation(key); } else { // add remove request config cfg.annotation(key, value); } cfg.apply(); }
Example 8
Source File: PortQueryVlansCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { DeviceService service = get(DeviceService.class); for (String portStr : ports) { ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(portStr); Port port = service.getPort(connectPoint.deviceId(), connectPoint.port()); printPort(port); printVlans(port); } }
Example 9
Source File: InstallCoordinatorTest.java From onos with Apache License 2.0 | 5 votes |
/** * Creates a test Intent. * * @return the test Intent. */ private PointToPointIntent createTestIntent() { FilteredConnectPoint ingress = new FilteredConnectPoint(ConnectPoint.deviceConnectPoint("s1/1")); FilteredConnectPoint egress = new FilteredConnectPoint(ConnectPoint.deviceConnectPoint("s1/2")); ApplicationId appId = TestApplicationId.create("test App"); return PointToPointIntent.builder() .filteredIngressPoint(ingress) .filteredEgressPoint(egress) .appId(appId) .key(Key.of("Test key", appId)) .build(); }
Example 10
Source File: InterfaceManagerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testAddInterface() throws Exception { // Create a new InterfaceConfig which will get added VlanId vlanId = VlanId.vlanId((short) 1); ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/2"); Interface newIntf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.emptyList(), MacAddress.valueOf(100), vlanId); InterfaceConfig ic = new TestInterfaceConfig(cp, Collections.singleton(newIntf)); subjects.add(cp); configs.put(cp, ic); interfaces.add(newIntf); NetworkConfigEvent event = new NetworkConfigEvent( NetworkConfigEvent.Type.CONFIG_ADDED, cp, ic, null, CONFIG_CLASS); assertEquals(NUM_INTERFACES, interfaceManager.getInterfaces().size()); // Send in a config event containing a new interface config listener.event(event); // Check the new interface exists in the InterfaceManager's inventory assertEquals(interfaces, interfaceManager.getInterfaces()); assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size()); // There are now two interfaces with vlan ID 1 Set<Interface> byVlan = Sets.newHashSet(createInterface(1), newIntf); assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId)); }
Example 11
Source File: AddSinglePointToMultiPointIntentCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { IntentService service = get(IntentService.class); if (deviceStrings.length < 2) { return; } String ingressDeviceString = deviceStrings[0]; ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString); Set<FilteredConnectPoint> egressPoints = new HashSet<>(); for (int index = 1; index < deviceStrings.length; index++) { String egressDeviceString = deviceStrings[index]; ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); egressPoints.add(new FilteredConnectPoint(egress)); } TrafficSelector selector = buildTrafficSelector(); TrafficTreatment treatment = buildTrafficTreatment(); List<Constraint> constraints = buildConstraints(); SinglePointToMultiPointIntent intent = SinglePointToMultiPointIntent.builder() .appId(appId()) .key(key()) .selector(selector) .treatment(treatment) .filteredIngressPoint(new FilteredConnectPoint(ingressPoint)) .filteredEgressPoints(egressPoints) .constraints(constraints) .priority(priority()) .resourceGroup(resourceGroup()) .build(); service.submit(intent); print("Single point to multipoint intent submitted:\n%s", intent.toString()); }
Example 12
Source File: VirtualNetworkIntentCreateCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { VirtualNetworkService service = get(VirtualNetworkService.class); IntentService virtualNetworkIntentService = service.get(NetworkId.networkId(networkId), IntentService.class); ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString); ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString); TrafficSelector selector = buildTrafficSelector(); TrafficTreatment treatment = buildTrafficTreatment(); List<Constraint> constraints = buildConstraints(); Intent intent = VirtualNetworkIntent.builder() .networkId(NetworkId.networkId(networkId)) .appId(appId()) .key(key()) .selector(selector) .treatment(treatment) .ingressPoint(ingress) .egressPoint(egress) .constraints(constraints) .priority(priority()) .build(); virtualNetworkIntentService.submit(intent); print("Virtual intent submitted:\n%s", intent.toString()); }
Example 13
Source File: InterfaceCodec.java From onos with Apache License 2.0 | 5 votes |
@Override public Interface decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } String name = nullIsIllegal(json.findValue(NAME), NAME + MISSING_NAME_MESSAGE).asText(); ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(nullIsIllegal(json.findValue(CONNECT_POINT), CONNECT_POINT + MISSING_CONNECT_POINT_MESSAGE).asText()); List<InterfaceIpAddress> ipAddresses = Lists.newArrayList(); if (json.findValue(IPS) != null) { json.findValue(IPS).forEach(ip -> { ipAddresses.add(InterfaceIpAddress.valueOf(ip.asText())); }); } MacAddress macAddr = json.findValue(MAC) == null ? null : MacAddress.valueOf(json.findValue(MAC).asText()); VlanId vlanId = json.findValue(VLAN) == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(json.findValue(VLAN).asText())); Interface inter = new Interface( name, connectPoint, ipAddresses, macAddr, vlanId); return inter; }
Example 14
Source File: SubjectFactories.java From onos with Apache License 2.0 | 4 votes |
@Override public ConnectPoint createSubject(String key) { return ConnectPoint.deviceConnectPoint(key); }
Example 15
Source File: TerminalDeviceConfig.java From onos with Apache License 2.0 | 4 votes |
public ConnectPoint clientCp() { String cp = get(CLIENT_PORT, ""); return ConnectPoint.deviceConnectPoint(cp); }
Example 16
Source File: InterfaceManagerTest.java From onos with Apache License 2.0 | 4 votes |
private ConnectPoint createConnectPoint(int i) { return ConnectPoint.deviceConnectPoint("of:000000000000000" + i + "/1"); }
Example 17
Source File: PowerConfigCommand.java From onos with Apache License 2.0 | 4 votes |
@Override protected void doExecute() throws Exception { DeviceService deviceService = get(DeviceService.class); ConnectPoint cp = ConnectPoint.deviceConnectPoint(connectPoint); Port port = deviceService.getPort(cp); if (port == null) { print("[ERROR] %s does not exist", cp); return; } if (!port.type().equals(Port.Type.OCH) && !port.type().equals(Port.Type.OTU) && !port.type().equals(Port.Type.OMS)) { log.warn("The power of selected port %s isn't editable.", port.number().toString()); print("The power of selected port %s isn't editable.", port.number().toString()); return; } Device device = deviceService.getDevice(cp.deviceId()); PowerConfig powerConfig = device.as(PowerConfig.class); // FIXME the parameter "component" equals NULL now, because there is one-to-one mapping between // <component> and <optical-channel>. if (operation.equals("get")) { Optional<Double> val = powerConfig.getTargetPower(cp.port(), Direction.ALL); if (val.isPresent()) { double power = val.orElse(Double.MIN_VALUE); print("The target-output-power value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), power); } Optional<Double> currentPower = powerConfig.currentPower(cp.port(), Direction.ALL); if (currentPower.isPresent()) { double currentPowerVal = currentPower.orElse(Double.MIN_VALUE); print("The current-output-power value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), currentPowerVal); } Optional<Double> currentInputPower = powerConfig.currentInputPower(cp.port(), Direction.ALL); if (currentInputPower.isPresent()) { double inputPowerVal = currentInputPower.orElse(Double.MIN_VALUE); print("The current-input-power value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), inputPowerVal); } } else if (operation.equals("edit-config")) { checkNotNull(value); powerConfig.setTargetPower(cp.port(), Direction.ALL, value); print("Set %f power on port", value, connectPoint); } else { print("Operation %s are not supported now.", operation); } }
Example 18
Source File: PortWaveLengthCommand.java From onos with Apache License 2.0 | 4 votes |
@Override protected void doExecute() throws Exception { if (operation.equals("edit-config")) { FlowRuleService flowService = get(FlowRuleService.class); DeviceService deviceService = get(DeviceService.class); CoreService coreService = get(CoreService.class); ConnectPoint cp = ConnectPoint.deviceConnectPoint(connectPointString); TrafficSelector.Builder trafficSelectorBuilder = DefaultTrafficSelector.builder(); TrafficTreatment.Builder trafficTreatmentBuilder = DefaultTrafficTreatment.builder(); FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder(); // an empty traffic selector TrafficSelector trafficSelector = trafficSelectorBuilder.matchInPort(cp.port()).build(); OchSignal ochSignal; if (parameter.contains("/")) { ochSignal = createOchSignal(); } else if (parameter.matches("-?\\d+(\\.\\d+)?")) { ochSignal = createOchSignalFromWavelength(deviceService, cp); } else { print("Signal or wavelength %s are in uncorrect format"); return; } if (ochSignal == null) { print("Error in creating OchSignal"); return; } TrafficTreatment trafficTreatment = trafficTreatmentBuilder .add(Instructions.modL0Lambda(ochSignal)) .add(Instructions.createOutput(deviceService.getPort(cp).number())) .build(); Device device = deviceService.getDevice(cp.deviceId()); int priority = 100; ApplicationId appId = coreService.registerApplication("org.onosproject.optical-model"); log.info(appId.name()); FlowRule addFlow = flowRuleBuilder .withPriority(priority) .fromApp(appId) .withTreatment(trafficTreatment) .withSelector(trafficSelector) .forDevice(device.id()) .makePermanent() .build(); flowService.applyFlowRules(addFlow); String msg = String.format("Setting wavelength %s", ochSignal.centralFrequency().asGHz()); print(msg); } else { print("Operation %s are not supported now.", operation); } }
Example 19
Source File: PortAuthTrackerTest.java From onos with Apache License 2.0 | 4 votes |
ConnectPoint cp(String devId, int port) { return ConnectPoint.deviceConnectPoint(devId + "/" + port); }
Example 20
Source File: RouterConfig.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the routing control plane connect point. * * @return control plane connect point */ public ConnectPoint getControlPlaneConnectPoint() { return ConnectPoint.deviceConnectPoint(object.path(CP_CONNECT_POINT).asText()); }