ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [12/15] git commit: AMBARI-3662. Resource Management. Add HadoopExecute resource. (Andrew Onischuk via dlysnichenko)
Date Fri, 01 Nov 2013 15:28:23 GMT
AMBARI-3662. Resource Management. Add HadoopExecute resource. (Andrew Onischuk via dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/fa817f64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/fa817f64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/fa817f64

Branch: refs/heads/trunk
Commit: fa817f6446177a49c414480a51c58e76e37f1b33
Parents: 0e7b987
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Fri Nov 1 17:21:43 2013 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Fri Nov 1 17:21:43 2013 +0200

----------------------------------------------------------------------
 .../libraries/providers/__init__.py             |  1 +
 .../libraries/providers/execute_hadoop.py       | 24 ++++++++++++++++++++
 .../libraries/resources/__init__.py             |  1 +
 .../libraries/resources/execute_hadoop.py       | 23 +++++++++++++++++++
 4 files changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/fa817f64/ambari-agent/src/main/python/resource_management/libraries/providers/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/providers/__init__.py
b/ambari-agent/src/main/python/resource_management/libraries/providers/__init__.py
index 1cb185c..62652ae 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/providers/__init__.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/providers/__init__.py
@@ -10,5 +10,6 @@ PROVIDERS = dict(
   amazon=dict(
   ),
   default=dict(
+    ExecuteHadoop="resource_management.libraries.providers.execute_hadoop.ExecuteHadoopProvider",
   ),
 )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/fa817f64/ambari-agent/src/main/python/resource_management/libraries/providers/execute_hadoop.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/providers/execute_hadoop.py
b/ambari-agent/src/main/python/resource_management/libraries/providers/execute_hadoop.py
new file mode 100644
index 0000000..1fbfab0
--- /dev/null
+++ b/ambari-agent/src/main/python/resource_management/libraries/providers/execute_hadoop.py
@@ -0,0 +1,24 @@
+from resource_management import *
+
+class ExecuteHadoopProvider(Provider):
+  def action_run(self):
+    if self.resource.security_enabled and not self.resource.kinit_override:
+      kinit_if_needed = "su - {user} -c '{kinit_path_local} -kt {keytab} {principal}'".format(
+            user=self.resource.user, kinit_path_local=self.resource.kinit_path_local, 
+            keytab=self.resource.keytab, principal=self.resource.principal)
+    else:
+      kinit_if_needed = ""
+
+    cmd = "hadoop --config {conf_dir} {command}".format(conf_dir=self.resource.conf_dir,
command=self.resource.command)
+    
+    if kinit_if_needed != "":
+      Execute ( kinit_if_needed,
+        path = ['/bin']
+      )
+  
+    Execute ( cmd,
+      user        = self.resource.user,
+      tries       = self.resource.tries,
+      try_sleep   = self.resource.try_sleep,
+      logoutput   = self.resource.logoutput,
+    )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/fa817f64/ambari-agent/src/main/python/resource_management/libraries/resources/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/resources/__init__.py
b/ambari-agent/src/main/python/resource_management/libraries/resources/__init__.py
index e69de29..3809149 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/resources/__init__.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/resources/__init__.py
@@ -0,0 +1 @@
+from resource_management.libraries.resources.execute_hadoop import *
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/fa817f64/ambari-agent/src/main/python/resource_management/libraries/resources/execute_hadoop.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/resources/execute_hadoop.py
b/ambari-agent/src/main/python/resource_management/libraries/resources/execute_hadoop.py
new file mode 100644
index 0000000..460ed67
--- /dev/null
+++ b/ambari-agent/src/main/python/resource_management/libraries/resources/execute_hadoop.py
@@ -0,0 +1,23 @@
+_all__ = ["ExecuteHadoop"]
+from resource_management.core.base import Resource, ForcedListArgument, ResourceArgument,
BooleanArgument
+
+class ExecuteHadoop(Resource):
+  action = ForcedListArgument(default="run")
+  command = ResourceArgument(default=lambda obj: obj.name)
+  kinit_override = BooleanArgument(default=False)
+  tries = ResourceArgument(default=1)
+  try_sleep = ResourceArgument(default=0) # seconds
+  user = ResourceArgument()
+  logoutput = BooleanArgument(default=False)
+  
+  conf_dir = ResourceArgument()
+  
+  security_enabled = BooleanArgument(default=False)
+  keytab = ResourceArgument()
+  principal = ResourceArgument()
+  kinit_path_local = ResourceArgument()
+  
+
+  
+  actions = Resource.actions + ["run"]
+  
\ No newline at end of file


Mime
View raw message