Search in sources :

Example 1 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class VmListModel method changeCD.

private void changeCD() {
    final VM vm = getSelectedItem();
    if (vm == null) {
        return;
    }
    AttachCdModel model = new AttachCdModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().changeCDTitle());
    model.setHelpTag(HelpTag.change_cd);
    // $NON-NLS-1$
    model.setHashName("change_cd");
    AttachCdModel attachCdModel = (AttachCdModel) getWindow();
    List<RepoImage> images1 = new ArrayList<>(Arrays.asList(new RepoImage(ConstantsManager.getInstance().getConstants().noCds())));
    attachCdModel.getIsoImage().setItems(images1);
    attachCdModel.getIsoImage().setSelectedItem(Linq.firstOrNull(images1));
    ImagesDataProvider.getISOImagesList(new AsyncQuery<>(images -> {
        AttachCdModel _attachCdModel = (AttachCdModel) getWindow();
        RepoImage eject = new RepoImage(ConsoleModel.getEjectLabel());
        images.add(0, eject);
        _attachCdModel.getIsoImage().setItems(images);
        if (_attachCdModel.getIsoImage().getIsChangable()) {
            RepoImage selectedIso = Linq.firstOrNull(images, s -> vm.getCurrentCd() != null && vm.getCurrentCd().equals(s.getRepoImageId()));
            _attachCdModel.getIsoImage().setSelectedItem(selectedIso == null ? eject : selectedIso);
        }
    }), vm.getStoragePoolId());
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnChangeCD", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : Arrays(java.util.Arrays) Event(org.ovirt.engine.ui.uicompat.Event) ImagesDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.ImagesDataProvider) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ICancelable(org.ovirt.engine.ui.uicompat.ICancelable) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) ChangeDiskCommandParameters(org.ovirt.engine.core.common.action.ChangeDiskCommandParameters) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ShutdownVmParameters(org.ovirt.engine.core.common.action.ShutdownVmParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmConsoles(org.ovirt.engine.ui.uicommonweb.models.VmConsoles) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) VmWithStatusForExclusiveLock(org.ovirt.engine.core.common.businessentities.VmWithStatusForExclusiveLock) QueryType(org.ovirt.engine.core.common.queries.QueryType) ChangeVMClusterParameters(org.ovirt.engine.core.common.action.ChangeVMClusterParameters) VmBaseListModel(org.ovirt.engine.ui.uicommonweb.models.templates.VmBaseListModel) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) MigrateVmParameters(org.ovirt.engine.core.common.action.MigrateVmParameters) StopVmTypeEnum(org.ovirt.engine.core.common.action.StopVmTypeEnum) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ConsoleContext(org.ovirt.engine.ui.uicommonweb.ConsoleOptionsFrontendPersister.ConsoleContext) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) Pair(org.ovirt.engine.core.common.utils.Pair) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) ConsolePopupModel(org.ovirt.engine.ui.uicommonweb.models.ConsolePopupModel) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) VmHostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.VmHostDeviceListModel) ConsolesFactory(org.ovirt.engine.ui.uicommonweb.models.ConsolesFactory) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmCommonUtils(org.ovirt.engine.core.common.utils.VmCommonUtils) VM(org.ovirt.engine.core.common.businessentities.VM) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) StopVmParameters(org.ovirt.engine.core.common.action.StopVmParameters) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) VmIconUnitAndVmToParameterBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmIconUnitAndVmToParameterBuilder) Inject(com.google.inject.Inject) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmAffinityGroupListModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.list.VmAffinityGroupListModel) VmErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.VmErrataCountModel) RemoveVmParameters(org.ovirt.engine.core.common.action.RemoveVmParameters) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) ChangeCDModel(org.ovirt.engine.ui.uicommonweb.models.configure.ChangeCDModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Collectors(java.util.stream.Collectors) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) Objects(java.util.Objects) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) Entry(java.util.Map.Entry) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) MigrateVmToServerParameters(org.ovirt.engine.core.common.action.MigrateVmToServerParameters) VmAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.VmAffinityLabelListModel) HashMap(java.util.HashMap) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) ExportOvaParameters(org.ovirt.engine.core.common.action.ExportOvaParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Provider(com.google.inject.Provider) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 2 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class VmModelBehaviorBase method updateSelectedCdImage.

protected void updateSelectedCdImage(VmBase vmBase) {
    boolean hasCd = !StringHelper.isNullOrEmpty(vmBase.getIsoPath());
    if (hasCd) {
        getModel().getCdImage().setSelectedItem(new RepoImage(vmBase.getIsoPath()));
    }
    getModel().getCdImage().setIsChangeable(hasCd);
    getModel().getCdAttached().setEntity(hasCd);
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 3 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class VmModelBehaviorBase method setImagesToModel.

protected void setImagesToModel(UnitVmModel model, List<RepoImage> images) {
    RepoImage oldCdImage = model.getCdImage().getSelectedItem();
    model.getCdImage().setItems(images);
    model.getCdImage().setSelectedItem((oldCdImage != null) ? oldCdImage : Linq.firstOrNull(images));
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 4 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class OpenStackImageProviderProxy method getAllImagesAsRepoImages.

public List<RepoImage> getAllImagesAsRepoImages(Integer listSize, Integer totalListSize) {
    ArrayList<RepoImage> repoImages = new ArrayList<>();
    long currentTime = System.currentTimeMillis();
    Images images = null;
    do {
        OpenStackRequest<Images> listRequest = getClient().images().list(true).queryParam("limit", listSize).queryParam("sort_key", "name").queryParam("sort_dir", "asc");
        if (images != null) {
            listRequest.queryParam("marker", images.getList().get(images.getList().size() - 1).getId());
        }
        images = listRequest.execute();
        for (Image glanceImage : images) {
            RepoImage repoImage = imageToRepoImage(glanceImage);
            repoImage.setLastRefreshed(currentTime);
            repoImages.add(repoImage);
        }
    } while ((images.getList().size() >= listSize) && (totalListSize != null && repoImages.size() < totalListSize));
    return repoImages;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Images(com.woorea.openstack.glance.model.Images) ArrayList(java.util.ArrayList) Image(com.woorea.openstack.glance.model.Image) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 5 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class BackendStorageDomainImageResourceTest method getEntity.

@Override
protected RepoImage getEntity(int index) {
    RepoImage entity = new RepoImage();
    entity.setRepoImageId(GUIDS[index].toString());
    entity.setFileType(ImageFileType.Disk);
    entity.setRepoImageName("RepoImage " + entity.getRepoImageId());
    return entity;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Aggregations

RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)41 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)5 Guid (org.ovirt.engine.core.compat.Guid)5 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)3 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 NullSafeRenderer (org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Lock (java.util.concurrent.locks.Lock)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)2 ListModelTypeAheadChangeableListBoxEditor (org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor)2 VncKeyMapRenderer (org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer)2 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)2