Search in sources :

Example 41 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class VolumeListModel method onConfigureClusterSnapshotOptions.

public void onConfigureClusterSnapshotOptions() {
    GlusterClusterSnapshotConfigModel clusterSnapshotConfigModel = (GlusterClusterSnapshotConfigModel) getWindow();
    Guid clusterId = clusterSnapshotConfigModel.getClusters().getSelectedItem().getId();
    List<GlusterVolumeSnapshotConfig> vdsParams = new ArrayList<>();
    for (EntityModel<GlusterVolumeSnapshotConfig> clusterCfg : clusterSnapshotConfigModel.getClusterConfigOptions().getItems()) {
        vdsParams.add(new GlusterVolumeSnapshotConfig(clusterId, null, clusterCfg.getEntity().getParamName(), clusterCfg.getEntity().getParamValue()));
    }
    Frontend.getInstance().runAction(ActionType.UpdateGlusterVolumeSnapshotConfig, new UpdateGlusterVolumeSnapshotConfigParameters(clusterId, null, vdsParams), result -> {
        if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
            cancel();
        }
        if (getConfirmWindow() != null) {
            setConfirmWindow(null);
        }
    }, this);
}
Also used : GlusterClusterSnapshotConfigModel(org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterClusterSnapshotConfigModel) GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) UpdateGlusterVolumeSnapshotConfigParameters(org.ovirt.engine.core.common.action.gluster.UpdateGlusterVolumeSnapshotConfigParameters)

Example 42 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class GlusterVolumeGeoRepCreateSessionPopupView method initEditors.

private void initEditors() {
    showEligibleVolumes = new EntityModelCheckBoxEditor(Align.RIGHT);
    startSessionEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    slaveClusterEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<String>() {

        @Override
        public String getReplacementStringNullSafe(String data) {
            return data;
        }

        @Override
        public String getDisplayStringNullSafe(String data) {
            return templates.typeAheadNameDescription(data == null ? constants.empty() : data, constants.empty()).asString();
        }
    });
    slaveHostIpEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<Pair<String, Guid>>() {

        @Override
        public String getReplacementStringNullSafe(Pair<String, Guid> data) {
            return data.getFirst();
        }

        @Override
        public String getDisplayStringNullSafe(Pair<String, Guid> data) {
            return templates.typeAheadNameDescription(data == null ? constants.empty() : data.getFirst(), constants.empty()).asString();
        }
    });
    slaveVolumeEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<GlusterVolumeEntity>() {

        @Override
        public String getReplacementStringNullSafe(GlusterVolumeEntity data) {
            return data.getName();
        }

        @Override
        public String getDisplayStringNullSafe(GlusterVolumeEntity data) {
            return templates.typeAheadNameDescription(data.getName() == null ? constants.empty() : data.getName(), data.getClusterName() == null ? constants.empty() : data.getClusterName()).asString();
        }
    });
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) Guid(org.ovirt.engine.core.compat.Guid) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 43 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class AddVmCommand method validateSpaceRequirements.

/**
 * Check if destination storage has enough space
 */
protected boolean validateSpaceRequirements() {
    for (Map.Entry<Guid, List<DiskImage>> sdImageEntry : storageToDisksMap.entrySet()) {
        StorageDomain destStorageDomain = destStorages.get(sdImageEntry.getKey());
        List<DiskImage> disksList = sdImageEntry.getValue();
        StorageDomainValidator storageDomainValidator = createStorageDomainValidator(destStorageDomain);
        if (!validateDomainsThreshold(storageDomainValidator) || !validateFreeSpace(storageDomainValidator, disksList)) {
            return false;
        }
    }
    return true;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) Map(java.util.Map) HashMap(java.util.HashMap) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 44 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class AddVmCommand method addVmNetwork.

protected void addVmNetwork() {
    List<? extends VmNic> nics = getVmInterfaces();
    VmInterfaceManager vmInterfaceManager = new VmInterfaceManager(getMacPool());
    vmInterfaceManager.sortVmNics(nics, getVmInterfaceDevices());
    List<String> macAddresses = getMacPool().allocateMacAddresses(nics.size());
    // Add interfaces from template
    for (int i = 0; i < nics.size(); ++i) {
        VmNic iface = nics.get(i);
        Guid id = Guid.newGuid();
        srcVmNicIdToTargetVmNicIdMapping.put(iface.getId(), id);
        iface.setId(id);
        iface.setMacAddress(macAddresses.get(i));
        iface.setSpeed(VmInterfaceType.forValue(iface.getType()).getSpeed());
        iface.setVmTemplateId(null);
        iface.setVmId(getParameters().getVmStaticData().getId());
        updateProfileOnNic(iface);
        vmNicDao.save(iface);
        getCompensationContext().snapshotNewEntity(iface);
        vmNetworkStatisticsDao.save(iface.getStatistics());
        getCompensationContext().snapshotNewEntity(iface.getStatistics());
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) VmInterfaceManager(org.ovirt.engine.core.bll.network.VmInterfaceManager) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 45 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class AddVmCommand method addVmCinderDisks.

protected void addVmCinderDisks(Collection<DiskImage> templateDisks) {
    List<CinderDisk> cinderDisks = DisksFilter.filterCinderDisks(templateDisks);
    if (cinderDisks.isEmpty()) {
        return;
    }
    Map<Guid, Guid> diskImageMap = new HashMap<>();
    for (CinderDisk cinderDisk : cinderDisks) {
        ImagesContainterParametersBase params = buildCloneCinderDiskCommandParameters(cinderDisk);
        ActionReturnValue actionReturnValue = runInternalAction(ActionType.CloneSingleCinderDisk, params, cloneContext().withoutExecutionContext().withoutLock());
        if (!actionReturnValue.getSucceeded()) {
            log.error("Error cloning Cinder disk '{}': {}", cinderDisk.getDiskAlias());
            getReturnValue().setFault(actionReturnValue.getFault());
            return;
        }
        Guid imageId = actionReturnValue.getActionReturnValue();
        diskImageMap.put(cinderDisk.getId(), imageId);
    }
    srcDiskIdToTargetDiskIdMapping.putAll(diskImageMap);
}
Also used : HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Aggregations

Guid (org.ovirt.engine.core.compat.Guid)1431 ArrayList (java.util.ArrayList)330 Test (org.junit.Test)322 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)219 HashMap (java.util.HashMap)211 List (java.util.List)167 VM (org.ovirt.engine.core.common.businessentities.VM)144 Map (java.util.Map)118 VDS (org.ovirt.engine.core.common.businessentities.VDS)117 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)106 HashSet (java.util.HashSet)102 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)89 Pair (org.ovirt.engine.core.common.utils.Pair)79 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)77 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)72 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)70 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)69 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)57 ActionType (org.ovirt.engine.core.common.action.ActionType)56 Set (java.util.Set)52