@Override protected VM doPopulate(VM model, org.ovirt.engine.core.common.businessentities.VM entity) { parent.setConsoleDevice(model); parent.setVirtioScsiController(model); parent.setSoundcard(model); parent.setVmOvfConfiguration(model, entity); parent.setRngDevice(model); return model; }
@Override protected VM deprecatedPopulate( VM model, org.ovirt.engine.core.common.businessentities.VM entity) { Set<String> details = DetailHelper.getDetails(httpHeaders, uriInfo); parent.addInlineDetails(details, model); if (details.contains("statistics")) { addStatistics(model, entity, uriInfo); } parent.setPayload(model); parent.setBallooning(model); parent.setCertificateInfo(model); return model; }
@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; }
private RunVmOnceParams createRunVmOnceParams(VM vm) { RunVmOnceParams params = map( vm, map( map( getEntity( entityType, VdcQueryType.GetVmByVmId, new IdQueryParameters(guid), id, true), new VM()), new RunVmOnceParams(guid))); if (vm.isSetPlacementPolicy()) { Set<Guid> hostsGuidsSet = parent.validateAndUpdateHostsInPlacementPolicy(vm.getPlacementPolicy()); if (hostsGuidsSet.size() > 0) { // take the arbitrary first host for run destination params.setDestinationVdsId(hostsGuidsSet.iterator().next()); } } if (vm.isSetInitialization() && vm.getInitialization().isSetCloudInit()) { CloudInit cloudInit = vm.getInitialization().getCloudInit(); // currently only 'root' user is supported, alert the user if other user sent if (cloudInit.isSetAuthorizedKeys()) { for (AuthorizedKey authKey : cloudInit.getAuthorizedKeys().getAuthorizedKeys()) { if (!"root".equals(authKey.getUser().getUserName())) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Currently only the user 'root' is supported for authorized keys") .build()); } } } params.setInitializationType(InitializationType.CloudInit); params.setVmInit(getMapper(CloudInit.class, VmInit.class).map(cloudInit, null)); } return params; }