}
private void createSelectedHostsPopup(final List<HostInfo> selectedHostInfos,
final Collection<UpdatableItem> items) {
/* cluster manager standby on */
final MyMenuItem standbyItem =
menuFactory.createMenuItem(Tools.getString("PcmkMultiSelectionInfo.StandByOn"),
HostInfo.HOST_STANDBY_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.OP, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
if (!hi.isStandby(Application.RunMode.LIVE)) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getBrowser().crmStatusFailed()) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
final Host dcHost = getBrowser().getDCHost();
if (!dcHost.isCrmStatusOk()) {
return HostInfo.NO_PCMK_STATUS_STRING + " (" + dcHost.getName() + ')';
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
final Host dcHost = getBrowser().getDCHost();
for (final HostInfo hi : selectedHostInfos) {
if (!hi.isStandby(Application.RunMode.LIVE)) {
CRM.standByOn(dcHost, hi.getHost(), Application.RunMode.LIVE);
}
}
}
});
final ButtonCallback standbyItemCallback = getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
for (final HostInfo hi : selectedHostInfos) {
if (!hi.isStandby(Application.RunMode.LIVE)) {
CRM.standByOn(dcHost, hi.getHost(), Application.RunMode.TEST);
}
}
}
});
pcmkMultiSelectionInfo.addMouseOverListener(standbyItem, standbyItemCallback);
items.add(standbyItem);
/* cluster manager standby off */
final MyMenuItem onlineItem =
menuFactory.createMenuItem(Tools.getString("PcmkMultiSelectionInfo.StandByOff"),
HostInfo.HOST_STANDBY_OFF_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.OP, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
if (hi.isStandby(Application.RunMode.LIVE)) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getBrowser().crmStatusFailed()) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
final Host dcHost = getBrowser().getDCHost();
if (!dcHost.isCrmStatusOk()) {
return HostInfo.NO_PCMK_STATUS_STRING + " (" + dcHost.getName() + ')';
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
final Host dcHost = getBrowser().getDCHost();
for (final HostInfo hi : selectedHostInfos) {
if (hi.isStandby(Application.RunMode.LIVE)) {
CRM.standByOff(dcHost, hi.getHost(), Application.RunMode.LIVE);
}
}
}
});
final ButtonCallback onlineItemCallback = getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
for (final HostInfo hi : selectedHostInfos) {
if (hi.isStandby(Application.RunMode.LIVE)) {
CRM.standByOff(dcHost, hi.getHost(), Application.RunMode.TEST);
}
}
}
});
pcmkMultiSelectionInfo.addMouseOverListener(onlineItem, onlineItemCallback);
items.add(onlineItem);
/* Stop corosync/openais. */
final MyMenuItem stopCorosyncItem =
menuFactory.createMenuItem(Tools.getString("PcmkMultiSelectionInfo.StopCorosync"),
HostInfo.HOST_STOP_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
Tools.getString("PcmkMultiSelectionInfo.StopOpenais"),
HostInfo.HOST_STOP_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
.predicate(new Predicate() {
@Override
public boolean check() {
/* when both are running it's openais. */
final HostInfo hi = selectedHostInfos.get(0);
return hi.getHost().isCorosyncRunning() && !hi.getHost().isOpenaisRunning();
}
})
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
if (hi.getHost().isCorosyncRunning() || hi.getHost().isOpenaisRunning()) {
return true;
}
}
return false;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
if (application.confirmDialog(Tools.getString("HostInfo.confirmCorosyncStop.Title"),
Tools.getString("HostInfo.confirmCorosyncStop.Desc"),
Tools.getString("HostInfo.confirmCorosyncStop.Yes"),
Tools.getString("HostInfo.confirmCorosyncStop.No"))) {
for (final HostInfo hi : selectedHostInfos) {
hi.getHost().setCommLayerStopping(true);
}
for (final HostInfo hi : selectedHostInfos) {
final Host host = hi.getHost();
if (!host.isPcmkStartedByCorosync()
&& host.hasPacemakerInitScript()
&& host.isPacemakerRunning()) {
if (host.isCorosyncRunning() && !host.isOpenaisRunning()) {
Corosync.stopCorosyncWithPcmk(host);
} else {
Openais.stopOpenaisWithPcmk(host);
}
} else {
if (host.isCorosyncRunning() && !host.isOpenaisRunning()) {
Corosync.stopCorosync(host);
} else {
Openais.stopOpenais(host);
}
}
}
for (final HostInfo hi : selectedHostInfos) {
getBrowser().updateHWInfo(hi.getHost(), !Host.UPDATE_LVM);
}
}
}
});
final ButtonCallback stopCorosyncItemCallback =
getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
for (final HostInfo hi : selectedHostInfos) {
if (!hi.isStandby(Application.RunMode.LIVE)) {
CRM.standByOn(dcHost, hi.getHost(), Application.RunMode.TEST);
}
}
}
});
pcmkMultiSelectionInfo.addMouseOverListener(stopCorosyncItem, stopCorosyncItemCallback);
items.add(stopCorosyncItem);
/* Stop heartbeat. */
final MyMenuItem stopHeartbeatItem =
menuFactory.createMenuItem(Tools.getString("PcmkMultiSelectionInfo.StopHeartbeat"),
HostInfo.HOST_STOP_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
if (hi.getHost().isHeartbeatRunning()) {
return true;
}
}
return false;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
if (application.confirmDialog(
Tools.getString("HostInfo.confirmHeartbeatStop.Title"),
Tools.getString("HostInfo.confirmHeartbeatStop.Desc"),
Tools.getString("HostInfo.confirmHeartbeatStop.Yes"),
Tools.getString("HostInfo.confirmHeartbeatStop.No"))) {
for (final HostInfo hi : selectedHostInfos) {
hi.getHost().setCommLayerStopping(true);
}
for (final HostInfo hi : selectedHostInfos) {
final Host host = hi.getHost();
Heartbeat.stopHeartbeat(host);
}
for (final HostInfo hi : selectedHostInfos) {
getBrowser().updateHWInfo(hi.getHost(), !Host.UPDATE_LVM);
}
}
}
});
final ButtonCallback stopHeartbeatItemCallback =
getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
for (final HostInfo hi : selectedHostInfos) {
if (!hi.isStandby(Application.RunMode.LIVE)) {
CRM.standByOn(dcHost, hi.getHost(), Application.RunMode.TEST);
}
}
}
});
pcmkMultiSelectionInfo.addMouseOverListener(stopHeartbeatItem, stopHeartbeatItemCallback);
items.add(stopHeartbeatItem);
/* Start corosync. */
final MyMenuItem startCorosyncItem =
menuFactory.createMenuItem(
Tools.getString("PcmkMultiSelectionInfo.StartCorosync"),
HostInfo.HOST_START_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
final Host h = hi.getHost();
if (h.isCorosyncInstalled()
&& h.hasCorosyncInitScript()
&& h.corosyncOrOpenaisConfigExists()
&& !h.isCorosyncRunning()
&& !h.isOpenaisRunning()
&& !h.isHeartbeatRunning()
&& !h.isHeartbeatInRc()) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
for (final HostInfo hi : selectedHostInfos) {
final Host h = hi.getHost();
if (h.isOpenaisInRc() && !h.isCorosyncInRc()) {
return "Openais is in rc.d";
}
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final HostInfo hi : selectedHostInfos) {
hi.getHost().setCommLayerStarting(true);
}
for (final HostInfo hi : selectedHostInfos) {
final Host h = hi.getHost();
if (h.isPacemakerInRc()) {
Corosync.startCorosyncWithPcmk(h);
} else {
Corosync.startCorosync(h);
}
}
for (final HostInfo hi : selectedHostInfos) {
getBrowser().updateHWInfo(hi.getHost(), !Host.UPDATE_LVM);
}
}
});
final ButtonCallback startCorosyncItemCallback =
getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
//TODO
}
});
pcmkMultiSelectionInfo.addMouseOverListener(startCorosyncItem, startCorosyncItemCallback);
items.add(startCorosyncItem);
/* Start openais. */
final MyMenuItem startOpenaisItem =
menuFactory.createMenuItem(Tools.getString("PcmkMultiSelectionInfo.StartOpenais"),
HostInfo.HOST_START_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
final Host h = hi.getHost();
if (h.hasOpenaisInitScript()
&& h.corosyncOrOpenaisConfigExists()
&& !h.isCorosyncRunning()
&& !h.isOpenaisRunning()
&& !h.isHeartbeatRunning()
&& !h.isHeartbeatInRc()) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
for (final HostInfo hi : selectedHostInfos) {
final Host h = hi.getHost();
if (h.isCorosyncInRc() && !h.isOpenaisInRc()) {
return "Corosync is in rc.d";
}
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final HostInfo hi : selectedHostInfos) {
hi.getHost().setCommLayerStarting(true);
Openais.startOpenais(hi.getHost());
}
for (final HostInfo hi : selectedHostInfos) {
getBrowser().updateHWInfo(hi.getHost(), !Host.UPDATE_LVM);
}
}
});
final ButtonCallback startOpenaisItemCallback =
getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
//TODO
}
});
pcmkMultiSelectionInfo.addMouseOverListener(startOpenaisItem, startOpenaisItemCallback);
items.add(startOpenaisItem);
/* Start heartbeat. */
final MyMenuItem startHeartbeatItem =
menuFactory.createMenuItem(
Tools.getString("PcmkMultiSelectionInfo.StartHeartbeat"),
HostInfo.HOST_START_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
.visiblePredicate(new VisiblePredicate() {
@Override
public boolean check() {
for (final HostInfo hi : selectedHostInfos) {
final Host h = hi.getHost();
if (h.hasHeartbeatInitScript()
&& h.heartbeatConfigExists()
&& !h.isCorosyncRunning()
&& !h.isOpenaisRunning()
&& !h.isHeartbeatRunning()) {
return true;
}
}
return false;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
for (final HostInfo hi : selectedHostInfos) {
hi.getHost().setCommLayerStarting(true);
}
for (final HostInfo hi : selectedHostInfos) {
Heartbeat.startHeartbeat(hi.getHost());
}
for (final HostInfo hi : selectedHostInfos) {
getBrowser().updateHWInfo(hi.getHost(), !Host.UPDATE_LVM);
}
}
});
final ButtonCallback startHeartbeatItemCallback =
getBrowser().new ClMenuItemCallback(getBrowser().getDCHost())
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
//TODO
}
});
pcmkMultiSelectionInfo.addMouseOverListener(startHeartbeatItem, startHeartbeatItemCallback);
items.add(startHeartbeatItem);
/* Start pacemaker. */
final MyMenuItem startPcmkItem =
menuFactory.createMenuItem(
Tools.getString("PcmkMultiSelectionInfo.StartPacemaker"),
HostInfo.HOST_START_COMM_LAYER_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,