AMBARI-25231 Replace deprecated hadoop commands (#3368)
diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/__init__.py b/ambari-common/src/main/python/resource_management/libraries/providers/__init__.py
index aed6c5f..d88d948 100644
--- a/ambari-common/src/main/python/resource_management/libraries/providers/__init__.py
+++ b/ambari-common/src/main/python/resource_management/libraries/providers/__init__.py
@@ -38,6 +38,7 @@
),
default=dict(
ExecuteHadoop="resource_management.libraries.providers.execute_hadoop.ExecuteHadoopProvider",
+ ExecuteHDFS="resource_management.libraries.providers.execute_hdfs.ExecuteHDFSProvider",
TemplateConfig="resource_management.libraries.providers.template_config.TemplateConfigProvider",
XmlConfig="resource_management.libraries.providers.xml_config.XmlConfigProvider",
PropertiesFile="resource_management.libraries.providers.properties_file.PropertiesFileProvider",
diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/execute_hdfs.py b/ambari-common/src/main/python/resource_management/libraries/providers/execute_hdfs.py
new file mode 100644
index 0000000..e207000
--- /dev/null
+++ b/ambari-common/src/main/python/resource_management/libraries/providers/execute_hdfs.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+
+from resource_management.core.providers import Provider
+from resource_management.core.resources import Execute
+from resource_management.core.shell import quote_bash_args
+from resource_management.libraries.functions.format import format
+
+
+class ExecuteHDFSProvider(Provider):
+ def action_run(self):
+ conf_dir = self.resource.conf_dir
+ command = self.resource.command
+ if isinstance(command, (list, tuple)):
+ command = ' '.join(quote_bash_args(x) for x in command)
+ Execute(format("hdfs --config {conf_dir} {command}"),
+ user=self.resource.user,
+ tries=self.resource.tries,
+ try_sleep=self.resource.try_sleep,
+ logoutput=self.resource.logoutput,
+ path=self.resource.bin_dir,
+ environment=self.resource.environment,
+ )
diff --git a/ambari-common/src/main/python/resource_management/libraries/resources/__init__.py b/ambari-common/src/main/python/resource_management/libraries/resources/__init__.py
index 524292f..6f06210 100644
--- a/ambari-common/src/main/python/resource_management/libraries/resources/__init__.py
+++ b/ambari-common/src/main/python/resource_management/libraries/resources/__init__.py
@@ -21,6 +21,7 @@
"""
from resource_management.libraries.resources.execute_hadoop import *
+from resource_management.libraries.resources.execute_hdfs import *
from resource_management.libraries.resources.template_config import *
from resource_management.libraries.resources.xml_config import *
from resource_management.libraries.resources.properties_file import *
diff --git a/ambari-common/src/main/python/resource_management/libraries/resources/execute_hdfs.py b/ambari-common/src/main/python/resource_management/libraries/resources/execute_hdfs.py
new file mode 100644
index 0000000..e85b448
--- /dev/null
+++ b/ambari-common/src/main/python/resource_management/libraries/resources/execute_hdfs.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+
+_all__ = ["ExecuteHDFS"]
+from resource_management.core.base import Resource, ForcedListArgument, ResourceArgument
+
+
+class ExecuteHDFS(Resource):
+ action = ForcedListArgument(default="run")
+ command = ResourceArgument(default=lambda obj: obj.name)
+ tries = ResourceArgument(default=1)
+ try_sleep = ResourceArgument(default=0)
+ user = ResourceArgument()
+ logoutput = ResourceArgument()
+ bin_dir = ResourceArgument(default=[])
+ environment = ResourceArgument(default={})
+ conf_dir = ResourceArgument()
+ actions = Resource.actions + ["run"]