You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by su...@apache.org on 2014/05/15 21:27:57 UTC

[1/2] git commit: AMBARI-5663: Python Client should support HTTP Headers.(Subin)

Repository: ambari
Updated Branches:
  refs/heads/trunk b424b21f0 -> 28c249e53


AMBARI-5663: Python Client should support HTTP Headers.(Subin)


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

Branch: refs/heads/trunk
Commit: e7089d4c786e39b988e79eb1ed6d38cefa99891d
Parents: a781a4a
Author: subin <su...@apache.org>
Authored: Fri May 16 00:07:40 2014 +0530
Committer: subin <su...@apache.org>
Committed: Fri May 16 00:07:40 2014 +0530

----------------------------------------------------------------------
 .../src/main/python/ambari_client/ambari_api.py |  8 +++---
 .../python/ambari_client/core/http_client.py    | 18 ++++++++----
 .../python/ambari_client/model/base_model.py    |  5 +++-
 .../main/python/ambari_client/model/cluster.py  | 25 +++++++++--------
 .../python/ambari_client/model/configuration.py | 29 ++++++++++++++++++--
 .../main/python/ambari_client/model/paths.py    |  2 ++
 .../main/python/ambari_client/model/service.py  | 16 ++++++++---
 .../main/python/ambari_client/model/status.py   | 12 +++++++-
 .../main/python/ambari_client/model/utils.py    |  1 +
 .../src/test/python/TestClusterModel.py         | 16 +++++------
 10 files changed, 95 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/ambari_api.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/ambari_api.py b/ambari-client/src/main/python/ambari_client/ambari_api.py
index 9f8e109..daf5e1e 100755
--- a/ambari-client/src/main/python/ambari_client/ambari_api.py
+++ b/ambari-client/src/main/python/ambari_client/ambari_api.py
@@ -36,7 +36,7 @@ class AmbariClient(RestResource):
   """
 
   def __init__(self, host_name, port=None, user_name="admin", password="admin", use_https = False,
-               version=API_VERSION , client=None):
+               version=API_VERSION , client=None ,http_header=None):
     """
     Creates a RestResource object.
 
@@ -59,11 +59,11 @@ class AmbariClient(RestResource):
       if port is None: 
         port = 8080
       
-
-      
     host_url = "%s://%s:%s/api/v%s" % (protocol, host_name, port, version)
     if client is None:
-        client = HttpClient(host_url, user_name , password)
+        client = HttpClient(host_url, user_name , password )
+        if http_header:
+            client.set_headers(http_header)
     RestResource.__init__(self, client)
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/core/http_client.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/core/http_client.py b/ambari-client/src/main/python/ambari_client/core/http_client.py
index 188af83..484ef5d 100755
--- a/ambari-client/src/main/python/ambari_client/core/http_client.py
+++ b/ambari-client/src/main/python/ambari_client/core/http_client.py
@@ -115,13 +115,16 @@ class HttpClient(object):
         self.c.setopt(pycurl.UPLOAD, 1)
     else:
         self.c.setopt(pycurl.CUSTOMREQUEST, http_method)
-        
+
+    data = None    
     if http_method in ('POST','PUT'):
       LOG.debug( "data..........."+str(payload))
       data = json.dumps(payload)
-      data= data.decode('unicode-escape')
-      LOG.debug( data)
+      #data= data.decode('unicode-escape')
+      #LOG.debug( "after unicode decode")
+      #LOG.debug( data)
       data = self._to_bytestring(data)
+      LOG.debug( "after _to_bytestring")
       LOG.debug( data)
       content = StringIO.StringIO(data)
       LOG.debug( content)
@@ -132,13 +135,16 @@ class HttpClient(object):
         self.c.setopt(pycurl.POSTFIELDSIZE, content_length)
       else:
         self.c.setopt(pycurl.INFILESIZE, content_length)
+        
       self.c.setopt(pycurl.READFUNCTION, content.read)
       
-      
+
     self.c.setopt(self.c.URL, url)
     headers = self._get_headers(headers)
