Search in sources :

Example 36 with VdsStatic

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

the class GlusterBrickEventSubscriber method processEvent.

@Override
public void processEvent(GlusterEvent event) {
    if (event == null) {
        log.debug("No event to process!");
        return;
    }
    GlusterServer glusterServer = glusterServerDao.getByGlusterServerUuid(Guid.createGuidFromString(event.getNodeId()));
    if (glusterServer == null) {
        log.debug("Could not determine gluster server from event '{}'", event);
        return;
    }
    VdsStatic host = vdsStaticDao.get(glusterServer.getId());
    if (host == null) {
        log.debug("No host corresponding to gluster server in '{}'", event);
        return;
    }
    GlusterVolumeEntity vol = glusterVolumeDao.getByName(host.getClusterId(), (String) event.getMessage().get("volume"));
    if (vol == null) {
        return;
    }
    if (event.getEvent().equalsIgnoreCase(EVENT_BRICK_DISCONNECTED) || event.getEvent().equalsIgnoreCase(EVENT_BRICK_CONNECTED)) {
        // get brick
        GlusterStatus status = event.getEvent().equalsIgnoreCase(EVENT_BRICK_DISCONNECTED) ? GlusterStatus.DOWN : GlusterStatus.UP;
        String path = (String) event.getMessage().get(BRICK);
        String peer = (String) event.getMessage().get(PEER);
        List<VdsStatic> vdsList = vdsStaticDao.getAllForCluster(host.getClusterId());
        VdsStatic vds = vdsList.stream().filter(v -> v.getName().equals(peer) || interfaceDao.getAllInterfacesForVds(v.getId()).stream().anyMatch(iface -> iface.getIpv4Address().equals(peer))).findFirst().orElse(null);
        GlusterBrickEntity brick = vds != null ? glusterBrickDao.getBrickByServerIdAndDirectory(vds.getId(), path) : null;
        if (brick != null) {
            glusterBrickDao.updateBrickStatus(brick.getId(), status);
            logBrickStatusChange(vol, status, brick);
        } else {
            // call sync to force updation
            log.debug("Forcing sync as brick event '{}' received that could not be resolved to brick", event);
            backend.runInternalAction(ActionType.RefreshGlusterVolumeDetails, new GlusterVolumeParameters(vol.getId()));
        }
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) GlusterVolumeParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)

Example 37 with VdsStatic

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

the class HttpImageTaskVDSCommand method getMethod.

protected T getMethod() {
    if (method == null) {
        VdsStatic vdsStatic = getAndSetVdsStatic();
        Pair<String, URL> urlInfo = HttpUtils.getConnectionUrl(vdsStatic.getHostName(), vdsStatic.getPort(), "", Config.getValue(ConfigValues.EncryptHostCommunication));
        method = concreteCreateMethod(urlInfo.getFirst());
    }
    return method;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) URL(java.net.URL)

Example 38 with VdsStatic

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

the class VdsStaticDaoTest method testGetByHostName.

/**
 * Ensures all the right VdsStatic instances are returned.
 */
@Test
public void testGetByHostName() {
    VdsStatic vds = dao.getByHostName(existingEntity.getHostName());
    assertNotNull(vds);
    assertEquals(existingEntity.getHostName(), vds.getHostName());
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Test(org.junit.Test)

Example 39 with VdsStatic

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

the class BackendStorageDomainsResourceTest method setUpVDStatic.

protected VdsStatic setUpVDStatic(int index) {
    VdsStatic vds = new VdsStatic();
    vds.setId(GUIDS[index]);
    vds.setName(NAMES[index]);
    return vds;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic)

Example 40 with VdsStatic

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

the class BackendStorageDomainResourceTest method setUpVDStatic.

protected VdsStatic setUpVDStatic(int index) {
    VdsStatic vds = new VdsStatic();
    vds.setId(GUIDS[index]);
    vds.setName(NAMES[index]);
    return vds;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic)

Aggregations

VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)49 Test (org.junit.Test)10 Guid (org.ovirt.engine.core.compat.Guid)8 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 Objects (java.util.Objects)3 Before (org.junit.Before)3 HostProviderProxy (org.ovirt.engine.core.bll.host.provider.HostProviderProxy)3 VdsDynamic (org.ovirt.engine.core.common.businessentities.VdsDynamic)3 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 StringUtils (org.apache.commons.lang.StringUtils)2 Host (org.ovirt.engine.api.model.Host)2