void addResourceBefore(final Host dcHost, final Application.RunMode runMode) {
if (getGroupInfo() != null) {
// TODO: disabled for now
return;
}
final VolumeInfo oldDvi = getBrowser().getDrbdVolumeFromDev(
getParamSaved(FS_RES_PARAM_DEV).getValueForConfig());
if (oldDvi != null) {
// TODO: disabled because it does not work well at the moment.
return;
}
final VolumeInfo newDvi = getBrowser().getDrbdVolumeFromDev(
getComboBoxValue(FS_RES_PARAM_DEV).getValueForConfig());
if (newDvi == null || newDvi.equals(oldDvi)) {
return;
}
final boolean oldDrbddisk = getDrbddiskInfo() != null || drbddiskIsPreferred;
if (oldDvi != null) {
if (oldDrbddisk) {
oldDvi.removeDrbdDisk(this, dcHost, runMode);
} else {
oldDvi.removeLinbitDrbd(this, dcHost, runMode);
}
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
oldDvi.updateMenus(null);
}
});
t.start();
oldDvi.getDrbdResourceInfo().setUsedByCRM(null);
//final Thread t = new Thread(new Runnable() {
// @Override
// public void run() {
// oldDvi.updateMenus(null);
// }
//});
if (oldDrbddisk) {
setDrbddiskInfo(null);
} else {
setLinbitDrbdInfo(null);
}
}
//newDvi.getDrbdResourceInfo().setUsedByCRM(true);
//final Thread t = new Thread(new Runnable() {
// @Override
// public void run() {
// newDvi.updateMenus(null);
// }
//});
//t.start();
final String fsId = getService().getId();
if (oldDrbddisk) {
final String drbdId = getBrowser().getFreeId(
getBrowser().getCrmXml().getDrbddiskResourceAgent().getServiceName(),
fsId);
newDvi.addDrbdDisk(this, dcHost, drbdId, runMode);
} else {
final String drbdId = getBrowser().getFreeId(
getBrowser().getCrmXml().getLinbitDrbdResourceAgent().getServiceName(),
fsId);
newDvi.addLinbitDrbd(this, dcHost, drbdId, runMode);
}
}