-    self.c.setopt(pycurl.HTTPHEADER,
-                        ["%s: %s" % pair for pair in sorted(headers.iteritems())])
+    headers_l = ["%s: %s" % pair for pair in sorted(headers.iteritems())]
+    LOG.debug( headers_l)
+    self.c.setopt(pycurl.HTTPHEADER,headers_l)
+
 
     LOG.debug ("invoke : pycurl.EFFECTIVE_URL = "+self.c.getinfo(pycurl.EFFECTIVE_URL))
     try:

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/base_model.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/base_model.py b/ambari-client/src/main/python/ambari_client/model/base_model.py
index f99c0b8..79fd9ad 100755
--- a/ambari-client/src/main/python/ambari_client/model/base_model.py
+++ b/ambari-client/src/main/python/ambari_client/model/base_model.py
@@ -19,7 +19,7 @@ import sys
 import logging
 import time
 from  ambari_client.model.utils  import get_REF_object, get_unicode, getREF_var_name , LIST_KEY
-
+from operator import itemgetter, attrgetter
 
 __docformat__ = "epytext"
 
@@ -101,6 +101,9 @@ class ModelList(object):
   def __iter__(self):
     return self.objects.__iter__()
 
+  def sort(self, sortkey):
+    self.objects = sorted(self.objects, key=sortkey ,reverse=True) 
+      
   def __getitem__(self, i):
     return self.objects.__getitem__(i)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/cluster.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/cluster.py b/ambari-client/src/main/python/ambari_client/model/cluster.py
index f765f2b..4a8cce6 100755
--- a/ambari-client/src/main/python/ambari_client/model/cluster.py
+++ b/ambari-client/src/main/python/ambari_client/model/cluster.py
@@ -162,12 +162,15 @@ class ClusterModel(BaseModel):
     """
     return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "global")
 
-  def get_core_site_config(self, detail=None):
+  def get_core_site_config(self, tag="version1" ,detail=None):
     """
     Get core-site configuration of  cluster.
-    @return: A ConfigModel object.
+    @return: A ConfigModel object or ModelList<ConfiObject>
     """
-    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "core-site")
+    if(detail == utils.ALL):
+        return configuration._get_all_configuration(self._get_resource_root(), self.cluster_name, "core-site")
+    else:
+        return configuration._get_configuration(self._get_resource_root(), self.cluster_name,  "core-site" ,tag)
 
   def get_hdfs_site_config(self, detail=None):
     """
@@ -183,37 +186,37 @@ class ClusterModel(BaseModel):
     """
     return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "mapred-site")
 
-  def update_global_config(self, config_model , detail=None):
+  def update_global_config(self, config_model , tag="version1" ,detail=None):
     """
     Updates the  global configuration of  cluster.
     @param config_model: The configModel object
     @return: A ConfigModel object.
     """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "global" , "version1", config_model)
+    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "global" , tag, config_model)
 
-  def update_core_site_config(self, config_model , detail=None):
+  def update_core_site_config(self, config_model , tag="version1" ,detail=None):
     """
     Updates the  core-site configuration of  cluster.
     @param config_model: The configModel object
     @return: A ConfigModel object.
     """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "core-site", "version1", config_model)
+    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "core-site", tag, config_model)
 
-  def update_hdfs_site_config(self, config_model , detail=None):
+  def update_hdfs_site_config(self, config_model , tag="version1" , detail=None):
     """
     Updates the  hdfs-site configuration of  cluster.
     @param config_model: The configModel object
     @return: A ConfigModel object.
     """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "hdfs-site", "version1", config_model)
+    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "hdfs-site", tag, config_model)
 
-  def update_mapred_site_config(self, config_model , detail=None):
+  def update_mapred_site_config(self, config_model ,tag="version1" , detail=None):
     """
     Updates the  mapred-site configuration of  cluster.
     @param config_model: The configModel object
     @return: A ConfigModel object.
     """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "mapred-site", "version1", config_model)
+    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "mapred-site", tag, config_model)
 
   def create_services(self, services_list , detail=None):
     """

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/configuration.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/configuration.py b/ambari-client/src/main/python/ambari_client/model/configuration.py
index 6cd2c2a..883caf2 100755
--- a/ambari-client/src/main/python/ambari_client/model/configuration.py
+++ b/ambari-client/src/main/python/ambari_client/model/configuration.py
@@ -16,7 +16,7 @@
 #  limitations under the License.
 
 
-from ambari_client.model.base_model import  BaseModel 
+from ambari_client.model.base_model import  BaseModel , ModelList
 from ambari_client.model import paths , status , utils
 
 
