new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
final DrbdXml dxml = getClusterBrowser().getDrbdXml();
if (getDrbdVolumeInfo() != null) {
return "it is already a drbd resouce";
} else if (!getHost().isConnected()) {
return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
} else if (!getHost().isDrbdLoaded()) {
return "drbd is not loaded";
} else if (getBlockDevice().isMounted()) {
return "is mounted";
} else if (getBlockDevice().isVolumeGroupOnPhysicalVolume()) {
return "is volume group";
} else if (!getBlockDevice().isAvailable()) {
return "not available";
} else if (dxml.isDrbdDisabled()) {
return "disabled because of config";
} else {
final String noavail = getClusterBrowser().isDrbdAvailable(getHost());
if (noavail != null) {
return "DRBD installation problem: " + noavail;
}
}
return null;
}
});
repMenuItem.onUpdate(new Runnable() {
@Override
public void run() {
repMenuItem.updateMenuComponents();
final Cluster cluster = getHost().getCluster();
final Host[] otherHosts = cluster.getHostsArray();
final Collection<MyMenu> hostMenus = new ArrayList<MyMenu>();
for (final Host oHost : otherHosts) {
if (oHost == getHost()) {
continue;
}
final MyMenu hostMenu = menuFactory.createMenu(oHost.getName(),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
final DrbdXml dxml = getClusterBrowser().getDrbdXml();
if (!oHost.isConnected()) {
return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
} else if (!oHost.isDrbdLoaded()) {
return "drbd is not loaded";
} else {