Tools.getString("PcmkMultiSelectionInfo.CleanUpResource"),
ServiceInfo.SERVICE_RUNNING_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.OP, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.predicate(new Predicate() {
@Override
public boolean check() {
for (final ServiceInfo si : selectedServiceInfos) {
if (si.getService().isAvailable() && si.isOneFailed(Application.RunMode.LIVE)) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getBrowser().crmStatusFailed()) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
boolean failCount = false;
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
if (si.isOneFailedCount(Application.RunMode.LIVE)) {
failCount = true;
}
}
if (!failCount) {
return "no fail count";
}
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
final String avail = si.getService().isAvailableWithText();
if (avail != null) {
return avail;
}
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
pcmkMultiSelectionInfo.hidePopup();
final Host dcHost = getBrowser().getDCHost();
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
si.cleanupResource(dcHost, Application.RunMode.LIVE);
}
}
});
/* cleanup ignores CIB_file */
items.add(cleanupMenuItem);
/* manage resource */
final ComponentWithTest manageMenuItem =
menuFactory.createMenuItem(
Tools.getString("PcmkMultiSelectionInfo.ManageResource"),
ServiceInfo.MANAGE_BY_CRM_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 ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
if (!si.isManaged(Application.RunMode.LIVE)) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getBrowser().crmStatusFailed()) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
final String avail = si.getService().isAvailableWithText();
if (avail != null) {
return avail;
}
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
pcmkMultiSelectionInfo.hidePopup();
final Host dcHost = getBrowser().getDCHost();
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
si.setManaged(true, dcHost, Application.RunMode.LIVE);
}
}
});
final ButtonCallback manageItemCallback = getBrowser().new ClMenuItemCallback(null)
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
si.setManaged(true, dcHost, Application.RunMode.TEST);
}
}
});
pcmkMultiSelectionInfo.addMouseOverListener(manageMenuItem, manageItemCallback);
items.add((UpdatableItem) manageMenuItem);
/* unmanage resource */
final ComponentWithTest unmanageMenuItem =
menuFactory.createMenuItem(
Tools.getString("PcmkMultiSelectionInfo.UnmanageResource"),
ServiceInfo.UNMANAGE_BY_CRM_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 ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
if (si.isManaged(Application.RunMode.LIVE)) {
return true;
}
}
return false;
}
})
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getBrowser().crmStatusFailed()) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
final String avail = si.getService().isAvailableWithText();
if (avail != null) {
return avail;
}
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
pcmkMultiSelectionInfo.hidePopup();
final Host dcHost = getBrowser().getDCHost();
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
si.setManaged(false, dcHost, Application.RunMode.LIVE);
}
}
});
final ButtonCallback unmanageItemCallback = getBrowser().new ClMenuItemCallback(null)
.addAction(new CallbackAction() {
@Override
public void run(final Host dcHost) {
for (final ServiceInfo si : selectedServiceInfos) {
if (si.isConstraintPlaceholder() || si.getService().isNew() || si.getService().isOrphaned()) {
continue;
}
si.setManaged(false, dcHost, Application.RunMode.TEST);
}
}
});
pcmkMultiSelectionInfo.addMouseOverListener(unmanageMenuItem, unmanageItemCallback);
items.add((UpdatableItem) unmanageMenuItem);
/* migrate resource */
for (final Host host : getBrowser().getClusterHosts()) {
final String hostName = host.getName();
final MyMenuItem migrateFromMenuItem =
menuFactory.createMenuItem(Tools.getString("PcmkMultiSelectionInfo.MigrateFromResource")
+ ' ' + hostName,
ServiceInfo.MIGRATE_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
Tools.getString("PcmkMultiSelectionInfo.MigrateFromResource")
+ ' ' + hostName + " (offline)",
ServiceInfo.MIGRATE_ICON,
ClusterBrowser.STARTING_PTEST_TOOLTIP,
new AccessMode(AccessMode.OP, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.predicate(new Predicate() {
@Override
public boolean check() {
return host.isCrmStatusOk();
}
})