private Link reverseLink(Link link) { return DefaultLink.builder().providerId(link.providerId()) .src(link.dst()) .dst(link.src()) .type(link.type()) .state(link.state()) .isExpected(link.isExpected()) .build(); }
private FilteredConnectPoint getFilteredPointFromLink(Link link) { FilteredConnectPoint filteredConnectPoint; if (link.src().elementId() instanceof DeviceId) { filteredConnectPoint = new FilteredConnectPoint(link.src()); } else if (link.dst().elementId() instanceof DeviceId) { filteredConnectPoint = new FilteredConnectPoint(link.dst()); } else { throw new IntentCompilationException(DEVICE_ID_NOT_FOUND); } return filteredConnectPoint; }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }
/** * Creates a virtual host attributed to the specified provider. * * @param networkId network identifier * @param id host identifier * @param mac host MAC address * @param vlan host VLAN identifier * @param locations host locations * @param ips host IP addresses */ public DefaultVirtualHost(NetworkId networkId, HostId id, MacAddress mac, VlanId vlan, Set<HostLocation> locations, Set<IpAddress> ips) { super(PID, id, mac, vlan, locations, ips, false, DefaultAnnotations.builder().build()); this.networkId = networkId; }
protected boolean isValidHost(Host host) { return !host.ipAddresses().isEmpty() && host.annotations().value(VXLAN_ID) != null && host.annotations().value(NETWORK_ID) != null && host.annotations().value(TENANT_ID) != null && host.annotations().value(PORT_ID) != null; }
protected String getVni(Host host) { return host.annotations().value(VXLAN_ID); }
private PortNumber createPortNumber(long number, String name) { if (name == null) { return PortNumber.portNumber(number); } return PortNumber.portNumber(number, name); }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { OchSignal ochSignal = ((OchSignalCriterion) criterion).lambda(); ObjectNode child = root.putObject(CriterionCodec.OCH_SIGNAL_ID); child.put(CriterionCodec.GRID_TYPE, ochSignal.gridType().name()); child.put(CriterionCodec.CHANNEL_SPACING, ochSignal.channelSpacing().name()); child.put(CriterionCodec.SPACING_MULIPLIER, ochSignal.spacingMultiplier()); child.put(CriterionCodec.SLOT_GRANULARITY, ochSignal.slotGranularity()); return root; } }
private OchSignal createLambda(int i) { return new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1); }
/** * Creates a new set nsh spi instruction. */ NiciraSetNshSpi() { nshSpi = NshServicePathId.of(0); }
/** * Creates a new set nsh si instruction. */ NiciraSetNshSi() { nshSi = NshServiceIndex.of((short) 0); }
/** * Creates a new set nsh context header instruction. * * @param type extension treatment type */ NiciraSetNshContextHeader(ExtensionTreatmentType type) { this.nshCh = NshContextHeader.of(0); this.type = type; }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }
public String pathToString(List<Link> links) { StringBuilder builder = new StringBuilder(); builder.append("{"); for (Link link : links) { builder.append("(Device:" + link.src().deviceId() + " Port:" + link.src().port().toLong()); builder.append(" Device:" + link.dst().deviceId() + " Port:" + link.dst().port().toLong()); builder.append(")"); } builder.append("}"); return builder.toString(); }
/** * Private constructor for a default virtual link. * * @param networkId network identifier * @param src source connection point * @param dst destination connection point * @param state link state * @param tunnelId tunnel identifier */ private DefaultVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, State state, TunnelId tunnelId) { super(PID, src, dst, Type.VIRTUAL, state, DefaultAnnotations.builder().build()); this.networkId = networkId; this.tunnelId = tunnelId; }
protected String getTenantId(Host host) { return host.annotations().value(TENANT_ID); }
/** * Creates a virtual port. * * @param networkId network identifier * @param device parent network element * @param portNumber port number * @param isEnabled indicator whether the port is up and active * @param realizedBy underling port which realizes this virtual port */ public DefaultVirtualPort(NetworkId networkId, Device device, PortNumber portNumber, boolean isEnabled, ConnectPoint realizedBy) { super((Element) device, portNumber, isEnabled, DefaultAnnotations.builder().build()); this.networkId = networkId; this.realizedBy = realizedBy; }