コード例 #1
0
 @Override
 public Sessions list() {
   Object obj =
       getEntity(
           entityType,
           VdcQueryType.GetVmByVmId,
           new IdQueryParameters(vmId),
           vmId.toString(),
           true);
   VM vm = (VM) obj;
   Sessions sessions = VmMapper.map(vm, new Sessions());
   org.ovirt.engine.api.model.VM vmModel = new org.ovirt.engine.api.model.VM();
   vmModel.setId(vm.getId().toString());
   if (sessions.isSetSessions()) {
     for (Session session : sessions.getSessions()) {
       setSessionId(session);
       setSessionVmId(vmModel, session);
       // only console user assumed to be an ovirt user, and only an ovirt-user has an ID & href
       if (session.isSetConsoleUser() && session.isConsoleUser()) {
         addLinksIncludingUser(session);
       } else {
         addLinks(session, org.ovirt.engine.api.model.VM.class);
       }
     }
   }
   return sessions;
 }
コード例 #2
0
  private GraphicsType deriveGraphicsType() {
    org.ovirt.engine.core.common.businessentities.VM vm =
        getEntity(
            org.ovirt.engine.core.common.businessentities.VM.class,
            VdcQueryType.GetVmByVmId,
            new IdQueryParameters(guid),
            "GetVmByVmId");

    return (vm == null) ? null : VmMapper.deriveGraphicsType(vm.getGraphicsInfos());
  }
コード例 #3
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;
    }
コード例 #4
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;
  }