Пример #1
0
  @Before
  public void before() {
    ClientResponse response;

    DtoApplication app = resource().path("").accept(APPLICATION_JSON_V5).get(DtoApplication.class);

    bridge = new DtoBridge();
    bridge.setName("br1234");
    bridge.setTenantId("DhcpTenant");
    response =
        resource()
            .uri(app.getBridges())
            .type(APPLICATION_BRIDGE_JSON)
            .post(ClientResponse.class, bridge);
    assertEquals("The bridge was created.", 201, response.getStatus());
    bridge =
        resource().uri(response.getLocation()).accept(APPLICATION_BRIDGE_JSON).get(DtoBridge.class);
  }
Пример #2
0
    @Before
    public void setUp()
        throws StateAccessException, InterruptedException, KeeperException, SerializationException {

      WebResource resource = resource();
      dtoResource = new DtoWebResource(resource);

      DtoHost host1 = new DtoHost();
      host1.setName("host1");

      DtoBridge bridge1 = new DtoBridge();
      bridge1.setName("bridge1-name");
      bridge1.setTenantId("tenant1-id");

      DtoRouter router1 = new DtoRouter();
      router1.setName("router1-name");
      router1.setTenantId("tenant1-id");

      DtoBridgePort bridgePort1 = new DtoBridgePort();
      DtoBridgePort bridgePort2 = new DtoBridgePort();

      DtoTunnelZone tunnelZone1 = new DtoTunnelZone();
      tunnelZone1.setName("tz1-name");

      topology =
          new Topology.Builder(dtoResource)
              .create("router1", router1)
              .create("bridge1", bridge1)
              .create("bridge1", "bridgePort1", bridgePort1)
              .create("bridge1", "bridgePort2", bridgePort2)
              .build();

      hostTopology =
          new HostTopology.Builder(dtoResource)
              .create(host1Id, host1)
              .create("tz1", tunnelZone1)
              .build();

      URI baseUri = resource().getURI();
      api = new MidonetApi(baseUri.toString());
      api.enableLogging();
    }
Пример #3
0
  private void createActualTenants(int count) {
    Topology.Builder builder = new Topology.Builder(dtoResource);

    for (int i = 0; i < count; i++) {
      String tenantId = Integer.toString(i);
      if (isCompatApiEnabled()) {
        // In the new storage stack we don't store tenants in MidoNet
        // and instead fetch them directly from the AuthService, so
        // let's add them there.
        AuthService as = _injector.getInstance(AuthService.class);
        ((MockAuthService) as).addTenant(tenantId, tenantId);
      } else {
        // TODO: remove when old stack is removed
        DtoBridge bridge = new DtoBridge();
        bridge.setName(tenantId);
        bridge.setTenantId(tenantId);
        builder.create(tenantId, bridge);
      }
    }

    topology = builder.build();
  }