Examples of VLANNetworkDto


Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

         this.networkServiceType = Optional.of(networkServiceType);
         return this;
      }

      public UnmanagedNetwork build() {
         VLANNetworkDto dto = new VLANNetworkDto();
         dto.setName(name);
         dto.setTag(tag);
         dto.setGateway(gateway);
         dto.setAddress(address);
         dto.setMask(mask);
         dto.setPrimaryDNS(primaryDNS);
         dto.setSecondaryDNS(secondaryDNS);
         dto.setSufixDNS(suffixDNS);
         dto.setDefaultNetwork(defaultNetwork);
         dto.setUnmanaged(true);
         dto.setType(NetworkType.UNMANAGED);

         NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType());
         dto.getLinks().add(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref()));

         UnmanagedNetwork network = new UnmanagedNetwork(context, dto);
         network.datacenter = datacenter;
         network.enterprise = enterprise;
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

         this.networkServiceType = Optional.of(networkServiceType);
         return this;
      }

      public ExternalNetwork build() {
         VLANNetworkDto dto = new VLANNetworkDto();
         dto.setName(name);
         dto.setTag(tag);
         dto.setGateway(gateway);
         dto.setAddress(address);
         dto.setMask(mask);
         dto.setPrimaryDNS(primaryDNS);
         dto.setSecondaryDNS(secondaryDNS);
         dto.setSufixDNS(suffixDNS);
         dto.setDefaultNetwork(defaultNetwork == null ? Boolean.FALSE : defaultNetwork);
         dto.setUnmanaged(Boolean.FALSE);
         dto.setType(NetworkType.EXTERNAL);

         NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType());
         dto.addLink(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref()));

         ExternalNetwork network = new ExternalNetwork(context, dto);
         network.datacenter = datacenter;
         network.enterprise = enterprise;
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

      binder.bindToRequest(request, network);
   }

   @Test(expectedExceptions = NoSuchElementException.class)
   public void testBindNetworkConfigurationRefWithoutVirtualMachine() throws SecurityException, NoSuchMethodException {
      VLANNetworkDto network = NetworkResources.privateNetworkPut();

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withoutVirtualMachine", VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, ImmutableList.<Object> of(network))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

      binder.bindToRequest(request, network);
   }

   public void testBindNetworkConfigurationRef() throws SecurityException, NoSuchMethodException, IOException {
      VirtualMachineDto vm = CloudResources.virtualMachinePut();
      VLANNetworkDto network = NetworkResources.privateNetworkPut();

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, ImmutableList.<Object> of(vm, network))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();

      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));

      String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId();

      GeneratedHttpRequest newRequest = binder.bindToRequest(request, network);
      assertPayloadEquals(newRequest.getPayload(), withHeader("<links><link href=\"" + configLink
            + "\" rel=\"network_configuration\"/></links>"), LinksDto.class);
   }
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }

   public void testBindUnmanagedNetworkIpRef() throws IOException {
      VLANNetworkDto network = NetworkResources.unmanagedNetworkPut();
      RESTLink ipsLink = network.searchLink("ips");
      BindUnmanagedIpRefToPayload binder = new BindUnmanagedIpRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, network);
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + ipsLink.getHref()
            + "\" rel=\"unmanagedip\"/></links>"), LinksDto.class);
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }

   public void testBindNetworkRef() throws IOException {
      VLANNetworkDto network = NetworkResources.privateNetworkPut();
      BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, network);
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + network.getEditLink().getHref()
            + "\" rel=\"internalnetwork\"/></links>"), LinksDto.class);
   }
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

      checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
            "this binder is only valid for VLANNetworkDto");
      GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
      checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point");

      VLANNetworkDto network = (VLANNetworkDto) input;
      VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getInvocation().getArgs(),
            Predicates.instanceOf(VirtualMachineDto.class));

      RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link");

      LinksDto dto = new LinksDto();
      dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId()));

      return super.bindToRequest(request, dto);
   }
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

   @Override
   public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
      checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
            "this binder is only valid for VLANNetworkDto objects");

      VLANNetworkDto network = (VLANNetworkDto) input;
      RESTLink editLink = checkNotNull(network.getEditLink(), "VLANNetworkDto must have an edit link");

      LinksDto refs = new LinksDto();
      switch (network.getType()) {
         case INTERNAL:
            refs.addLink(new RESTLink("internalnetwork", editLink.getHref()));
            break;
         case EXTERNAL:
            refs.addLink(new RESTLink("externalnetwork", editLink.getHref()));
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

   @Override
   public <R extends HttpRequest> R bindToRequest(final R request, final Object input) {
      checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto,
            "this binder is only valid for VLANNetworkDto objects");

      VLANNetworkDto network = (VLANNetworkDto) input;
      checkArgument(network.getType() == NetworkType.UNMANAGED, "this binder is only valid for UNMANAGED networks");

      RESTLink ipsLink = checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link");

      LinksDto refs = new LinksDto();
      refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref()));

      return super.bindToRequest(request, refs);
View Full Code Here

Examples of com.abiquo.server.core.infrastructure.network.VLANNetworkDto

                  .payload(
                        payloadFromResourceWithContentType("/payloads/publicips-lastpage.xml",
                              normalize(PublicIpsDto.MEDIA_TYPE))) //
                  .build());

      VLANNetworkDto vlan = new VLANNetworkDto();
      vlan.addLink(new RESTLink("ips", "http://localhost/api/admin/datacenters/1/network/1/ips"));

      PagedIterable<PublicIpDto> publicIps = api.listPublicIps(vlan);
      List<PublicIpDto> ips = publicIps.concat().toList();

      assertEquals(ips.size(), 4);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.