Esempio n. 1
0
  @Override
  public VM update(VM incoming) {
    validateEnums(VM.class, incoming);
    validateParameters(incoming);
    if (incoming.isSetCluster()
        && (incoming.getCluster().isSetId() || incoming.getCluster().isSetName())) {
      Guid clusterId = lookupClusterId(incoming);
      if (!clusterId.toString().equals(get().getCluster().getId())) {
        performAction(
            VdcActionType.ChangeVMCluster, new ChangeVMClusterParameters(clusterId, guid));
      }
    }
    if (!isFiltered()) {
      if (incoming.isSetPlacementPolicy()) {
        parent.validateAndUpdateHostsInPlacementPolicy(incoming.getPlacementPolicy());
      }
    } else {
      incoming.setPlacementPolicy(null);
    }

    VM vm =
        performUpdate(
            incoming,
            new QueryIdResolver<Guid>(VdcQueryType.GetVmByVmId, IdQueryParameters.class),
            VdcActionType.UpdateVm,
            new UpdateParametersProvider());

    if (vm != null) {
      DisplayHelper.adjustDisplayData(this, vm);
      removeRestrictedInfo(vm);
    }

    return vm;
  }
Esempio n. 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;
    }
Esempio n. 3
0
  @Override
  public VM get() {
    VM vm;
    if (isNextRunRequested()) {
      org.ovirt.engine.core.common.businessentities.VM entity =
          getEntity(
              org.ovirt.engine.core.common.businessentities.VM.class,
              VdcQueryType.GetVmNextRunConfiguration,
              new IdQueryParameters(guid),
              id,
              true);
      vm = addLinks(populate(VmMapper.map(entity, null, false), entity));

    } else {
      vm = performGet(VdcQueryType.GetVmByVmId, new IdQueryParameters(guid));
    }

    if (vm != null) {
      DisplayHelper.adjustDisplayData(this, vm);
      removeRestrictedInfo(vm);
    }

    return vm;
  }