incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject git commit: AMBARI-3263. Ambar-client updates for JIRA-3201. (Andrew Onischuk via mahadev)
Date Wed, 18 Sep 2013 20:04:31 GMT
Updated Branches:
  refs/heads/trunk e8223b378 -> 91ead9e80


AMBARI-3263. Ambar-client updates for JIRA-3201. (Andrew Onischuk via mahadev)


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

Branch: refs/heads/trunk
Commit: 91ead9e80dfd0c7d7034fa40c5b133706fede467
Parents: e8223b3
Author: Mahadev Konar <mahadev@apache.org>
Authored: Wed Sep 18 13:00:00 2013 -0700
Committer: Mahadev Konar <mahadev@apache.org>
Committed: Wed Sep 18 13:00:00 2013 -0700

----------------------------------------------------------------------
 .../src/main/python/ambari_client/ambari_api.py | 22 -------
 .../src/test/python/TestAmbariClient.py         | 21 +++++++
 .../src/test/python/json/get_host.json          | 63 ++++++++++++++++++++
 3 files changed, 84 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/91ead9e8/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 d9bb4b7..53b608f 100755
--- a/ambari-client/src/main/python/ambari_client/ambari_api.py
+++ b/ambari-client/src/main/python/ambari_client/ambari_api.py
@@ -129,28 +129,6 @@ class AmbariClient(RestResource):
     @return  ClusterModel object.
     """
     return clusters._create_cluster(self, cluster_name, version)
-  
-  def create_host(self, host_name, ip, rack_info='/default-rack'):
-    """
-    Create a host
-    @param root_resource: The root Resource.
-    @param host_name: Host name
-    @param ip: IP address
-    @param rack_info: Rack id. Default None
-    @return: A HostModel object
-    """
-    return hosts._create_host(self, host_name, ip, rack_info)
-  
-  
-  def create_hosts(self, host_list):
-    """
-    Create a host
-    @param root_resource: The root Resource.
-    @param host_list: ModelList list of hosts
-    @return: A HostModel object
-    """
-    return hosts._create_hosts(self, host_list)
-
 
   def delete_cluster(self , cluster_name):
     """

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/91ead9e8/ambari-client/src/test/python/TestAmbariClient.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestAmbariClient.py b/ambari-client/src/test/python/TestAmbariClient.py
index 2dcdfce..6830b6d 100755
--- a/ambari-client/src/test/python/TestAmbariClient.py
+++ b/ambari-client/src/test/python/TestAmbariClient.py
@@ -96,6 +96,27 @@ class TestAmbariClient(unittest.TestCase):
       
     self.assertEqual(len(all_hosts), 12, "There should be 12 hosts from the response")
     
+  @patch("ambari_client.core.http_client.HttpClient")  
+  def test_get_host_valid(self , http_client):
+    """
+    Get host
+    This testcase checks if client.get_host returns a correct host
+    """
+    http_client_mock = MagicMock()
+    http_client.returned_obj = http_client_mock
+    mocked_code = "200" 
+    mocked_content = "text/plain"
+    
+    linestring = open('json/get_host.json', 'r').read()
+    mocked_response = linestring
+    expected_dict_output = {'ip': '10.0.2.15', 'host_name': 'dev06.hortonworks.com', 'rack_info':
'/default-rack'}
+    
+    http_client_mock.invoke.return_value = mocked_response , mocked_code , mocked_content
+    client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)
+    host = client.get_host('dev06.hortonworks.com')
+    
+    self.assertEqual(host.to_json_dict(), expected_dict_output)
+    
        
   @patch("ambari_client.core.http_client.HttpClient")  
   def test_get_cluster_valid(self , http_client):

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/91ead9e8/ambari-client/src/test/python/json/get_host.json
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/json/get_host.json b/ambari-client/src/test/python/json/get_host.json
new file mode 100644
index 0000000..d710626
--- /dev/null
+++ b/ambari-client/src/test/python/json/get_host.json
@@ -0,0 +1,63 @@
+{
+  "href" : "http://localhost:8080/api/v1/hosts/dev06.hortonworks.com",
+  "Hosts" : {
+    "cpu_count" : 4,
+    "desired_configs" : null,
+    "disk_info" : [
+      {
+        "available" : "45333752",
+        "used" : "5748252",
+        "percent" : "12%",
+        "size" : "51606140",
+        "type" : "ext4",
+        "mountpoint" : "/"
+      },
+      {
+        "available" : "5517976",
+        "used" : "272",
+        "percent" : "1%",
+        "size" : "5518248",
+        "type" : "tmpfs",
+        "mountpoint" : "/dev/shm"
+      },
+      {
+        "available" : "432210",
+        "used" : "38034",
+        "percent" : "9%",
+        "size" : "495844",
+        "type" : "ext4",
+        "mountpoint" : "/boot"
+      },
+      {
+        "available" : "44459840",
+        "used" : "184252",
+        "percent" : "1%",
+        "size" : "47033288",
+        "type" : "ext4",
+        "mountpoint" : "/home"
+      },
+      {
+        "available" : "136400692",
+        "used" : "840256712",
+        "percent" : "87%",
+        "size" : "976657404",
+        "type" : "vboxsf",
+        "mountpoint" : "/media/sf_share"
+      }
+    ],
+    "host_health_report" : "",
+    "host_name" : "dev06.hortonworks.com",
+    "host_state" : "HEARTBEAT_LOST",
+    "host_status" : "UNKNOWN",
+    "ip" : "10.0.2.15",
+    "last_agent_env" : null,
+    "last_heartbeat_time" : 0,
+    "last_registration_time" : 1378228232506,
+    "os_arch" : "x86_64",
+    "os_type" : "centos6",
+    "ph_cpu_count" : 1,
+    "public_host_name" : "dev06.hortonworks.com",
+    "rack_info" : "/default-rack",
+    "total_mem" : 11041505
+  }
+}
\ No newline at end of file


Mime
View raw message