@@ -41,6 +41,28 @@ def _get_configuration(resource_root, cluster_name , type , tag="version1"):
   return config_model
 
 
+def _get_all_configuration(resource_root, cluster_name , type ):
+  """
+  Gets ALL configuration of a cluster of a given type
+  @param resource_root: The root Resource .
+  @param cluster_name: cluster_name
+  @param type: type of config
+  @return: A ConfigModel object
+  """
+  dic = resource_root.get(paths.CONFIGURATION_ALL_PATH % (cluster_name, type))
+  
+  if len(dic["items"]) == 0:
+    return None
+
+  objects = []
+  for cfgm in dic["items"]:
+      config_model = utils.ModelUtils.create_model(ConfigModel , cfgm, resource_root, "NO_KEY")
+      ref_clss = utils.getREF_class_name("cluster_name")
+      config_model._setattr(ref_clss, cfgm['Config']['cluster_name'])
+      objects.append(config_model)
+  return ModelList(objects)
+  
+  
 def _update_configuration(resource_root, cluster_name , type , tag , config_model):
   """
   Update configuration of a cluster
@@ -51,7 +73,7 @@ def _update_configuration(resource_root, cluster_name , type , tag , config_mode
   @return: A ConfigModel object
   """
   data = {"Clusters":{"desired_configs":{ "type":type, "tag":tag, "properties":config_model.properties}}}
-  resp = resource_root.post(path=paths.CREATE_CONFIGURATION_PATH % cluster_name , payload=data)
+  resp = resource_root.put(path=paths.UPDATE_CONFIGURATION_PATH % cluster_name , payload=data )
   return utils.ModelUtils.create_model(status.StatusModel, resp, resource_root, "NO_KEY")
 
 
@@ -103,6 +125,9 @@ class ConfigModel(BaseModel):
       return self.clusterRef.cluster_name
     return None
 
