/** * provides the element id. */ private ElementId elementId(String id) { try { return DeviceId.deviceId(id); } catch (IllegalArgumentException e) { return HostId.hostId(id); } }
@Override protected void doExecute() { get(HostAdminService.class).removeHost(HostId.hostId(id)); }
private void updateForMode(String id) { log.debug("host service: {}", hostService); log.debug("device service: {}", deviceService); try { HostId hid = HostId.hostId(id); log.debug("host id {}", hid); elementOfNote = hostService.getHost(hid); log.debug("host element {}", elementOfNote); } catch (RuntimeException e) { try { DeviceId did = DeviceId.deviceId(id); log.debug("device id {}", did); elementOfNote = deviceService.getDevice(did); log.debug("device element {}", elementOfNote); } catch (RuntimeException e2) { log.debug("Unable to process ID [{}]", id); elementOfNote = null; } } switch (currentMode) { case MOUSE: sendMouseData(); break; default: break; } }
@Override public HostToHostIntent decode(ObjectNode json, CodecContext context) { HostToHostIntent.Builder builder = HostToHostIntent.builder(); IntentCodec.intentAttributes(json, context, builder); ConnectivityIntentCodec.intentAttributes(json, context, builder); String one = nullIsIllegal(json.get(ONE), ONE + IntentCodec.MISSING_MEMBER_MESSAGE).asText(); builder.one(HostId.hostId(one)); String two = nullIsIllegal(json.get(TWO), TWO + IntentCodec.MISSING_MEMBER_MESSAGE).asText(); builder.two(HostId.hostId(two)); return builder.build(); } }
@Override public ConnectPoint decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } ElementId elementId; if (json.has(ELEMENT_DEVICE)) { elementId = DeviceId.deviceId(json.get(ELEMENT_DEVICE).asText()); } else if (json.has(ELEMENT_HOST)) { elementId = HostId.hostId(json.get(ELEMENT_HOST).asText()); } else { // invalid JSON return null; } PortNumber portNumber = portNumber(json.get(PORT).asText()); return new ConnectPoint(elementId, portNumber); } }
public void onVirtualPortCreated(VtnRscEventFeedback l3Feedback) { VirtualPort vPort = l3Feedback.virtualPort(); BasicHostConfig basicHostConfig = networkConfigService.addConfig(HostId.hostId(vPort.macAddress()), BasicHostConfig.class); Set<IpAddress> ips = new HashSet<>(); for (FixedIp fixedIp : vPort.fixedIps()) { ips.add(fixedIp.ip()); } basicHostConfig.setIps(ips).apply(); }
public void onVirtualPortDeleted(VtnRscEventFeedback l3Feedback) { VirtualPort vPort = l3Feedback.virtualPort(); HostId hostId = HostId.hostId(vPort.macAddress()); BasicHostConfig basicHostConfig = networkConfigService.addConfig(hostId, BasicHostConfig.class); Set<IpAddress> ips = hostService.getHost(hostId).ipAddresses(); for (FixedIp fixedIp : vPort.fixedIps()) { ips.remove(fixedIp.ip()); } basicHostConfig.setIps(ips).apply(); }
@Override protected void doExecute() { NetworkConfigService netcfgService = get(NetworkConfigService.class); HostId hostId = HostId.hostId(uri); if (key == null) { print("[ERROR] Annotation key not specified."); return; } HostAnnotationConfig cfg = netcfgService.getConfig(hostId, HostAnnotationConfig.class); if (cfg == null) { cfg = new HostAnnotationConfig(hostId); } if (removeCfg) { // remove config about entry cfg.annotation(key); } else { // add request config cfg.annotation(key, value); } netcfgService.applyConfig(hostId, HostAnnotationConfig.class, cfg.node()); } }
@Override public void modifyHostDetails(PropertyPanel pp, HostId hostId) { pp.title(MY_HOST_TITLE); pp.removeAllProps(); PortPairService portPairService = AbstractShellCommand.get(PortPairService.class); VirtualPortService virtualPortService = AbstractShellCommand.get(VirtualPortService.class); HostService hostService = AbstractShellCommand.get(HostService.class); Iterable<PortPair> portPairs = portPairService.getPortPairs(); for (PortPair portPair : portPairs) { VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())); MacAddress dstMacAddress = vPort.macAddress(); Host host = hostService.getHost(HostId.hostId(dstMacAddress)); if (hostId.toString().equals(host.id().toString())) { pp.addProp("SF Name", portPair.name()); pp.addProp("SF Ip", vPort.fixedIps().iterator().next().ip()); } } pp.addProp("SF host Address", hostId.toString()); }
@Override protected void doExecute() { IntentService service = get(IntentService.class); HostId oneId = HostId.hostId(one); HostId twoId = HostId.hostId(two); TrafficSelector selector = buildTrafficSelector(); TrafficTreatment treatment = buildTrafficTreatment(); List<Constraint> constraints = buildConstraints(); HostToHostIntent intent = HostToHostIntent.builder() .appId(appId()) .key(key()) .one(oneId) .two(twoId) .selector(selector) .treatment(treatment) .constraints(constraints) .priority(priority()) .resourceGroup(resourceGroup()) .build(); service.submit(intent); print("Host to Host intent submitted:\n%s", intent.toString()); }
Host host = hostService.getHost(HostId.hostId(srcMacAddress)); PortNumber port = host.location().port();
MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); VirtualPort virtualPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())); Host host = hostService.getHost(HostId.hostId(srcMacAddress)); PortNumber port = host.location().port();
Host srcHost = hostService.getHost(HostId.hostId(fiveTuple.macSrc())); VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())); MacAddress dstMacAddress = vPort.macAddress(); Host host = hostService.getHost(HostId.hostId(dstMacAddress)); .portId(portPair.ingress())) .macAddress(); Host hostSrc = hostService.getHost(HostId.hostId(srcMacAddress)); HostHighlight hhSrc = new HostHighlight(hostSrc.id().toString()); hhSrc.setBadge(NodeBadge.text(portPair.name())); Host dstHost = hostService.getHost(HostId.hostId(fiveTuple.macDst()));
HostId hostId = HostId.hostId(subject.hwAddress(), VlanId.vlanId()); DeviceId deviceId = DeviceId.deviceId(uri(subject.dpid().value())); PortNumber portNumber = PortNumber.portNumber(subject break; case PORT_REMOVED: HostId host = HostId.hostId(subject.hwAddress(), VlanId.vlanId()); providerService.hostVanished(host); break;
DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress())); MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); Host host = hostService.getHost(HostId.hostId(srcMacAddress)); PortNumber port = host.location().port();
public void installSfcEndRule(PortPair portPair, NshServicePathId nshSpiId, Objective.Operation type) { DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress())); MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); Host host = hostService.getHost(HostId.hostId(srcMacAddress)); PortNumber port = host.location().port();
VirtualPortId vPortId = VirtualPortId.portId(flowClassifier.srcPort().portId()); MacAddress macAddress = virtualPortService.getPort(vPortId).macAddress(); Host host = hostService.getHost(HostId.hostId(macAddress)); selector.matchInPort(host.location().port());