@Override
  public void execute()
      throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException,
          ConcurrentOperationException, ResourceAllocationException {
    try {
      List<? extends Network> networks = _niciraNvpElementService.listNiciraNvpDeviceNetworks(this);
      ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
      List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();

      if (networks != null && !networks.isEmpty()) {
        for (Network network : networks) {
          NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(network);
          networkResponses.add(networkResponse);
        }
      }

      response.setResponses(networkResponses);
      response.setResponseName(getCommandName());
      this.setResponseObject(response);
    } catch (InvalidParameterValueException invalidParamExcp) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
  }
 @Override
 public void execute() {
   List<? extends UserVm> result = _lbService.listLoadBalancerInstances(this);
   ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
   List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
   if (result != null) {
     vmResponses =
         _responseGenerator.createUserVmResponse(
             "loadbalancerruleinstance", result.toArray(new UserVm[result.size()]));
   }
   response.setResponses(vmResponses);
   response.setResponseName(getCommandName());
   this.setResponseObject(response);
 }
  @Override
  public void execute() {
    List<? extends Domain> result = _domainService.searchForDomainChildren(this);
    ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
    List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
    for (Domain domain : result) {
      DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
      domainResponse.setObjectName("domain");
      domainResponses.add(domainResponse);
    }

    response.setResponses(domainResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
  }
  @Override
  public void execute() {
    List<? extends StoragePool> pools = _mgr.searchForStoragePools(this);
    ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
    List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();
    for (StoragePool pool : pools) {
      StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolResponse(pool);
      poolResponse.setObjectName("storagepool");
      poolResponses.add(poolResponse);
    }

    response.setResponses(poolResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
  }
  @Override
  public void execute() {
    List<? extends IpAddress> result = _mgr.searchForIPAddresses(this);
    ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
    List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
    for (IpAddress ipAddress : result) {
      IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ipAddress);
      ipResponse.setObjectName("publicipaddress");
      ipAddrResponses.add(ipResponse);
    }

    response.setResponses(ipAddrResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
  }
Example #6
0
  @Override
  public void execute() {
    try {
      List<? extends Host> result = _resourceService.discoverHosts(this);
      ListResponse<HostResponse> response = new ListResponse<HostResponse>();
      List<HostResponse> hostResponses = new ArrayList<HostResponse>();
      if (result != null && result.size() > 0) {
        for (Host host : result) {
          HostResponse hostResponse = _responseGenerator.createHostResponse(host);
          hostResponses.add(hostResponse);
        }
      } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
      }

      response.setResponses(hostResponses);
      response.setResponseName(getCommandName());

      this.setResponseObject(response);
    } catch (DiscoveryException ex) {
      s_logger.warn("Exception: ", ex);
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
    }
  }