예제 #1
0
 @Override
 protected void executeCommand() {
   if (validatePermissions()) {
     if (validateInputs()) {
       try {
         returnValue.setSucceeded(true);
         executeQueryCommand();
       } catch (RuntimeException ex) {
         returnValue.setSucceeded(false);
         Throwable th = ex instanceof EngineException ? ex : ex.getCause();
         if (th instanceof EngineException) {
           EngineException vdcExc = (EngineException) th;
           if (vdcExc.getErrorCode() != null) {
             returnValue.setExceptionString(vdcExc.getErrorCode().toString());
           } else {
             returnValue.setExceptionString(vdcExc.getMessage());
           }
           log.error("Query '{}' failed: {}", getClass().getSimpleName(), vdcExc.getMessage());
           log.error("Exception", vdcExc);
         } else {
           returnValue.setExceptionString(ex.getMessage());
           log.error("Query '{}' failed: {}", getClass().getSimpleName(), ex.getMessage());
           log.error("Exception", ex);
         }
       }
     } else {
       log.error(
           "Query execution failed due to invalid inputs: {}", returnValue.getExceptionString());
     }
   } else {
     String errMessage = "Query execution failed due to insufficient permissions.";
     log.error(errMessage);
     returnValue.setExceptionString(errMessage);
   }
 }
  /**
   * Get devices (LUNs) that are visible by the host.
   *
   * @return the list of LUNs.
   */
  protected List<LUNs> getDeviceList() {
    List<LUNs> luns = new ArrayList<>();
    VdcQueryReturnValue returnValue =
        executeGetDeviceList(
            new GetDeviceListQueryParameters(
                getParameters().getVdsId(), getParameters().getStorageType(), false, null));

    if (returnValue.getSucceeded()) {
      luns.addAll(returnValue.<List<LUNs>>getReturnValue());
    } else {
      throw new RuntimeException(
          String.format(
              "GetDeviceList execution failed. Exception message: %1$s",
              returnValue.getExceptionString()));
    }

    return luns;
  }