incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [14/15] git commit: AMBARI-3664. Resource Management. Implement Configfile resource (Andrew Onischuk via dlisnichenko)
Date Fri, 01 Nov 2013 15:28:25 GMT
AMBARI-3664. Resource Management. Implement Configfile resource (Andrew Onischuk via dlisnichenko)


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

Branch: refs/heads/trunk
Commit: 732d113587391e7d9c62be8fd950ede177255e38
Parents: 002060f
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Fri Nov 1 17:24:58 2013 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Fri Nov 1 17:24:58 2013 +0200

----------------------------------------------------------------------
 .../libraries/providers/__init__.py             |  1 +
 .../libraries/providers/config_file.py          | 20 ++++++++++++++++++++
 .../libraries/resources/__init__.py             |  3 ++-
 .../libraries/resources/config_file.py          | 12 ++++++++++++
 .../libraries/resources/execute_hadoop.py       |  2 --
 5 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/732d1135/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 62652ae..ba4269e 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
@@ -11,5 +11,6 @@ PROVIDERS = dict(
   ),
   default=dict(
     ExecuteHadoop="resource_management.libraries.providers.execute_hadoop.ExecuteHadoopProvider",
+    ConfigFile="resource_management.libraries.providers.config_file.ConfigFileProvider",
   ),
 )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/732d1135/ambari-agent/src/main/python/resource_management/libraries/providers/config_file.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/providers/config_file.py
b/ambari-agent/src/main/python/resource_management/libraries/providers/config_file.py
new file mode 100644
index 0000000..8cc04e0
--- /dev/null
+++ b/ambari-agent/src/main/python/resource_management/libraries/providers/config_file.py
@@ -0,0 +1,20 @@
+import os
+from resource_management import *
+
+class ConfigFileProvider(Provider):
+  def action_create(self):
+    template_tag = self.resource.template_tag
+    qualified_file_name = self.resource.name
+    file_name = os.path.basename(qualified_file_name)
+
+    if not template_tag:
+      template_name = format("{file_name}.j2")
+    else:
+      template_name = format("{file_name}-{template_tag}.j2")
+
+    File( qualified_file_name,
+     owner   = self.resource.owner,
+     group   = self.resource.group,
+     mode    = self.resource.mode,
+     content = Template(template_name)
+    )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/732d1135/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 3809149..0001272 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
@@ -1 +1,2 @@
-from resource_management.libraries.resources.execute_hadoop import *
\ No newline at end of file
+from resource_management.libraries.resources.execute_hadoop import *
+from resource_management.libraries.resources.config_file import *
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/732d1135/ambari-agent/src/main/python/resource_management/libraries/resources/config_file.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/resources/config_file.py
b/ambari-agent/src/main/python/resource_management/libraries/resources/config_file.py
new file mode 100644
index 0000000..3632c8b
--- /dev/null
+++ b/ambari-agent/src/main/python/resource_management/libraries/resources/config_file.py
@@ -0,0 +1,12 @@
+_all__ = ["ConfigFile"]
+from resource_management.core.base import Resource, ForcedListArgument, ResourceArgument,
BooleanArgument
+
+class ConfigFile(Resource):
+  action = ForcedListArgument(default="create")
+  path = ResourceArgument(default=lambda obj: obj.name)
+  mode = ResourceArgument()
+  owner = ResourceArgument()
+  group = ResourceArgument()
+  template_tag = ResourceArgument()
+
+  actions = Resource.actions + ["create"]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/732d1135/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
index 460ed67..622c001 100644
--- 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
@@ -17,7 +17,5 @@ class ExecuteHadoop(Resource):
   principal = ResourceArgument()
   kinit_path_local = ResourceArgument()
   
-
-  
   actions = Resource.actions + ["run"]
   
\ No newline at end of file


Mime
View raw message