}
}
return oneAttached;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean detachable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.getBlockDevice().isSyncing()) {
continue;
}
detachable = true;
}
if (detachable) {
return null;
} else {
return "nothing do detach";
}
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.getBlockDevice().isSyncing()
&& !bdi.isDiskless(Application.RunMode.LIVE)) {
bdi.detach(Application.RunMode.LIVE);
}
}
}});
final ButtonCallback detachItemCallback =
getBrowser().new DRBDMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host host) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.getBlockDevice().isSyncing()
&& !bdi.isDiskless(Application.RunMode.LIVE)) {
bdi.detach(Application.RunMode.TEST);
}
}
}});
multiSelectionInfo.addMouseOverListener(detachMenu, detachItemCallback);
items.add(detachMenu);
/* attach */
final MyMenuItem attachMenu =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.Attach"),
BlockDevInfo.HARDDISK_DRBD_ICON_LARGE,
Tools.getString("MultiSelectionInfo.Attach"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
boolean oneDetached = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (bdi.isDiskless(Application.RunMode.LIVE)) {
oneDetached = true;
}
}
return oneDetached;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean attachable = true;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.getBlockDevice().isSyncing()) {
continue;
}
attachable = true;
}
if (attachable) {
return null;
} else {
return "nothing to attach";
}
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.getBlockDevice().isSyncing()
&& bdi.isDiskless(Application.RunMode.LIVE)) {
bdi.attach(Application.RunMode.LIVE);
}
}
}});
final ButtonCallback attachItemCallback =
getBrowser().new DRBDMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host host) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.getBlockDevice().isSyncing()
&& bdi.isDiskless(Application.RunMode.LIVE)) {
bdi.attach(Application.RunMode.TEST);
}
}
}});
multiSelectionInfo.addMouseOverListener(attachMenu, attachItemCallback);
items.add(attachMenu);
/* connect */
final MyMenuItem connectMenu =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.Connect"),
null,
Tools.getString("MultiSelectionInfo.Connect"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
boolean oneDisconnected = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!bdi.isConnectedOrWF(Application.RunMode.LIVE)) {
oneDisconnected = true;
}
}
return oneDisconnected;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean connectable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.isConnectedOrWF(Application.RunMode.LIVE)) {
continue;
}
connectable = true;
}
if (connectable) {
return null;
} else {
return "nothing to connect";
}
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.isConnectedOrWF(Application.RunMode.LIVE)) {
bdi.connect(Application.RunMode.LIVE);
}
}
}});
final ButtonCallback connectItemCallback =
getBrowser().new DRBDMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host host) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.isConnectedOrWF(Application.RunMode.LIVE)) {
bdi.connect(Application.RunMode.TEST);
}
}
}});
multiSelectionInfo.addMouseOverListener(connectMenu, connectItemCallback);
items.add(connectMenu);
/* disconnect */
final MyMenuItem disconnectMenu =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.Disconnect"),
null,
Tools.getString("MultiSelectionInfo.Disconnect"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
boolean oneConnected = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (bdi.isConnectedOrWF(Application.RunMode.LIVE)) {
oneConnected = true;
}
}
return oneConnected;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean disconnectable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.getBlockDevice().isSyncing()
&& ((bdi.getBlockDevice().isPrimary() && bdi.getBlockDevice().isSyncTarget())
|| (bdi.getOtherBlockDevInfo().getBlockDevice().isPrimary()
&& bdi.getBlockDevice().isSyncSource()))) {
continue;
}
if (!bdi.isConnectedOrWF(Application.RunMode.LIVE)) {
continue;
}
disconnectable = true;
}
if (disconnectable) {
return null;
} else {
return "nothing to disconnect";
}
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& bdi.isConnectedOrWF(Application.RunMode.LIVE)
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& (!bdi.getBlockDevice().isSyncing()
|| (bdi.getBlockDevice().isPrimary() && bdi.getBlockDevice().isSyncSource())
|| (bdi.getOtherBlockDevInfo().getBlockDevice().isPrimary()
&& bdi.getBlockDevice().isSyncTarget()))) {
bdi.disconnect(Application.RunMode.LIVE);
}
}
}});
final ButtonCallback disconnectItemCallback =
getBrowser().new DRBDMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host host) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& bdi.isConnectedOrWF(Application.RunMode.LIVE)
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& (!bdi.getBlockDevice().isSyncing()
|| (bdi.getBlockDevice().isPrimary() && bdi.getBlockDevice().isSyncSource())
|| (bdi.getOtherBlockDevInfo().getBlockDevice().isPrimary()
&& bdi.getBlockDevice().isSyncTarget()))) {
bdi.disconnect(Application.RunMode.TEST);
}
}
}});
multiSelectionInfo.addMouseOverListener(disconnectMenu, disconnectItemCallback);
items.add(disconnectMenu);
/* set primary */
final UpdatableItem setPrimaryItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.SetPrimary"),
null,
Tools.getString("MultiSelectionInfo.SetPrimary"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean oneSecondary = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
final BlockDevInfo oBdi = bdi.getOtherBlockDevInfo();
if (bdi.getBlockDevice().isSecondary()
&& ((!oBdi.getBlockDevice().isPrimary() && !selectedBlockDevInfos.contains(oBdi))
|| bdi.allowTwoPrimaries())) {
oneSecondary = true;
}
}
if (!oneSecondary) {
return "nothing to promote";
}
return null;
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& !bdi.getBlockDevice().isPrimary()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())) {
final BlockDevInfo oBdi = bdi.getOtherBlockDevInfo();
if (oBdi != null
&& oBdi.getBlockDevice().isPrimary()
&& !selectedBlockDevInfos.contains(oBdi)
&& !bdi.allowTwoPrimaries()) {
continue;
}
bdi.setPrimary(Application.RunMode.LIVE);
}
}
}});
items.add(setPrimaryItem);
/* set secondary */
final UpdatableItem setSecondaryItem =
menuFactory.createMenuItem(
Tools.getString("MultiSelectionInfo.SetSecondary"),
null,
Tools.getString("MultiSelectionInfo.SetSecondary"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean onePrimary = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.getBlockDevice().isPrimary()) {
onePrimary = true;
}
}
if (!onePrimary) {
return "nothing to demote";
}
return null;
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& bdi.getBlockDevice().isPrimary()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())) {
bdi.setSecondary(Application.RunMode.LIVE);
}
}
}});
items.add(setSecondaryItem);
/* force primary */
final UpdatableItem forcePrimaryItem =
menuFactory.createMenuItem(
Tools.getString("MultiSelectionInfo.ForcePrimary"),
null,
Tools.getString("MultiSelectionInfo.ForcePrimary"),
new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean oneSecondary = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
final BlockDevInfo oBdi = bdi.getOtherBlockDevInfo();
if (bdi.getBlockDevice().isSecondary()
&& ((!oBdi.getBlockDevice().isPrimary() && !selectedBlockDevInfos.contains(oBdi))
|| bdi.allowTwoPrimaries())) {
oneSecondary = true;
}
}
if (!oneSecondary) {
return "nothing to promote";
}
return null;
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& !bdi.getBlockDevice().isPrimary()
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())) {
final BlockDevInfo oBdi = bdi.getOtherBlockDevInfo();
if (oBdi != null
&& oBdi.getBlockDevice().isPrimary()
&& !selectedBlockDevInfos.contains(oBdi)
&& !bdi.allowTwoPrimaries()) {
continue;
}
bdi.forcePrimary(Application.RunMode.LIVE);
}
}
}});
items.add(forcePrimaryItem);
/* invalidate */
final UpdatableItem invalidateItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.Invalidate"),
null,
Tools.getString("MultiSelectionInfo.Invalidate"),
new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean canInvalidate = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.getBlockDevice().isSyncing()) {
continue;
}
if (bdi.getDrbdVolumeInfo().isVerifying()) {
continue;
}
if (selectedBlockDevInfos.contains(bdi.getOtherBlockDevInfo())) {
continue;
}
canInvalidate = true;
}
if (canInvalidate) {
return null;
} else {
return "nothing to invalidate";
}
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& !bdi.getBlockDevice().isSyncing()
&& !bdi.getDrbdVolumeInfo().isVerifying()
&& !selectedBlockDevInfos.contains(bdi.getOtherBlockDevInfo())
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())) {
bdi.invalidateBD(Application.RunMode.LIVE);
}
}
}});
items.add(invalidateItem);
/* resume */
final UpdatableItem resumeSyncItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.ResumeSync"),
null,
Tools.getString("MultiSelectionInfo.ResumeSync"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean resumable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!bdi.getBlockDevice().isSyncing()) {
continue;
}
if (bdi.getBlockDevice().isSyncTarget() || bdi.getBlockDevice().isSyncSource()) {
continue;
}
resumable = true;
}
if (!resumable) {
return "nothing to resume";
}
return null;
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& bdi.getBlockDevice().isSyncing()
&& !bdi.getBlockDevice().isSyncTarget()
&& !bdi.getBlockDevice().isSyncSource()) {
bdi.resumeSync(Application.RunMode.LIVE);
}
}
}});
items.add(resumeSyncItem);
/* pause sync */
final UpdatableItem pauseSyncItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.PauseSync"),
null,
Tools.getString("MultiSelectionInfo.PauseSync"),
new AccessMode(AccessMode.OP, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean pausable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!bdi.getBlockDevice().isSyncTarget() && !bdi.getBlockDevice().isSyncSource()) {
continue;
}
pausable = true;
}
if (!pausable) {
return "nothing to pause";
}
return null;
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& (bdi.getBlockDevice().isSyncTarget() || bdi.getBlockDevice().isSyncSource())) {
bdi.pauseSync(Application.RunMode.LIVE);
}
}
}});
items.add(pauseSyncItem);
/* resize */
final UpdatableItem resizeItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.Resize"),
null,
Tools.getString("MultiSelectionInfo.Resize"),
new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean resizable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (bdi.getBlockDevice().isSyncing()) {
continue;
}
if (selectedBlockDevInfos.contains(bdi.getOtherBlockDevInfo())) {
continue;
}
resizable = true;
}
if (resizable) {
return null;
} else {
return "nothing to resize";
}
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& !selectedBlockDevInfos.contains(bdi.getOtherBlockDevInfo())
&& !bdi.getBlockDevice().isSyncing()) {
bdi.resizeDrbd(Application.RunMode.LIVE);
}
}
}});
items.add(resizeItem);
/* discard my data */
final UpdatableItem discardDataItem =
menuFactory.createMenuItem(
Tools.getString("MultiSelectionInfo.DiscardData"),
null,
Tools.getString("MultiSelectionInfo.DiscardData"),
new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
boolean discardable = false;
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
if (!application.isAdvancedMode() && bdi.getDrbdVolumeInfo().isUsedByCRM()) {
continue;
}
if (bdi.getBlockDevice().isSyncing()) {
continue;
}
if (bdi.getBlockDevice().isPrimary()) {
continue;
}
if (selectedBlockDevInfos.contains(bdi.getOtherBlockDevInfo())) {
continue;
}
discardable = true;
}
if (discardable) {
return null;
} else {
return "nothing to discard";
}
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (bdi.getBlockDevice().isDrbd()
&& !selectedBlockDevInfos.contains(bdi.getOtherBlockDevInfo())
&& (application.isAdvancedMode() || !bdi.getDrbdVolumeInfo().isUsedByCRM())
&& !bdi.getBlockDevice().isSyncing()
&& !bdi.getBlockDevice().isPrimary()) {
bdi.discardData(Application.RunMode.LIVE);
}
}
}});
items.add(discardDataItem);
/* proxy down */
final UpdatableItem proxyDownItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.ProxyDown"),
null,
Tools.getString("MultiSelectionInfo.ProxyDown"),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
final ResourceInfo dri = bdi.getDrbdVolumeInfo().getDrbdResourceInfo();
final Host pHost = dri.getProxyHost(bdi.getHost(), !ResourceInfo.WIZARD);
if (pHost == null) {
return false;
}
if (pHost.isDrbdProxyUp(dri.getName())) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
final ResourceInfo dri = bdi.getDrbdVolumeInfo().getDrbdResourceInfo();
final Host pHost = dri.getProxyHost(bdi.getHost(), !ResourceInfo.WIZARD);
if (pHost == null) {
return "";
}
if (!pHost.isConnected()) {
return Host.PROXY_NOT_CONNECTED_MENU_TOOLTIP_TEXT;
}
}
return null;
}})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
final Collection<Host> hosts = new HashSet<Host>();
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
final ResourceInfo dri = bdi.getDrbdVolumeInfo().getDrbdResourceInfo();
final Host pHost = dri.getProxyHost(bdi.getHost(), !ResourceInfo.WIZARD);
if (pHost.isDrbdProxyUp(dri.getName())) {
DRBD.proxyDown(pHost,
dri.getName(),
bdi.getDrbdVolumeInfo().getName(),
Application.RunMode.LIVE);
hosts.add(pHost);
}
}
for (final Host h : hosts) {
getBrowser().updateProxyHWInfo(h);
}
}});
items.add(proxyDownItem);
/* proxy up */
final UpdatableItem proxyUpItem =
menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.ProxyUp"),
null,
Tools.getString("MultiSelectionInfo.ProxyUp"),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;
}
final ResourceInfo dri = bdi.getDrbdVolumeInfo().getDrbdResourceInfo();
final Host pHost = dri.getProxyHost(bdi.getHost(), !ResourceInfo.WIZARD);
if (pHost == null) {
return false;
}
if (!pHost.isDrbdProxyUp(dri.getName())) {
return true;
}
}
return false;
}})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
for (final BlockDevInfo bdi : selectedBlockDevInfos) {
if (!bdi.getBlockDevice().isDrbd()) {
continue;