Пример #1
0
  @GET
  public IpsPoolManagementDto getIPAddresses(
      @PathParam(VirtualDatacenterResource.VIRTUAL_DATACENTER) final Integer vdcId,
      @PathParam(PrivateNetworkResource.PRIVATE_NETWORK) final Integer vlanId,
      @QueryParam(START_WITH) @DefaultValue("0") @Min(0) final Integer startwith,
      @QueryParam(BY) @DefaultValue("ip") final String orderBy,
      @QueryParam(FILTER) @DefaultValue("") final String filter,
      @QueryParam(LIMIT) @Min(0) @DefaultValue(DEFAULT_PAGE_LENGTH_STRING) final Integer limit,
      @QueryParam(ASC) @DefaultValue("true") final Boolean descOrAsc,
      @QueryParam(ONLYAVAILABLE) @DefaultValue("false") final Boolean available,
      @Context final IRESTBuilder restBuilder)
      throws Exception {

    List<IpPoolManagement> all =
        service.getListIpPoolManagementByVlan(
            vdcId, vlanId, startwith, orderBy, filter, limit, descOrAsc);

    IpsPoolManagementDto ips = new IpsPoolManagementDto();

    for (IpPoolManagement ip : all) {
      ips.add(createTransferObject(ip, restBuilder));
    }

    ips.addLinks(
        restBuilder.buildPaggingLinks(uriInfo.getAbsolutePath().toString(), (PagedList) all));
    ips.setTotalSize(((PagedList) all).getTotalResults());

    return ips;
  }
Пример #2
0
  @GET
  @Path(VirtualMachineResource.VIRTUAL_MACHINE_ACTION_GET_IPS)
  public IpsPoolManagementDto getIPsByVirtualMachine(
      @PathParam(VirtualDatacenterResource.VIRTUAL_DATACENTER) Integer vdcId,
      @PathParam(VirtualApplianceResource.VIRTUAL_APPLIANCE) Integer vappId,
      @PathParam(VirtualMachineResource.VIRTUAL_MACHINE) Integer vmId,
      @Context IRESTBuilder restBuilder)
      throws Exception {
    VirtualMachine vm = vmService.getVirtualMachine(vdcId, vappId, vmId);

    List<IpPoolManagement> all = ipService.getListIpPoolManagementByMachine(vm);
    IpsPoolManagementDto ips = new IpsPoolManagementDto();
    for (IpPoolManagement ip : all) {
      ips.add(IpAddressesResource.createTransferObject(ip, restBuilder));
    }

    return ips;
  }