incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject git commit: AMBARI-3572. Resource Management. Allow to create multiple resources passing list as a name. (Andrew Onischuk via dlysnichenko)
Date Tue, 22 Oct 2013 16:29:37 GMT
Updated Branches:
  refs/heads/trunk cc8d9fec8 -> f8cf601c1


AMBARI-3572. Resource Management. Allow to create multiple resources passing list as a name.
(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/f8cf601c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/f8cf601c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/f8cf601c

Branch: refs/heads/trunk
Commit: f8cf601c1fac6f2b7571903b3ded8225f71d63a7
Parents: cc8d9fe
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Tue Oct 22 19:28:48 2013 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Tue Oct 22 19:28:48 2013 +0300

----------------------------------------------------------------------
 .../src/main/python/resource_management/base.py        | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f8cf601c/ambari-agent/src/main/python/resource_management/base.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/base.py b/ambari-agent/src/main/python/resource_management/base.py
index 5e3c391..3debebf 100644
--- a/ambari-agent/src/main/python/resource_management/base.py
+++ b/ambari-agent/src/main/python/resource_management/base.py
@@ -86,11 +86,17 @@ class Resource(object):
   initial_wait = ResourceArgument() # in seconds
 
   actions = ["nothing"]
-
+  
   def __new__(cls, name, env=None, provider=None, **kwargs):
+    if isinstance(name, list):
+      while len(name) != 1:
+        cls(name.pop(0), env, provider, **kwargs)
+        
+      name = name[0]
+
     env = env or Environment.get_instance()
     provider = provider or getattr(cls, 'provider', None)
-
+    
     r_type = cls.__name__
     if r_type not in env.resources:
       env.resources[r_type] = {}
@@ -109,6 +115,9 @@ class Resource(object):
     return obj
 
   def __init__(self, name, env=None, provider=None, **kwargs):
+    if isinstance(name, list):
+      name = name.pop(0)
+    
     if hasattr(self, 'name'):
       return
 


Mime
View raw message