use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class GetGlusterStorageDevicesQuery method filterStorageDevices.
private List<StorageDevice> filterStorageDevices(List<StorageDevice> storageDevices) {
List<StorageDevice> filteredStorageDevices = new ArrayList<>();
Pattern mountPointsFilterPattern = Pattern.compile(getMountPointsFilterPattern());
List<String> fsTypesToFilterOutList = getFsTypesFilter();
// Filter out the devices which are not going to be used as storage device for gluster.
for (StorageDevice device : storageDevices) {
if ((device.getMountPoint() != null && mountPointsFilterPattern.matcher(device.getMountPoint()).matches()) || (device.getFsType() != null && fsTypesToFilterOutList.contains(device.getFsType()))) {
continue;
}
if (device.getCanCreateBrick() || device.getMountPoint() != null || device.getFsType() != null) {
filteredStorageDevices.add(device);
}
}
return filteredStorageDevices;
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class StorageDeviceSyncJobTest method getStorageDevice.
private StorageDevice getStorageDevice(String name, Guid id) {
StorageDevice storageDevice = new StorageDevice();
storageDevice.setCanCreateBrick(true);
storageDevice.setDescription("Test Device" + name);
storageDevice.setDevPath("/dev/" + name);
storageDevice.setDevType("SCSI");
storageDevice.setName(name);
storageDevice.setSize(10000L);
if (id == null) {
storageDevice.setId(Guid.newGuid());
} else {
storageDevice.setId(id);
}
return storageDevice;
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class CreateBrickVDSCommand method executeVdsBrokerCommand.
@Override
protected void executeVdsBrokerCommand() {
CreateBrickVDSParameters parameters = getParameters();
Set<String> diskNames = new HashSet<>();
for (StorageDevice storageDevice : parameters.getStorageDevices()) {
diskNames.add(storageDevice.getName());
}
storageDeviceReturn = getBroker().glusterCreateBrick(parameters.getLvName(), parameters.getMountPoint(), parameters.getRaidParams(), parameters.getFsType(), diskNames.toArray(new String[0]));
proceedProxyReturnValue();
if (getVDSReturnValue().getSucceeded()) {
StorageDevice storageDevice = storageDeviceReturn.getStorageDevice();
storageDevice.setVdsId(getParameters().getVdsId());
storageDevice.setId(Guid.newGuid());
setReturnValue(storageDevice);
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class StorageDeviceSyncJob method updateStorageDevices.
public void updateStorageDevices(VDS vds, List<StorageDevice> storageDevicesFromVdsm) {
Set<String> deviceUuidsFromVdsm = new HashSet<>();
Set<String> deviceNamesFromVdsm = new HashSet<>();
List<StorageDevice> storageDevicesInDb = storageDeviceDao.getStorageDevicesInHost(vds.getId());
Map<String, StorageDevice> nameToDeviceMap = new HashMap<>();
Map<String, StorageDevice> deviceUuidToDeviceMap = new HashMap<>();
// newly added and updated devices without looping over the same list again and again.
for (StorageDevice storageDevice : storageDevicesInDb) {
nameToDeviceMap.put(storageDevice.getName(), storageDevice);
if (storageDevice.getDevUuid() != null && !storageDevice.getDevUuid().isEmpty()) {
deviceUuidToDeviceMap.put(storageDevice.getDevUuid(), storageDevice);
}
}
List<StorageDevice> storageDevicesToUpdate = new ArrayList<>();
List<StorageDevice> storageDevicesToDelete = new ArrayList<>();
for (StorageDevice storageDevice : storageDevicesFromVdsm) {
// Create deviceName and deviceUuid set to use it while finding the deleted services.
deviceNamesFromVdsm.add(storageDevice.getName());
if (storageDevice.getDevUuid() != null) {
deviceUuidsFromVdsm.add(storageDevice.getDevUuid());
}
// If DevUuid is already exits in the DB then its an existing devices
// Assume device from vdsm doesn't have devUUID, but device name already exists in the DB
// Following two cases possible:
// 1. If device in DB doesn't have a devUUID
// update the device if there is a change from vdsm.
// 2. If device in DB has devUUID
// Though name matches, its two different devices. So treat this device as new one.
// Device in DB will be updated/removed by some other iteration in the loop
StorageDevice storageDevByDevUuid = deviceUuidToDeviceMap.get(storageDevice.getDevUuid());
StorageDevice storageDevByName = nameToDeviceMap.get(storageDevice.getName());
if (storageDevByDevUuid != null) {
storageDevice.setId(storageDevByDevUuid.getId());
if (!Objects.equals(storageDevByDevUuid, storageDevice)) {
storageDevicesToUpdate.add(storageDevice);
}
} else if (storageDevByName != null && StringUtils.isBlank(storageDevByName.getDevUuid())) {
storageDevice.setId(storageDevByName.getId());
if (!Objects.equals(storageDevByName, storageDevice)) {
storageDevicesToUpdate.add(storageDevice);
}
} else {
storageDevice.setId(Guid.newGuid());
storageDevice.setVdsId(vds.getId());
log.debug("detected new storage device '{}' for host '{}'", storageDevice.getName(), vds.getName());
storageDeviceDao.save(storageDevice);
logStorageDeviceMessage(AuditLogType.NEW_STORAGE_DEVICE_DETECTED, vds, storageDevice);
}
}
for (StorageDevice storageDevice : storageDevicesInDb) {
if ((storageDevice.getDevUuid() != null && !deviceUuidsFromVdsm.contains(storageDevice.getDevUuid())) || (storageDevice.getDevUuid() == null && !deviceNamesFromVdsm.contains(storageDevice.getName()))) {
log.debug("storage device '{}' detected removed for the host '{}'", storageDevice.getName(), vds.getName());
logStorageDeviceMessage(AuditLogType.STORAGE_DEVICE_REMOVED_FROM_THE_HOST, vds, storageDevice);
storageDevicesToDelete.add(storageDevice);
}
}
if (!storageDevicesToUpdate.isEmpty()) {
storageDeviceDao.updateAllInBatch(storageDevicesToUpdate);
}
if (!storageDevicesToDelete.isEmpty()) {
storageDeviceDao.removeAllInBatch(storageDevicesToDelete);
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.StorageDevice in project ovirt-engine by oVirt.
the class SyncStorageDevicesCommand method executeCommand.
@Override
protected void executeCommand() {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetStorageDeviceList, new VdsIdVDSCommandParametersBase(getVds().getId()));
if (returnValue.getSucceeded()) {
List<StorageDevice> storageDevices = (List<StorageDevice>) returnValue.getReturnValue();
getStorageDeviceSyncJobInstance().updateStorageDevices(getVds(), storageDevices);
setSucceeded(true);
} else {
handleVdsError(returnValue);
setSucceeded(false);
}
}
Aggregations