@Test public void testEmptyBgpSpeakers() throws Exception { assertTrue(emptyBgpConfig.bgpSpeakers().isEmpty()); }
public Set<BgpSpeakerConfig> bgpSpeakers() { Set<BgpSpeakerConfig> speakers = Sets.newHashSet(); JsonNode speakersNode = object.get(SPEAKERS); if (speakersNode == null) { return speakers; } speakersNode.forEach(jsonNode -> { Set<IpAddress> listenAddresses = Sets.newHashSet(); jsonNode.path(PEERS).forEach(addressNode -> listenAddresses.add(IpAddress.valueOf(addressNode.asText())) ); Optional<String> name; if (jsonNode.get(NAME) == null) { name = Optional.empty(); } else { name = Optional.of(jsonNode.get(NAME).asText()); } VlanId vlan = getVlan(jsonNode); speakers.add(new BgpSpeakerConfig(name, vlan, ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()), listenAddresses)); }); return speakers; }
BgpConfig extends Config<ApplicationId> { public Set<BgpSpeakerConfig> bgpSpeakers() { Set<BgpSpeakerConfig> speakers = Sets.newHashSet(); JsonNode speakersNode = object.get(SPEAKERS); if (speakersNode == null) { return speakers; } speakersNode.forEach(jsonNode -> { Set<IpAddress> listenAddresses = Sets.newHashSet(); jsonNode.path(PEERS).forEach(addressNode -> listenAddresses.add(IpAddress.valueOf(addressNode.asText())) ); Optional<String> name; if (jsonNode.get(NAME) == null) { name = Optional.empty(); } else { name = Optional.of(jsonNode.get(NAME).asText()); } VlanId vlan = getVlan(jsonNode); speakers.add(new BgpSpeakerConfig(name, vlan, ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()), listenAddresses)); }); return speakers; } }
BgpConfig extends Config<ApplicationId> { public Set<BgpSpeakerConfig> bgpSpeakers() { Set<BgpSpeakerConfig> speakers = Sets.newHashSet(); JsonNode speakersNode = object.get(SPEAKERS); if (speakersNode == null) { return speakers; } speakersNode.forEach(jsonNode -> { Set<IpAddress> listenAddresses = Sets.newHashSet(); jsonNode.path(PEERS).forEach(addressNode -> listenAddresses.add(IpAddress.valueOf(addressNode.asText())) ); Optional<String> name; if (jsonNode.get(NAME) == null) { name = Optional.empty(); } else { name = Optional.of(jsonNode.get(NAME).asText()); } VlanId vlan = getVlan(jsonNode); speakers.add(new BgpSpeakerConfig(name, vlan, ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()), listenAddresses)); }); return speakers; }  }
BgpConfig extends Config<ApplicationId> { public Set<BgpSpeakerConfig> bgpSpeakers() { Set<BgpSpeakerConfig> speakers = Sets.newHashSet(); JsonNode speakersNode = object.get(SPEAKERS); if (speakersNode == null) { return speakers; } speakersNode.forEach(jsonNode -> { Set<IpAddress> listenAddresses = Sets.newHashSet(); jsonNode.path(PEERS).forEach(addressNode -> listenAddresses.add(IpAddress.valueOf(addressNode.asText())) ); Optional<String> name; if (jsonNode.get(NAME) == null) { name = Optional.empty(); } else { name = Optional.of(jsonNode.get(NAME).asText()); } VlanId vlan = getVlan(jsonNode); speakers.add(new BgpSpeakerConfig(name, vlan, ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()), listenAddresses)); }); return speakers; }  Set<BgpSpeakerConfig> bgpSpeakers(); BgpSpeakerConfig getSpeakerWithName(String name); void addSpeaker(BgpSpeakerConfig speaker); void removeSpeaker(String speakerName); void addPeerToSpeaker(String speakerName, IpAddress peerAddress); BgpSpeakerConfig getSpeakerFromPeer(IpAddress peerAddress); void removePeerFromSpeaker(BgpSpeakerConfig speaker, IpAddress peerAddress); }
BgpConfig extends Config<ApplicationId> { public Set<BgpSpeakerConfig> bgpSpeakers() { Set<BgpSpeakerConfig> speakers = Sets.newHashSet(); JsonNode speakersNode = object.get(SPEAKERS); if (speakersNode == null) { return speakers; } speakersNode.forEach(jsonNode -> { Set<IpAddress> listenAddresses = Sets.newHashSet(); jsonNode.path(PEERS).forEach(addressNode -> listenAddresses.add(IpAddress.valueOf(addressNode.asText())) ); Optional<String> name; if (jsonNode.get(NAME) == null) { name = Optional.empty(); } else { name = Optional.of(jsonNode.get(NAME).asText()); } VlanId vlan = getVlan(jsonNode); speakers.add(new BgpSpeakerConfig(name, vlan, ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()), listenAddresses)); }); return speakers; }  Set<BgpSpeakerConfig> bgpSpeakers(); BgpSpeakerConfig getSpeakerWithName(String name); void addSpeaker(BgpSpeakerConfig speaker); void removeSpeaker(String speakerName); void addPeerToSpeaker(String speakerName, IpAddress peerAddress); BgpSpeakerConfig getSpeakerFromPeer(IpAddress peerAddress); void removePeerFromSpeaker(BgpSpeakerConfig speaker, IpAddress peerAddress); static final String SPEAKERS; static final String CONNECT_POINT; static final String NAME; static final String PEERS; static final String VLAN; }