This is an automated email from the ASF dual-hosted git repository.
wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new cefedd56b8 AMBARI-25231 Replace deprecated hadoop commands (#3368)
cefedd56b8 is described below
commit cefedd56b84590ab5ae80969c68d0d59b53663eb
Author: Viraj Jasani <[email protected]>
AuthorDate: Wed Sep 21 03:25:17 2022 -0700
AMBARI-25231 Replace deprecated hadoop commands (#3368)
---
.../libraries/providers/__init__.py | 1 +
.../libraries/providers/execute_hdfs.py | 42 ++++++++++++++++++++++
.../libraries/resources/__init__.py | 1 +
.../resources/{__init__.py => execute_hdfs.py} | 24 ++++++++-----
4 files changed, 59 insertions(+), 9 deletions(-)
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 aed6c5fd16..d88d94885c 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 @@ PROVIDERS = dict(
),
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 0000000000..e207000d7e
--- /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 524292f4ba..6f06210635 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 @@ Ambari Agent
"""
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/__init__.py
b/ambari-common/src/main/python/resource_management/libraries/resources/execute_hdfs.py
similarity index 56%
copy from
ambari-common/src/main/python/resource_management/libraries/resources/__init__.py
copy to
ambari-common/src/main/python/resource_management/libraries/resources/execute_hdfs.py
index 524292f4ba..e85b448a5e 100644
---
a/ambari-common/src/main/python/resource_management/libraries/resources/__init__.py
+++
b/ambari-common/src/main/python/resource_management/libraries/resources/execute_hdfs.py
@@ -20,12 +20,18 @@ Ambari Agent
"""
-from resource_management.libraries.resources.execute_hadoop 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 *
-from resource_management.libraries.resources.repository import *
-from resource_management.libraries.resources.monitor_webserver import *
-from resource_management.libraries.resources.hdfs_resource import *
-from resource_management.libraries.resources.msi import *
-from resource_management.libraries.resources.modify_properties_file import *
\ No newline at end of file
+_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"]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]