@Test public void testAddSpeaker() throws Exception { int initialSize = bgpConfig.bgpSpeakers().size(); BgpConfig.BgpSpeakerConfig newSpeaker = createNewSpeaker(); bgpConfig.addSpeaker(newSpeaker); assertEquals(initialSize + 1, bgpConfig.bgpSpeakers().size()); speakers.add(newSpeaker); assertEquals(speakers, bgpConfig.bgpSpeakers()); }
public void addSpeaker(BgpSpeakerConfig speaker) { ObjectNode speakerNode = JsonNodeFactory.instance.objectNode(); speakerNode.put(NAME, speaker.name().get()); speakerNode.put(VLAN, speaker.vlan().toString()); speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString() + "/" + speaker.connectPoint().port().toString()); ArrayNode peersNode = speakerNode.putArray(PEERS); for (IpAddress peerAddress: speaker.peers()) { peersNode.add(peerAddress.toString()); } ArrayNode speakersArray = bgpSpeakers().isEmpty() ? initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS); speakersArray.add(speakerNode); }
BgpConfig extends Config<ApplicationId> { public void addSpeaker(BgpSpeakerConfig speaker) { ObjectNode speakerNode = JsonNodeFactory.instance.objectNode(); speakerNode.put(NAME, speaker.name().get()); speakerNode.put(VLAN, speaker.vlan().toString()); speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString() + "/" + speaker.connectPoint().port().toString()); ArrayNode peersNode = speakerNode.putArray(PEERS); for (IpAddress peerAddress: speaker.peers()) { peersNode.add(peerAddress.toString()); } ArrayNode speakersArray = bgpSpeakers().isEmpty() ? initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS); speakersArray.add(speakerNode); } }
BgpConfig extends Config<ApplicationId> { public void addSpeaker(BgpSpeakerConfig speaker) { ObjectNode speakerNode = JsonNodeFactory.instance.objectNode(); speakerNode.put(NAME, speaker.name().get()); speakerNode.put(VLAN, speaker.vlan().toString()); speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString() + "/" + speaker.connectPoint().port().toString()); ArrayNode peersNode = speakerNode.putArray(PEERS); for (IpAddress peerAddress: speaker.peers()) { peersNode.add(peerAddress.toString()); } ArrayNode speakersArray = bgpSpeakers().isEmpty() ? initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS); speakersArray.add(speakerNode); }  }
BgpConfig extends Config<ApplicationId> { public void addSpeaker(BgpSpeakerConfig speaker) { ObjectNode speakerNode = JsonNodeFactory.instance.objectNode(); speakerNode.put(NAME, speaker.name().get()); speakerNode.put(VLAN, speaker.vlan().toString()); speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString() + "/" + speaker.connectPoint().port().toString()); ArrayNode peersNode = speakerNode.putArray(PEERS); for (IpAddress peerAddress: speaker.peers()) { peersNode.add(peerAddress.toString()); } ArrayNode speakersArray = bgpSpeakers().isEmpty() ? initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS); speakersArray.add(speakerNode); }  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 void addSpeaker(BgpSpeakerConfig speaker) { ObjectNode speakerNode = JsonNodeFactory.instance.objectNode(); speakerNode.put(NAME, speaker.name().get()); speakerNode.put(VLAN, speaker.vlan().toString()); speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString() + "/" + speaker.connectPoint().port().toString()); ArrayNode peersNode = speakerNode.putArray(PEERS); for (IpAddress peerAddress: speaker.peers()) { peersNode.add(peerAddress.toString()); } ArrayNode speakersArray = bgpSpeakers().isEmpty() ? initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS); speakersArray.add(speakerNode); }  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; }