+  def __lt__(self, other):
+    return self.tag < other.tag
+
   def _path(self):
     """
     Return the API path for this service.

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/paths.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/paths.py b/ambari-client/src/main/python/ambari_client/model/paths.py
index 1f43548..f34c26d 100755
--- a/ambari-client/src/main/python/ambari_client/model/paths.py
+++ b/ambari-client/src/main/python/ambari_client/model/paths.py
@@ -42,7 +42,9 @@ REQUEST_STATUS_PATH = "/clusters/%s/requests/%s?fields=tasks/Tasks/status"
 REQUEST_PATH = "clusters/%s/requests/%s"
 
 CONFIGURATION_PATH = "/clusters/%s/configurations?type=%s&tag=%s"
+CONFIGURATION_ALL_PATH = "/clusters/%s/configurations?type=%s"
 CREATE_CONFIGURATION_PATH = "/clusters/%s/configurations"
+UPDATE_CONFIGURATION_PATH="/clusters/%s"
 
 STACK_SERVICES_COMPONENTS_PATH = "/stacks2/HDP/versions/%s/stackServices/%s/serviceComponents?fields=*"
 STACK_SERVICES_CONFIG_PATH = "/stacks2/HDP/versions/%s/stackServices/%s/configurations?fields=*"

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/service.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/service.py b/ambari-client/src/main/python/ambari_client/model/service.py
index e9579c4..ed91d7c 100755
--- a/ambari-client/src/main/python/ambari_client/model/service.py
+++ b/ambari-client/src/main/python/ambari_client/model/service.py
@@ -159,18 +159,26 @@ class ServiceModel(BaseModel):
       status_model.request_path = None
     return status_model
 
-  def start(self):
+  def start(self ,message = None):
     """
     Start a service.
     """
-    data = {"ServiceInfo": {"state": "STARTED"}}
+    data = None
+    if message:
+        data = {"RequestInfo":{"context":message},"Body":{"ServiceInfo":{"state":"STARTED"}}}
+    else:
+        data = {"ServiceInfo": {"state": "STARTED"}}
     return self._action(data)
 
-  def stop(self):
+  def stop(self ,message = None):
     """
     Stop a service.
     """
-    data = {"ServiceInfo": {"state": "INSTALLED"}}
+    data = None
+    if message:
+        data = {"RequestInfo":{"context":message},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}
+    else:
+        data = {"ServiceInfo": {"state": "INSTALLED"}}
     return self._action(data)
 
   def install(self):

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/status.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/status.py b/ambari-client/src/main/python/ambari_client/model/status.py
index ff31220..f88a534 100755
--- a/ambari-client/src/main/python/ambari_client/model/status.py
+++ b/ambari-client/src/main/python/ambari_client/model/status.py
@@ -35,7 +35,7 @@ class StatusModel(BaseModel):
     utils.retain_self_helper(BaseModel, **locals())
 
   def __str__(self):
-    return "<<StatusModel>> status = %s ; requestId = %s ;message = %s" % (self.status, self._get_id() , self.get_message())
+    return "<<StatusModel>> status = %s ; requestId = %s ;message = %s" % (self._get_status(), self._get_id() , self.get_message())
 
   def get_bootstrap_path(self):
     return paths.BOOTSTRAP_PATH + '/' + str(self.requestId)
@@ -59,3 +59,13 @@ class StatusModel(BaseModel):
         return self.id
     else:
         None
+
+  def _get_status(self):
+    if hasattr(self, 'status') and isinstance(self.status, basestring):
+        self.message = self.status
+        self.status = 200
+        return self.status
+    elif hasattr(self, 'status') and isinstance(self.status, int):
+        return self.status
+    else:
+        None
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/main/python/ambari_client/model/utils.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/utils.py b/ambari-client/src/main/python/ambari_client/model/utils.py
index 38add26..0b3b6a0 100755
--- a/ambari-client/src/main/python/ambari_client/model/utils.py
+++ b/ambari-client/src/main/python/ambari_client/model/utils.py
@@ -27,6 +27,7 @@ ref_dic = {"cluster_name":"clusterRef"}
 ref_class_dic = {"ClusterModelRef":"cluster_name"}
 ref_pkg_dic = {"ClusterModelRef":"ambari_client.model.cluster"}
 LIST_KEY = "items"
+ALL="ALL" 
   
 class ModelUtils(object):
   

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7089d4c/ambari-client/src/test/python/TestClusterModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestClusterModel.py b/ambari-client/src/test/python/TestClusterModel.py
index b3758e6..e558706 100644
--- a/ambari-client/src/test/python/TestClusterModel.py
+++ b/ambari-client/src/test/python/TestClusterModel.py
@@ -164,7 +164,7 @@ class TestClusterModel(unittest.TestCase):
     http_client_mock = MagicMock()
     
     expected_properties = {'dfs_namenode_name_dir': 'abc', 'security_enabled': 'false', 'proxyuser_group': 'users', 'hdfs_log_dir_prefix': '/var/log/hadoop', 'dfs_datanode_data_dir': '/hadoop/hdfs/data', 'namenode_formatted_mark_dir': '/var/run/hadoop/hdfs/namenode/formatted/', 'rrdcached_base_dir': '/var/lib/ganglia/rrds', 'user_group': 'hadoop', 'dfs_namenode_checkpoint_dir': '/hadoop/hdfs/namesecondary', 'dfs_namenode_checkpoint_period': '21600', 'hive_user': 'hive', 'fs_checkpoint_size': '0.5', 'hbase_conf_dir': '/etc/hbase', 'datanode_du_reserved': '1', 'dfs_datanode_http_address': '50075', 'namenode_heapsize': '1024m', 'dfs_webhdfs_enabled': 'true', 'oozie_user': 'oozie', 'hcat_conf_dir': '', 'hadoop_conf_dir': '/etc/hadoop/conf', 'dfs_replication': '3', 'namenode_opt_maxnewsize': '640m', 'apache_artifacts_download_url': '', 'dfs_datanode_address': '50010', 'dfs_exclude': 'dfs.exclude', 'yarn_user': 'yarn', 'gpl_artifacts_download_url': '', 'zk_user': 'zookeeper', 'smokeuser':
  'ambari-qa', 'dtnode_heapsize': '1024m', 'gmond_user': 'nobody', 'dfs_datanode_failed_volume_tolerated': '0', 'java64_home': '/usr/jdk/jdk1.6.0_31', 'run_dir': '/var/run/hadoop', 'ganglia_runtime_dir': '/var/run/ganglia/hdp', 'dfs_datanode_data_dir_perm': '750', 'hdfs_enable_shortcircuit_read': 'true', 'hdfs_user': 'hdfs', 'hbase_user': 'hbase', 'webhcat_user': 'hcat', 'gmetad_user': 'nobody', 'dfs_block_local_path_access_user': 'hbase', 'namenode_opt_newsize': '200m', 'mapred_user': 'mapred', 'nagios_group': 'nagios', 'hcat_user': 'hcat', 'hadoop_heapsize': '1024', 'hadoop_pid_dir_prefix': '/var/run/hadoop', 'nagios_user': 'nagios'}
-    expected_post_path = '//clusters/test1/configurations'
+    expected_put_path = '//clusters/test1'
     expected_post_request = {'Clusters': {'desired_configs': {'tag': 'version1', 'type': 'global', 'properties':expected_properties}}}   
     expected_get_path = '//clusters/test1/configurations?type=global&tag=version1'
     expected_get_request = None
@@ -175,7 +175,7 @@ class TestClusterModel(unittest.TestCase):
     cluster.update_global_config(existant_global_config)
     
     self.assertEqual(cluster.cluster_name, "test1")
-    http_client_mock.invoke.assert_any_call('POST', expected_post_path, headers=None, payload=expected_post_request)
+    http_client_mock.invoke.assert_any_call('PUT', expected_put_path, headers=None, payload=expected_post_request)
     http_client_mock.invoke.assert_any_call('GET', expected_get_path, headers=None, payload=expected_get_request)
  
   def test_update_core_site_config(self):
@@ -185,7 +185,7 @@ class TestClusterModel(unittest.TestCase):
     http_client_mock = MagicMock()
     
     expected_properties = {'io.serializations': 'abc', 'fs.checkpoint.size': '0.5', 'fs.trash.interval': '360', 'hadoop.security.authentication': 'simple', 'io.compression.codecs': 'org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec', 'mapreduce.jobtracker.webinterface.trusted': 'false', 'hadoop.security.authorization': 'false', 'fs.checkpoint.edits.dir': '/hadoop/hdfs/namesecondary', 'ipc.client.connection.maxidletime': '30000', 'ipc.client.connect.max.retries': '50', 'hadoop.security.auth_to_local': '\n        RULE:[2:$1@$0]([rn]m@.*)s/.*/yarn/\n        RULE:[2:$1@$0](jhs@.*)s/.*/mapred/\n        RULE:[2:$1@$0]([nd]n@.*)s/.*/hdfs/\n        RULE:[2:$1@$0](hm@.*)s/.*/hbase/\n        RULE:[2:$1@$0](rs@.*)s/.*/hbase/\n        DEFAULT\n    ', 'io.file.buffer.size': '131072', 'dfs.namenode.checkpoint.dir': '/hadoop/hdfs/namesecondary', 'ipc.client.idlethreshold': '8000', 'dfs.namenode.checkpoint.edits.dir': '${dfs.namenode.checkpoint.dir}', 'fs.defaultFS'
 : 'hdfs://dev05.hortonworks.com:8020', 'dfs.namenode.checkpoint.period': '21600'}
-    expected_post_path = '//clusters/test1/configurations'
+    expected_put_path = '//clusters/test1'
     expected_post_request = {'Clusters': {'desired_configs': {'tag': 'version1', 'type': 'core-site', 'properties':expected_properties}}}   
     expected_get_path = '//clusters/test1/configurations?type=core-site&tag=version1'
     expected_get_request = None
@@ -196,7 +196,7 @@ class TestClusterModel(unittest.TestCase):
     cluster.update_core_site_config(existant_global_config)
     
     self.assertEqual(cluster.cluster_name, "test1")
-    http_client_mock.invoke.assert_any_call('POST', expected_post_path, headers=None, payload=expected_post_request)
+    http_client_mock.invoke.assert_any_call('PUT', expected_put_path, headers=None, payload=expected_post_request)
     http_client_mock.invoke.assert_any_call('GET', expected_get_path, headers=None, payload=expected_get_request)
        
   def test_update_hdfs_site_config(self):
@@ -206,7 +206,7 @@ class TestClusterModel(unittest.TestCase):
     http_client_mock = MagicMock()
     
     expected_properties = {'dfs.namenode.avoid.write.stale.datanode': 'abc', 'dfs.webhdfs.enabled': 'true', 'dfs.block.access.token.enable': 'true', 'dfs.datanode.address': '0.0.0.0:50010', 'dfs.cluster.administrators': ' hdfs', 'dfs.datanode.balance.bandwidthPerSec': '6250000', 'dfs.namenode.safemode.threshold-pct': '1.0f', 'dfs.permissions.enabled': 'true', 'dfs.client.read.shortcircuit': 'true', 'dfs.journalnode.edits.dir': '/grid/0/hdfs/journal', 'dfs.blocksize': '134217728', 'dfs.datanode.max.transfer.threads': '1024', 'dfs.datanode.du.reserved': '1', 'dfs.replication': '3', 'dfs.namenode.handler.count': '100', 'fs.permissions.umask-mode': '022', 'dfs.datanode.http.address': '0.0.0.0:50075', 'dfs.datanode.ipc.address': '0.0.0.0:8010', 'dfs.datanode.data.dir': '/hadoop/hdfs/data', 'dfs.namenode.http-address': 'dev05.hortonworks.com:50070', 'dfs.blockreport.initialDelay': '120', 'dfs.datanode.failed.volumes.tolerated': '0', 'dfs.namenode.accesstime.precision': '0', 'dfs.block.loc
 al-path-access.user': 'hbase', 'dfs.https.namenode.https-address': 'dev05.hortonworks.com:50470', 'dfs.namenode.secondary.http-address': 'dev05.hortonworks.com:50090', 'dfs.namenode.stale.datanode.interval': '30000', 'dfs.heartbeat.interval': '3', 'dfs.client.read.shortcircuit.streams.cache.size': '4096', 'dfs.permissions.superusergroup': 'hdfs', 'dfs.journalnode.http-address': '0.0.0.0:8480', 'dfs.domain.socket.path': '/var/lib/hadoop-hdfs/dn_socket', 'dfs.namenode.avoid.read.stale.datanode': 'true', 'dfs.hosts.exclude': '/etc/hadoop/conf/dfs.exclude', 'dfs.datanode.data.dir.perm': '750', 'dfs.namenode.write.stale.datanode.ratio': '1.0f', 'dfs.replication.max': '50', 'dfs.namenode.name.dir': '/hadoop/hdfs/namenode'}
-    expected_post_path = '//clusters/test1/configurations'
+    expected_put_path = '//clusters/test1'
     expected_post_request = {'Clusters': {'desired_configs': {'tag': 'version1', 'type': 'hdfs-site', 'properties':expected_properties}}}   
     expected_get_path = '//clusters/test1/configurations?type=hdfs-site&tag=version1'
     expected_get_request = None
@@ -217,7 +217,7 @@ class TestClusterModel(unittest.TestCase):
     cluster.update_hdfs_site_config(existant_global_config)
     
     self.assertEqual(cluster.cluster_name, "test1")
-    http_client_mock.invoke.assert_any_call('POST', expected_post_path, headers=None, payload=expected_post_request)
+    http_client_mock.invoke.assert_any_call('PUT', expected_put_path, headers=None, payload=expected_post_request)
     http_client_mock.invoke.assert_any_call('GET', expected_get_path, headers=None, payload=expected_get_request)\
     
   def test_update_mapred_site_config(self):
@@ -227,7 +227,7 @@ class TestClusterModel(unittest.TestCase):
     http_client_mock = MagicMock()
     
     expected_properties = {'mapreduce.jobhistory.address': 'abc', 'mapreduce.reduce.input.buffer.percent': '0.0', 'mapred.jobtracker.maxtasks.per.job': '-1', 'mapreduce.framework.name': 'yarn', 'mapreduce.map.speculative': 'false', 'mapreduce.tasktracker.healthchecker.script.path': 'file:////mapred/jobstatus', 'mapreduce.reduce.shuffle.merge.percent': '0.66', 'mapred.userlog.retain.hours': '24', 'yarn.app.mapreduce.am.resource.mb': '1024', 'mapreduce.reduce.shuffle.parallelcopies': '30', 'mapreduce.map.java.opts': '-Xmx320m', 'mapreduce.task.io.sort.factor': '100', 'mapreduce.application.classpath': '$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*,$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*', 'yarn.app.mapreduce.am.command-opts': '-Xmx756m', 'mapreduce.job.reduce.slowstart.completedmaps': '0.05', 'mapreduce.output.fileoutputformat.compress.type': 'BLOCK', 'mapreduce.reduce.speculative': 'false', 'mapreduce.reduce.java.opts': '-Xmx756m', 'mapreduce.am.max-attempts': '2', 'yarn.app.
 mapreduce.am.admin-command-opts': '-Djava.net.preferIPv4Stack=true -Dhadoop.metrics.log.level=WARN', 'mapreduce.jobtracker.system.dir': '/mapred/system', 'mapreduce.map.sort.spill.percent': '0.1', 'mapreduce.task.timeout': '600000', 'mapreduce.map.memory.mb': '1536', 'mapreduce.reduce.log.level': 'INFO', 'mapreduce.jobhistory.intermediate-done-dir': '/mr-history/tmp', 'mapreduce.reduce.memory.mb': '2048', 'mapreduce.tasktracker.map.tasks.maximum': '4', 'yarn.app.mapreduce.am.log.level': 'INFO', 'mapreduce.map.log.level': 'INFO', 'mapreduce.shuffle.port': '13562', 'mapred.jobtracker.taskScheduler': 'org.apache.hadoop.mapred.CapacityTaskScheduler', 'mapreduce.admin.user.env': 'LD_LIBRARY_PATH=/usr/lib/hadoop/lib/native:/usr/lib/hadoop/lib/native/`$JAVA_HOME/bin/java -d32 -version &amp;&gt; /dev/null;if [ $? -eq 0 ]; then echo Linux-i386-32; else echo Linux-amd64-64;fi`', 'mapreduce.jobhistory.webapp.address': 'dev05.hortonworks.com:19888', 'mapred.hosts.exclude': '/etc/hadoop/conf/map
 red.exclude', 'mapreduce.reduce.shuffle.input.buffer.percent': '0.7', 'yarn.app.mapreduce.am.staging-dir': '/user', 'mapred.hosts': '/etc/hadoop/conf/mapred.include', 'mapreduce.jobhistory.done-dir': '/mr-history/done', 'mapreduce.admin.reduce.child.java.opts': '-Djava.net.preferIPv4Stack=true -Dhadoop.metrics.log.level=WARN', 'mapreduce.task.io.sort.mb': '200', 'mapred.task.tracker.task-controller': 'org.apache.hadoop.mapred.DefaultTaskController', 'mapreduce.admin.map.child.java.opts': '-Djava.net.preferIPv4Stack=true -Dhadoop.metrics.log.level=WARN'}
-    expected_post_path = '//clusters/test1/configurations'
+    expected_put_path = '//clusters/test1'
     expected_post_request = {'Clusters': {'desired_configs': {'tag': 'version1', 'type': 'mapred-site', 'properties':expected_properties}}}   
     expected_get_path = '//clusters/test1/configurations?type=mapred-site&tag=version1'
     expected_get_request = None
@@ -238,7 +238,7 @@ class TestClusterModel(unittest.TestCase):
     cluster.update_mapred_site_config(existant_global_config)
     
     self.assertEqual(cluster.cluster_name, "test1")
-    http_client_mock.invoke.assert_any_call('POST', expected_post_path, headers=None, payload=expected_post_request)
+    http_client_mock.invoke.assert_any_call('PUT', expected_put_path, headers=None, payload=expected_post_request)
     http_client_mock.invoke.assert_any_call('GET', expected_get_path, headers=None, payload=expected_get_request)
     
   def test_create_services(self):


[2/2] git commit: Merge branch 'trunk' of https://git-wip-us.apache.org/repos/asf/ambari into test

Posted by su...@apache.org.
Merge branch 'trunk' of https://git-wip-us.apache.org/repos/asf/ambari into test


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

Branch: refs/heads/trunk
Commit: 28c249e5332515a8f98fe18de872380fc1f30faa
Parents: e7089d4 b424b21
Author: Subin <su...@apache.org>
Authored: Fri May 16 00:48:27 2014 +0530
Committer: Subin <su...@apache.org>
Committed: Fri May 16 00:48:27 2014 +0530

----------------------------------------------------------------------
 .../stacks/HDP/2.0.6/services/HIVE/package/scripts/params.py | 3 +--
 .../apache/ambari/server/upgrade/UpgradeCatalog160Test.java  | 4 +---
 .../src/test/python/stacks/2.1/HIVE/test_hive_metastore.py   | 8 ++++----
 .../src/test/python/stacks/2.1/configs/default.json          | 2 +-
 .../src/test/python/stacks/2.1/configs/secured.json          | 2 +-
 ambari-web/app/controllers/wizard/step8_controller.js        | 2 +-
 6 files changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------