@Test public void testToLogicalNodeMissingAggregate() { String c1Name = "c1"; String iName = "i1"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(iName).build().setChannelGroup("missing"); NetworkConfigurations networkConfigurations = NetworkConfigurations.of(ImmutableSortedMap.of(c1Name, c1)); Layer1Node node = new Layer1Node(c1Name, iName); assertThat(node.toLogicalNode(networkConfigurations), nullValue()); }
public @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations) { Optional<Interface> optIface = networkConfigurations.getInterface(_hostname, _interfaceName); checkArgument( optIface.isPresent(), "Unable to create logical node for missing interface %s[%s]", _hostname, _interfaceName); Interface iface = optIface.get(); if (iface.getChannelGroup() == null) { return this; } return networkConfigurations .getInterface(_hostname, iface.getChannelGroup()) .filter(Interface::getActive) .map(c -> new Layer1Node(_hostname, c.getName())) .orElse(null); }
Layer1Node implements Comparable<Layer1Node> { public @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations) { Optional<Interface> optIface = networkConfigurations.getInterface(_hostname, _interfaceName); checkArgument( optIface.isPresent(), "Unable to create logical node for missing interface %s[%s]", _hostname, _interfaceName); Interface iface = optIface.get(); if (iface.getChannelGroup() == null) { return this; } return networkConfigurations .getInterface(_hostname, iface.getChannelGroup()) .filter(Interface::getActive) .map(c -> new Layer1Node(_hostname, c.getName())) .orElse(null); } }
Layer1Node implements Comparable<Layer1Node> { public @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations) { Optional<Interface> optIface = networkConfigurations.getInterface(_hostname, _interfaceName); checkArgument( optIface.isPresent(), "Unable to create logical node for missing interface %s[%s]", _hostname, _interfaceName); Interface iface = optIface.get(); if (iface.getChannelGroup() == null) { return this; } return networkConfigurations .getInterface(_hostname, iface.getChannelGroup()) .filter(Interface::getActive) .map(c -> new Layer1Node(_hostname, c.getName())) .orElse(null); } Layer1Node(String hostname, String interfaceName); }
Layer1Node implements Comparable<Layer1Node> { public @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations) { Optional<Interface> optIface = networkConfigurations.getInterface(_hostname, _interfaceName); checkArgument( optIface.isPresent(), "Unable to create logical node for missing interface %s[%s]", _hostname, _interfaceName); Interface iface = optIface.get(); if (iface.getChannelGroup() == null) { return this; } return networkConfigurations .getInterface(_hostname, iface.getChannelGroup()) .filter(Interface::getActive) .map(c -> new Layer1Node(_hostname, c.getName())) .orElse(null); } Layer1Node(String hostname, String interfaceName); @Override int compareTo(Layer1Node o); @Override boolean equals(@Nullable Object obj); @JsonProperty(PROP_HOSTNAME) @Nonnull String getHostname(); @JsonProperty(PROP_INTERFACE_NAME) @Nonnull String getInterfaceName(); @Override int hashCode(); @Override String toString(); @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations); }
Layer1Node implements Comparable<Layer1Node> { public @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations) { Optional<Interface> optIface = networkConfigurations.getInterface(_hostname, _interfaceName); checkArgument( optIface.isPresent(), "Unable to create logical node for missing interface %s[%s]", _hostname, _interfaceName); Interface iface = optIface.get(); if (iface.getChannelGroup() == null) { return this; } return networkConfigurations .getInterface(_hostname, iface.getChannelGroup()) .filter(Interface::getActive) .map(c -> new Layer1Node(_hostname, c.getName())) .orElse(null); } Layer1Node(String hostname, String interfaceName); @Override int compareTo(Layer1Node o); @Override boolean equals(@Nullable Object obj); @JsonProperty(PROP_HOSTNAME) @Nonnull String getHostname(); @JsonProperty(PROP_INTERFACE_NAME) @Nonnull String getInterfaceName(); @Override int hashCode(); @Override String toString(); @Nullable Layer1Node toLogicalNode(NetworkConfigurations networkConfigurations);  }