Search in sources :

Example 16 with Cluster

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

the class VnicProfileMappingModel method mergeShownRows.

private void mergeShownRows() {
    for (Entry<Cluster, List<VnicProfileMappingItem>> showCluster : shownMappingRows.entrySet()) {
        final Cluster cluster = showCluster.getKey();
        final List<VnicProfileMappingItem> showClusterRows = showCluster.getValue();
        final Set<VnicProfileMappingEntity> existingMappings;
        if (externalVnicProfiles.containsKey(cluster)) {
            existingMappings = externalVnicProfiles.get(cluster);
        } else {
            existingMappings = new HashSet<>();
            externalVnicProfiles.put(cluster, existingMappings);
        }
        for (VnicProfileMappingItem shownRow : showClusterRows) {
            final VnicProfileMappingEntity shownMapping = shownRow.getEntity();
            addOrReplace(existingMappings, shownMapping);
        }
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with Cluster

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

the class ImportVmFromConfigurationCommand method initUnregisteredVM.

private void initUnregisteredVM() {
    List<OvfEntityData> ovfEntityDataList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(getParameters().getContainerId(), getParameters().getStorageDomainId());
    if (!ovfEntityDataList.isEmpty()) {
        try {
            // We should get only one entity, since we fetched the entity with a specific Storage Domain
            ovfEntityData = ovfEntityDataList.get(0);
            FullEntityOvfData fullEntityOvfData = ovfHelper.readVmFromOvf(ovfEntityData.getOvfData());
            VM vmFromConfiguration = fullEntityOvfData.getVm();
            if (Guid.isNullOrEmpty(getParameters().getClusterId())) {
                Cluster cluster = drMappingHelper.getMappedCluster(fullEntityOvfData.getClusterName(), vmFromConfiguration.getId(), getParameters().getClusterMap());
                if (cluster != null) {
                    getParameters().setClusterId(cluster.getId());
                }
            }
            vmFromConfiguration.setClusterId(getParameters().getClusterId());
            getParameters().setVm(vmFromConfiguration);
            getParameters().setDestDomainId(ovfEntityData.getStorageDomainId());
            getParameters().setSourceDomainId(ovfEntityData.getStorageDomainId());
            getParameters().setUserToRoles(fullEntityOvfData.getUserToRoles());
            // For quota, update disks when required
            if (getParameters().getDiskMap() != null) {
                vmFromConfiguration.setDiskMap(getParameters().getDiskMap());
                vmFromConfiguration.setImages(getDiskImageListFromDiskMap(getParameters().getDiskMap()));
            }
            // Note: The VM's OVF does not preserve the username and password for the LUN's connection.
            // Therefore to achieve a simple VM registration the iSCSI storage server should not use
            // credentials, although if the user will use the mapping attribute, one can set the credentials through
            // there.
            drMappingHelper.mapExternalLunDisks(DisksFilter.filterLunDisks(vmFromConfiguration.getDiskMap().values()), getParameters().getExternalLunMap());
            mapEntities(fullEntityOvfData);
        } catch (OvfReaderException e) {
            log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData());
            log.debug("Exception", e);
        }
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 18 with Cluster

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

the class GlusterGeoRepSyncJob method refreshGeoRepDataForVolume.

/**
 * Exposing this to be called via BLL command in case of force sync of geo-replication session data for volume
 */
public void refreshGeoRepDataForVolume(final GlusterVolumeEntity volume) {
    if (volume == null) {
        throw new EngineException(EngineError.GlusterVolumeGeoRepSyncFailed, "No volume information");
    }
    Cluster cluster = clusterDao.get(volume.getClusterId());
    discoverGeoRepDataInCluster(cluster, volume);
    List<GlusterGeoRepSession> geoRepSessions = geoRepDao.getGeoRepSessions(volume.getId());
    refreshGeoRepSessionStatusForSessions(cluster, geoRepSessions);
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 19 with Cluster

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

the class GlusterHookSyncJob method refreshHooks.

@OnTimerMethodAnnotation("refreshHooks")
public void refreshHooks() {
    log.debug("Refreshing hooks list");
    List<Cluster> clusters = clusterDao.getAll();
    for (Cluster cluster : clusters) {
        refreshHooksInCluster(cluster, false);
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 20 with Cluster

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

the class GlusterHostValidator method checkGlusterQuorum.

public List<String> checkGlusterQuorum(Cluster cluster, Iterable<Guid> selectedHostIdsForMaintenance) {
    List<String> volumesWithoutQuorum = new ArrayList<>();
    if (cluster.supportsGlusterService()) {
        List<GlusterBrickEntity> bricksGoingToMaintenance = new ArrayList<>();
        for (Guid serverId : selectedHostIdsForMaintenance) {
            bricksGoingToMaintenance.addAll(brickDao.getGlusterVolumeBricksByServerId(serverId));
        }
        List<GlusterVolumeEntity> volumesInCluster = volumeDao.getByClusterId(cluster.getId());
        volumesWithoutQuorum = volumesInCluster.stream().filter(volume -> volume.getStatus() == GlusterStatus.UP && volume.getVolumeType().isReplicatedType() && !isQuorumMet(volume, bricksGoingToMaintenance)).map(v -> v.getName()).collect(Collectors.toList());
    }
    return volumesWithoutQuorum;
}
Also used : GlusterBrickDao(org.ovirt.engine.core.dao.gluster.GlusterBrickDao) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Inject(javax.inject.Inject) GlusterConstants(org.ovirt.engine.core.common.constants.gluster.GlusterConstants) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Map(java.util.Map) GlusterVolumeDao(org.ovirt.engine.core.dao.gluster.GlusterVolumeDao) Validate(org.apache.commons.lang.Validate) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)346 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)80 Guid (org.ovirt.engine.core.compat.Guid)77 VDS (org.ovirt.engine.core.common.businessentities.VDS)54 List (java.util.List)50 VM (org.ovirt.engine.core.common.businessentities.VM)36 HashMap (java.util.HashMap)35 Map (java.util.Map)33 HashSet (java.util.HashSet)30 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)30 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)28 Version (org.ovirt.engine.core.compat.Version)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)26 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)26 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)25 Set (java.util.Set)24 QueryType (org.ovirt.engine.core.common.queries.QueryType)23 Collections (java.util.Collections)22 Frontend (org.ovirt.engine.ui.frontend.Frontend)22