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 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;
  }