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()));
}
}
}
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;
}
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());
}
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;
}
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;
}
Aggregations