This is an automated email from the ASF dual-hosted git repository.
jialiang pushed a commit to branch frontend-refactor
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/frontend-refactor by this push:
new bf1ba10310 AMBARI:-26570: Ambari Web React: Component actions for
masters/slaves - Turn On / Off Maintenance Mode (#4102)
bf1ba10310 is described below
commit bf1ba1031085e2776cc3de772805de52474418a1
Author: Sandeep Kumar <[email protected]>
AuthorDate: Tue Jan 27 13:53:08 2026 +0530
AMBARI:-26570: Ambari Web React: Component actions for masters/slaves -
Turn On / Off Maintenance Mode (#4102)
---
ambari-web/latest/src/screens/Hosts/actions.tsx | 33 ++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/ambari-web/latest/src/screens/Hosts/actions.tsx
b/ambari-web/latest/src/screens/Hosts/actions.tsx
index 831d2336d0..4abfdef009 100644
--- a/ambari-web/latest/src/screens/Hosts/actions.tsx
+++ b/ambari-web/latest/src/screens/Hosts/actions.tsx
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-import { cloneDeep, get, set } from "lodash";
+import { capitalize, cloneDeep, get, set } from "lodash";
import { HostsApi } from "../../api/hostsApi";
import {
doDecommissionRegionServer,
@@ -39,6 +39,7 @@ import {
} from "../../Utils/Utility";
import ConfirmationModal from "../../components/ConfirmationModal";
import { IHost } from "../../models/host";
+import { t } from "i18next";
export const sendComponentCommand = async (
component: IHostComponent,
@@ -405,3 +406,33 @@ const executeCustomCommandErrorCallback = (error: any) => {
error.message
);
};
+
+export const toggleMaintenanceMode = async (component: IHostComponent) => {
+ if (component.isImpliedState()) return null;
+
+ const hostname = get(component, "hostName");
+ const clusterName = get(component, "clusterName");
+ const componentName = get(component, "componentName");
+ const state = get(component, "passiveState") === "ON" ? "OFF" : "ON";
+ const displayName = get(component, "displayName");
+ let message = t(
+ "passiveState.turn" + capitalize(state.toString()) + "For"
+ ).replace("{0}", displayName);
+
+ const data = JSON.stringify({
+ RequestInfo: {
+ context: message,
+ },
+ Body: {
+ HostRoles: {
+ maintenance_state: state,
+ },
+ },
+ });
+ await HostsApi.updateHostComponentForHost(
+ clusterName,
+ hostname,
+ componentName,
+ data
+ );
+};
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]