Ejemplo n.º 1
0
  /** Tests the encoding of a host to host intent. */
  @Test
  public void hostToHostIntent() {
    final HostToHostIntent intent =
        HostToHostIntent.builder().appId(appId).one(id1).two(id2).build();

    final JsonCodec<HostToHostIntent> intentCodec = context.codec(HostToHostIntent.class);
    assertThat(intentCodec, notNullValue());

    final ObjectNode intentJson = intentCodec.encode(intent, context);
    assertThat(intentJson, matchesIntent(intent));
  }
Ejemplo n.º 2
0
 public HostPair(Host src, Host dst) {
   this.src = src;
   this.dst = dst;
   this.intent =
       HostToHostIntent.builder()
           .appId(appId)
           .one(src.id())
           .two(dst.id())
           .selector(selector)
           .treatment(treatment)
           .constraints(constraint)
           .build();
 }
Ejemplo n.º 3
0
 @Override
 public void run() {
   TrafficSelector selector = DefaultTrafficSelector.emptySelector();
   TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
   List<Constraint> constraint = Lists.newArrayList();
   List<Host> hosts = Lists.newArrayList(hostService.getHosts());
   while (!hosts.isEmpty()) {
     Host src = hosts.remove(0);
     for (Host dst : hosts) {
       HostToHostIntent intent =
           HostToHostIntent.builder()
               .appId(appId)
               .one(src.id())
               .two(dst.id())
               .selector(selector)
               .treatment(treatment)
               .constraints(constraint)
               .build();
       existingIntents.add(intent);
       intentService.submit(intent);
     }
   }
 }