예제 #1
0
 private void validateParameters(VM incoming) {
   if (incoming.isSetDomain() && !incoming.getDomain().isSetName()) {
     throw new WebFaultException(
         null,
         localize(Messages.INCOMPLETE_PARAMS_REASON),
         localize(Messages.INCOMPLETE_PARAMS_CONDITIONAL, "Domain", "Domain name"),
         Response.Status.BAD_REQUEST);
   }
   if (!IconHelper.validateIconParameters(incoming)) {
     throw new BaseBackendResource.WebFaultException(
         null, localize(Messages.INVALID_ICON_PARAMETERS), Response.Status.BAD_REQUEST);
   }
 }
예제 #2
0
    @Override
    public VdcActionParametersBase getParameters(
        VM incoming, org.ovirt.engine.core.common.businessentities.VM entity) {
      VmStatic updated = getMapper(modelType, VmStatic.class).map(incoming, entity.getStaticData());

      updated.setUsbPolicy(
          VmMapper.getUsbPolicyOnUpdate(
              incoming.getUsb(),
              entity.getUsbPolicy(),
              lookupCluster(updated.getVdsGroupId()).getCompatibilityVersion()));

      VmManagementParametersBase params = new VmManagementParametersBase(updated);

      params.setApplyChangesLater(isNextRunRequested());

      if (incoming.isSetPayloads()) {
        if (incoming.isSetPayloads() && incoming.getPayloads().isSetPayload()) {
          params.setVmPayload(parent.getPayload(incoming));
        } else {
          params.setClearPayload(true);
        }
      }
      if (incoming.isSetMemoryPolicy() && incoming.getMemoryPolicy().isSetBallooning()) {
        params.setBalloonEnabled(incoming.getMemoryPolicy().isBallooning());
      }
      if (incoming.isSetConsole() && incoming.getConsole().isSetEnabled()) {
        params.setConsoleEnabled(incoming.getConsole().isEnabled());
      }
      if (incoming.isSetVirtioScsi()) {
        params.setVirtioScsiEnabled(incoming.getVirtioScsi().isEnabled());
      }
      if (incoming.isSetSoundcardEnabled()) {
        params.setSoundDeviceEnabled(incoming.isSoundcardEnabled());
      }
      if (incoming.isSetRngDevice()) {
        params.setUpdateRngDevice(true);
        params.setRngDevice(RngDeviceMapper.map(incoming.getRngDevice(), null));
      }

      DisplayHelper.setGraphicsToParams(incoming.getDisplay(), params);

      if (incoming.isSetInstanceType()
          && (incoming.getInstanceType().isSetId() || incoming.getInstanceType().isSetName())) {
        updated.setInstanceTypeId(lookupInstanceTypeId(incoming.getInstanceType()));
      } else if (incoming.isSetInstanceType()) {
        // this means that the instance type should be unset
        updated.setInstanceTypeId(null);
      }
      IconHelper.setIconToParams(incoming, params);
      return params;
    }