use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterVolumeProfileInfoReturn method prepareBrickProfileDetails.
private List<BrickProfileDetails> prepareBrickProfileDetails(GlusterVolumeEntity volume, Object[] brickProfileDetails) {
List<BrickProfileDetails> brickProfileDetailsList = new ArrayList<>();
for (Object brickProfileObj : brickProfileDetails) {
BrickProfileDetails brickProfileDetail = new BrickProfileDetails();
Map<String, Object> brickProfile = (Map<String, Object>) brickProfileObj;
GlusterBrickEntity brick = GlusterCoreUtil.getBrickByQualifiedName(volume.getBricks(), (String) brickProfile.get(BRICK));
if (brick != null) {
brickProfileDetail.setBrickId(brick.getId());
}
List<StatsInfo> statsInfo = new ArrayList<>();
statsInfo.add(getStatInfo((Map<String, Object>) brickProfile.get(CUMULATIVE_STATS), CUMULATIVE_STATS));
statsInfo.add(getStatInfo((Map<String, Object>) brickProfile.get(INTERVAL_STATS), INTERVAL_STATS));
brickProfileDetail.setProfileStats(statsInfo);
brickProfileDetailsList.add(brickProfileDetail);
}
return brickProfileDetailsList;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterVolumesListReturn method getBricks.
/**
* Gets list of bricks of the volume from given list of brick representations. This can return null in certain cases
* of failure e.g. if the brick representation contains an ip address which is mapped to more than servers in the
* database.
*/
private List<GlusterBrickEntity> getBricks(Guid volumeId, Object[] brickList, boolean withUuid) throws Exception {
List<GlusterBrickEntity> bricks = new ArrayList<>();
GlusterBrickEntity fetchedBrick;
int brickOrder = 0;
try {
for (Object brick : brickList) {
if (withUuid) {
fetchedBrick = getBrick(clusterId, volumeId, (Map<String, Object>) brick, brickOrder++);
} else {
fetchedBrick = getBrick(clusterId, volumeId, (String) brick, brickOrder++);
}
if (fetchedBrick != null) {
bricks.add(fetchedBrick);
}
}
} catch (Exception e) {
// We do not want the command to fail if bricks for one of the volumes could not be fetched. Hence log the
// exception and return null. The client should have special handling if bricks list of any of the volumes
// is null.
log.error("Error while populating bricks of volume '{}': {}", volumeId, e.getMessage());
log.debug("Exception", e);
return null;
}
return bricks;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class StorageListModel method onImport.
private void onImport() {
StorageModel model = (StorageModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (!model.validate()) {
return;
}
model.startProgress(ConstantsManager.getInstance().getConstants().importingStorageDomainProgress());
VDS host = model.getHost().getSelectedItem();
// Save changes.
if (model.getCurrentStorageItem() instanceof NfsStorageModel) {
NfsStorageModel nfsModel = (NfsStorageModel) model.getCurrentStorageItem();
nfsModel.setMessage(null);
Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
"ImportFile", host.getId(), nfsModel.getPath().getEntity(), nfsModel.getRole(), StorageType.NFS, model.getActivateDomain().getEntity() }))).run();
} else if (model.getCurrentStorageItem() instanceof LocalStorageModel) {
LocalStorageModel localModel = (LocalStorageModel) model.getCurrentStorageItem();
localModel.setMessage(null);
Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
"ImportFile", host.getId(), localModel.getPath().getEntity(), localModel.getRole(), StorageType.LOCALFS, model.getActivateDomain().getEntity() }))).run();
} else if (model.getCurrentStorageItem() instanceof GlusterStorageModel) {
GlusterStorageModel glusterModel = (GlusterStorageModel) model.getCurrentStorageItem();
glusterModel.setMessage(null);
// Check checkbox is selected or not
if (glusterModel.getLinkGlusterVolume().getEntity() && glusterModel.getGlusterVolumes().getSelectedItem() != null) {
GlusterBrickEntity brick = glusterModel.getGlusterVolumes().getSelectedItem().getBricks().get(0);
if (brick != null) {
String server = brick.getNetworkId() != null && StringHelper.isNotNullOrEmpty(brick.getNetworkAddress()) ? brick.getNetworkAddress() : brick.getServerName();
path = // $NON-NLS-1$
server + ":/" + glusterModel.getGlusterVolumes().getSelectedItem().getName();
}
} else if (!glusterModel.getLinkGlusterVolume().getEntity()) {
path = glusterModel.getPath().getEntity();
}
if (StringHelper.isNotNullOrEmpty(path)) {
Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
"ImportFile", host.getId(), path, glusterModel.getRole(), glusterModel.getType(), model.getActivateDomain().getEntity() }))).run();
} else {
return;
}
} else if (model.getCurrentStorageItem() instanceof PosixStorageModel) {
PosixStorageModel posixModel = (PosixStorageModel) model.getCurrentStorageItem();
posixModel.setMessage(null);
Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
"ImportFile", host.getId(), posixModel.getPath().getEntity(), posixModel.getRole(), posixModel.getType(), model.getActivateDomain().getEntity() }))).run();
} else if (model.getCurrentStorageItem() instanceof ImportSanStorageModel) {
Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
"ImportSan", host.getId(), model.getActivateDomain().getEntity() }))).run();
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterStorageView method initEditors.
void initEditors() {
linkGlusterVolumeEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
glusterVolumesEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<GlusterVolumeEntity>() {
@Override
protected String renderNullSafe(GlusterVolumeEntity glusterVolume) {
if (glusterVolume == null) {
// $NON-NLS-1$
return "";
} else {
if (glusterVolume.getBricks().isEmpty()) {
return glusterVolume.getName();
}
GlusterBrickEntity brick = glusterVolume.getBricks().get(0);
if (brick == null) {
return glusterVolume.getName();
}
String server = brick.getNetworkId() != null && StringHelper.isNotNullOrEmpty(brick.getNetworkAddress()) ? brick.getNetworkAddress() : brick.getServerName();
// $NON-NLS-1$
return server + ":/" + glusterVolume.getName();
}
}
});
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GetGlusterVolumeRemoveBricksStatusVDSCommand method executeVdsBrokerCommand.
@Override
protected void executeVdsBrokerCommand() {
String volumeName = getParameters().getVolumeName();
List<GlusterBrickEntity> bricksList = getParameters().getBricks();
String[] brickNames = new String[bricksList.size()];
for (int count = 0; count < bricksList.size(); count++) {
brickNames[count] = bricksList.get(count).getQualifiedName();
}
result = getBroker().glusterVolumeRemoveBrickStatus(volumeName, brickNames);
proceedProxyReturnValue();
// Set the current engine time as status time
GlusterVolumeTaskStatusEntity entity = result.getStatusDetails();
entity.setStatusTime(new Date());
setReturnValue(entity);
}
Aggregations