コード例 #1
0
ファイル: IntentCodecTest.java プロジェクト: Mohdrz/Onos
  /**
   * Tests the host to host intent JSON codec.
   *
   * @throws IOException
   */
  @Test
  public void decodeHostToHostIntent() throws IOException {
    JsonCodec<Intent> intentCodec = context.codec(Intent.class);
    assertThat(intentCodec, notNullValue());

    Intent intent = getIntent("HostToHostIntent.json", intentCodec);
    assertThat(intent, notNullValue());
    assertThat(intent, instanceOf(HostToHostIntent.class));

    HostToHostIntent hostIntent = (HostToHostIntent) intent;
    assertThat(hostIntent.priority(), is(7));
    assertThat(hostIntent.constraints(), hasSize(1));
  }
コード例 #2
0
ファイル: IntentCodecTest.java プロジェクト: Mohdrz/Onos
  /** 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));
  }
コード例 #3
0
ファイル: DemoInstaller.java プロジェクト: rsmontero/onos
 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();
 }
コード例 #4
0
ファイル: DemoInstaller.java プロジェクト: rsmontero/onos
 @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);
     }
   }
 }