You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2014/05/31 09:21:10 UTC
[06/12] AMBARI-5482. Integrate Ambari Shell. (Janos Matyas and
Krisztian Horvath via yusaku)
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/componentmodel_get_metrics.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/componentmodel_get_metrics.json b/ambari-client/python-client/src/test/python/json/componentmodel_get_metrics.json
new file mode 100644
index 0000000..5623d8b
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/componentmodel_get_metrics.json
@@ -0,0 +1,133 @@
+{
+ "href" : "http://192.168.64.101:8080/api/v1/clusters/cl1/hosts/myhost/host_components/DATANODE?fields=metrics",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "DATANODE",
+ "host_name" : "myhost"
+ },
+ "host" : {
+ "href" : "http://192.168.64.101:8080/api/v1/clusters/cl1/hosts/myhost"
+ },
+ "metrics" : {
+ "boottime" : 1.383131209E9,
+ "cpu" : {
+ "cpu_aidle" : 0.0,
+ "cpu_idle" : 85.73,
+ "cpu_nice" : 0.0,
+ "cpu_num" : 1.0,
+ "cpu_speed" : 2967.0,
+ "cpu_system" : 6.84583333333,
+ "cpu_user" : 7.42888888889,
+ "cpu_wio" : 0.00416666666667
+ },
+ "dfs" : {
+ "FSNamesystem" : {
+ "HttpPort" : null,
+ "NamenodeAddress" : "{\"myhost\":\"BP-442795920-192.168.64.101-1383132565020\"}",
+ "RpcPort" : "8010",
+ "Version" : "2.2.0.2.0.6.0-76",
+ "VolumeInfo" : "{\"/hadoop/hdfs/data/current\":{\"freeSpace\":495195869184,\"usedSpace\":345120768,\"reservedSpace\":1073741824}}"
+ },
+ "datanode" : {
+ "blockChecksumOp_avg_time" : 0.0,
+ "blockChecksumOp_num_ops" : 0.0,
+ "blockReports_avg_time" : 6.0,
+ "blockReports_num_ops" : 0.0,
+ "block_verification_failures" : 0.0,
+ "blocks_get_local_pathinfo" : 0.0,
+ "blocks_read" : 0.0,
+ "blocks_removed" : 0.0,
+ "blocks_replicated" : 0.0,
+ "blocks_verified" : 0.0,
+ "blocks_written" : 0.0,
+ "bytes_read" : 0.0,
+ "bytes_written" : 0.0,
+ "copyBlockOp_avg_time" : 0.0,
+ "copyBlockOp_num_ops" : 0.0,
+ "heartBeats_avg_time" : 1.69166666667,
+ "heartBeats_num_ops" : 0.336481481481,
+ "readBlockOp_avg_time" : 0.0,
+ "readBlockOp_num_ops" : 0.0,
+ "reads_from_local_client" : 0.0,
+ "reads_from_remote_client" : 0.0,
+ "replaceBlockOp_avg_time" : 0.0,
+ "replaceBlockOp_num_ops" : 0.0,
+ "writeBlockOp_avg_time" : 13.8969072165,
+ "writeBlockOp_num_ops" : 0.0,
+ "writes_from_local_client" : 0.0,
+ "writes_from_remote_client" : 0.0
+ }
+ },
+ "disk" : {
+ "disk_free" : 495.645,
+ "disk_total" : 525.79,
+ "part_max_used" : 11.6
+ },
+ "jvm" : {
+ "HeapMemoryMax" : 1037959168,
+ "HeapMemoryUsed" : 11395264,
+ "NonHeapMemoryMax" : 136314880,
+ "NonHeapMemoryUsed" : 30798600,
+ "gcCount" : 0.0111111111111,
+ "gcTimeMillis" : 388,
+ "logError" : 0.0,
+ "logFatal" : 0.0,
+ "logInfo" : 0.0,
+ "logWarn" : 0.0,
+ "memHeapCommittedM" : 28.5625,
+ "memHeapUsedM" : 11.7175731111,
+ "memNonHeapCommittedM" : 29.625,
+ "memNonHeapUsedM" : 29.36007675,
+ "threadsBlocked" : 0.0,
+ "threadsNew" : 0.0,
+ "threadsRunnable" : 8.04166666667,
+ "threadsTerminated" : 0.0,
+ "threadsTimedWaiting" : 8.91666666667,
+ "threadsWaiting" : 18.0
+ },
+ "load" : {
+ "load_fifteen" : 0.0692222222222,
+ "load_five" : 0.0592777777778,
+ "load_one" : 0.0125555555556
+ },
+ "memory" : {
+ "mem_buffers" : 23914.2666667,
+ "mem_cached" : 160191.855556,
+ "mem_free" : 183983.855556,
+ "mem_shared" : 0.0,
+ "mem_total" : 1922680.0,
+ "swap_free" : 2593920.0,
+ "swap_total" : 2621432.0
+ },
+ "network" : {
+ "bytes_in" : 30989.8874167,
+ "bytes_out" : 98799.6742778,
+ "pkts_in" : 44.9822222222,
+ "pkts_out" : 214.358916667
+ },
+ "process" : {
+ "proc_run" : 2.0,
+ "proc_total" : 682.397222222
+ },
+ "rpc" : {
+ "NumOpenConnections" : 0.0,
+ "ReceivedBytes" : 0.0,
+ "RpcProcessingTime_avg_time" : 0.0,
+ "RpcProcessingTime_num_ops" : 0.0,
+ "RpcQueueTime_avg_time" : 0.0,
+ "RpcQueueTime_num_ops" : 0.0,
+ "SentBytes" : 0.0,
+ "callQueueLen" : 0.0,
+ "rpcAuthenticationFailures" : 0.0,
+ "rpcAuthenticationSuccesses" : 0.0,
+ "rpcAuthorizationFailures" : 0.0,
+ "rpcAuthorizationSuccesses" : 0.0
+ },
+ "ugi" : {
+ "loginFailure_avg_time" : 0.0,
+ "loginFailure_num_ops" : 0.0,
+ "loginSuccess_avg_time" : 0.0,
+ "loginSuccess_num_ops" : 0.0
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/get_cluster_service.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/get_cluster_service.json b/ambari-client/python-client/src/test/python/json/get_cluster_service.json
new file mode 100755
index 0000000..5b78e05
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/get_cluster_service.json
@@ -0,0 +1,27 @@
+{
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA",
+ "ServiceInfo" : {
+ "cluster_name" : "test6",
+ "service_name" : "GANGLIA",
+ "state" : "INSTALLED",
+ "desired_configs" : { }
+ },
+ "components" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA/components/GANGLIA_MONITOR",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "service_name" : "GANGLIA"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA/components/GANGLIA_SERVER",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_SERVER",
+ "service_name" : "GANGLIA"
+ }
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/get_components_from_stack.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/get_components_from_stack.json b/ambari-client/python-client/src/test/python/json/get_components_from_stack.json
new file mode 100644
index 0000000..55a9c09
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/get_components_from_stack.json
@@ -0,0 +1,41 @@
+{
+ "href" : "http://localhost:8080/api/v1/stacks2/HDP/versions/2.0.5/stackServices/YARN/serviceComponents?fields=*",
+ "items" : [
+ {
+ "href" : "http://localhost:8080/api/v1/stacks2/HDP/versions/2.0.5/stackServices/YARN/serviceComponents/NODEMANAGER",
+ "StackServiceComponents" : {
+ "component_category" : "SLAVE",
+ "component_name" : "NODEMANAGER",
+ "is_client" : false,
+ "is_master" : false,
+ "service_name" : "YARN",
+ "stack_name" : "HDP",
+ "stack_version" : "2.0.5"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/stacks2/HDP/versions/2.0.5/stackServices/YARN/serviceComponents/RESOURCEMANAGER",
+ "StackServiceComponents" : {
+ "component_category" : "MASTER",
+ "component_name" : "RESOURCEMANAGER",
+ "is_client" : false,
+ "is_master" : true,
+ "service_name" : "YARN",
+ "stack_name" : "HDP",
+ "stack_version" : "2.0.5"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/stacks2/HDP/versions/2.0.5/stackServices/YARN/serviceComponents/YARN_CLIENT",
+ "StackServiceComponents" : {
+ "component_category" : "CLIENT",
+ "component_name" : "YARN_CLIENT",
+ "is_client" : true,
+ "is_master" : false,
+ "service_name" : "YARN",
+ "stack_name" : "HDP",
+ "stack_version" : "2.0.5"
+ }
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/get_host_component.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/get_host_component.json b/ambari-client/python-client/src/test/python/json/get_host_component.json
new file mode 100755
index 0000000..709b94b
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/get_host_component.json
@@ -0,0 +1,41 @@
+{
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/NAMENODE",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "NAMENODE",
+ "desired_stack_id" : "HDP-1.3.0",
+ "desired_state" : "INSTALLED",
+ "host_name" : "r01wn01",
+ "stack_id" : "HDP-1.3.0",
+ "state" : "INSTALLED",
+ "actual_configs" : {
+ "core-site" : {
+ "tag" : "version1"
+ },
+ "global" : {
+ "tag" : "version1"
+ },
+ "hdfs-site" : {
+ "tag" : "version1"
+ },
+ "mapred-site" : {
+ "tag" : "version1"
+ }
+ },
+ "configs" : { },
+ "desired_configs" : { }
+ },
+ "host" : {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01"
+ },
+ "component" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/HDFS/components/NAMENODE",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "test6",
+ "component_name" : "NAMENODE",
+ "service_name" : "HDFS"
+ }
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/get_host_components.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/get_host_components.json b/ambari-client/python-client/src/test/python/json/get_host_components.json
new file mode 100755
index 0000000..94a3027
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/get_host_components.json
@@ -0,0 +1,60 @@
+{
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components?ServiceComponentInfo",
+ "items" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn01"
+ },
+ "host" : {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/GANGLIA_SERVER",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_SERVER",
+ "host_name" : "r01wn01"
+ },
+ "host" : {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/MAPREDUCE_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "MAPREDUCE_CLIENT",
+ "host_name" : "r01wn01"
+ },
+ "host" : {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/NAGIOS_SERVER",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "NAGIOS_SERVER",
+ "host_name" : "r01wn01"
+ },
+ "host" : {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/NAMENODE",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "NAMENODE",
+ "host_name" : "r01wn01"
+ },
+ "host" : {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01"
+ }
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/get_service_component.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/get_service_component.json b/ambari-client/python-client/src/test/python/json/get_service_component.json
new file mode 100755
index 0000000..3e993cd
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/get_service_component.json
@@ -0,0 +1,108 @@
+{
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA/components/GANGLIA_MONITOR",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "service_name" : "GANGLIA",
+ "state" : "INSTALLED",
+ "desired_configs" : { }
+ },
+ "host_components" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-83/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-83"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-84/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-84"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-85/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-85"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-86/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-86"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-87/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-87"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-88/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-88"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-89/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-89"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01hn01/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01hn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01mgt/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01mgt"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn02/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn02"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn03/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn03"
+ }
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/get_service_components.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/get_service_components.json b/ambari-client/python-client/src/test/python/json/get_service_components.json
new file mode 100755
index 0000000..967bcbd
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/get_service_components.json
@@ -0,0 +1,133 @@
+{
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA/components?fields=*",
+ "items" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA/components/GANGLIA_MONITOR",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "service_name" : "GANGLIA",
+ "state" : "INSTALLED",
+ "desired_configs" : { }
+ },
+ "host_components" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-83/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-83"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-84/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-84"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-85/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-85"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-86/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-86"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-87/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-87"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-88/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-88"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/apspal44-89/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "apspal44-89"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01hn01/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01hn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01mgt/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01mgt"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn01"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn02/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn02"
+ }
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn03/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "r01wn03"
+ }
+ }
+ ]
+ },
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/services/GANGLIA/components/GANGLIA_SERVER",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_SERVER",
+ "service_name" : "GANGLIA",
+ "state" : "INSTALLED",
+ "desired_configs" : { }
+ },
+ "host_components" : [
+ {
+ "href" : "http://localhost:8080/api/v1/clusters/test6/hosts/r01wn01/host_components/GANGLIA_SERVER",
+ "HostRoles" : {
+ "cluster_name" : "test6",
+ "component_name" : "GANGLIA_SERVER",
+ "host_name" : "r01wn01"
+ }
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/hostmodel_get_host_component.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/hostmodel_get_host_component.json b/ambari-client/python-client/src/test/python/json/hostmodel_get_host_component.json
new file mode 100644
index 0000000..436cfda
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/hostmodel_get_host_component.json
@@ -0,0 +1,181 @@
+{
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/DATANODE",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "DATANODE",
+ "desired_stack_id" : "HDP-2.0.6",
+ "desired_state" : "STARTED",
+ "host_name" : "myhost",
+ "stack_id" : "HDP-2.0.6",
+ "state" : "STARTED",
+ "actual_configs" : {
+ "capacity-scheduler" : {
+ "tag" : "version1"
+ },
+ "core-site" : {
+ "tag" : "version1"
+ },
+ "global" : {
+ "tag" : "version1"
+ },
+ "hbase-site" : {
+ "tag" : "version1"
+ },
+ "hdfs-site" : {
+ "tag" : "version1"
+ },
+ "hive-site" : {
+ "tag" : "version1"
+ },
+ "mapred-site" : {
+ "tag" : "version1"
+ },
+ "oozie-site" : {
+ "tag" : "version1"
+ },
+ "webhcat-site" : {
+ "tag" : "version1"
+ },
+ "yarn-site" : {
+ "tag" : "version1"
+ }
+ },
+ "configs" : { },
+ "desired_configs" : { }
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ },
+ "metrics" : {
+ "boottime" : 1.383131209E9,
+ "cpu" : {
+ "cpu_aidle" : 0.0,
+ "cpu_idle" : 86.7238888889,
+ "cpu_nice" : 0.0,
+ "cpu_num" : 1.0,
+ "cpu_speed" : 2967.0,
+ "cpu_system" : 6.43527777778,
+ "cpu_user" : 6.81722222222,
+ "cpu_wio" : 0.0263888888889
+ },
+ "dfs" : {
+ "FSNamesystem" : {
+ "HttpPort" : null,
+ "NamenodeAddress" : "{\"myhost\":\"BP-442795920-192.168.64.101-1383132565020\"}",
+ "RpcPort" : "8010",
+ "Version" : "2.2.0.2.0.6.0-76",
+ "VolumeInfo" : "{\"/hadoop/hdfs/data/current\":{\"freeSpace\":495195308032,\"usedSpace\":345120768,\"reservedSpace\":1073741824}}"
+ },
+ "datanode" : {
+ "blockChecksumOp_avg_time" : 0.0,
+ "blockChecksumOp_num_ops" : 0.0,
+ "blockReports_avg_time" : 6.0,
+ "blockReports_num_ops" : 0.0,
+ "block_verification_failures" : 0.0,
+ "blocks_get_local_pathinfo" : 0.0,
+ "blocks_read" : 0.0,
+ "blocks_removed" : 0.0,
+ "blocks_replicated" : 0.0,
+ "blocks_verified" : 0.0,
+ "blocks_written" : 0.0,
+ "bytes_read" : 0.0,
+ "bytes_written" : 0.0,
+ "copyBlockOp_avg_time" : 0.0,
+ "copyBlockOp_num_ops" : 0.0,
+ "heartBeats_avg_time" : 1.29537037037,
+ "heartBeats_num_ops" : 0.330833333333,
+ "readBlockOp_avg_time" : 0.0,
+ "readBlockOp_num_ops" : 0.0,
+ "reads_from_local_client" : 0.0,
+ "reads_from_remote_client" : 0.0,
+ "replaceBlockOp_avg_time" : 0.0,
+ "replaceBlockOp_num_ops" : 0.0,
+ "writeBlockOp_avg_time" : 13.8969072165,
+ "writeBlockOp_num_ops" : 0.0,
+ "writes_from_local_client" : 0.0,
+ "writes_from_remote_client" : 0.0
+ }
+ },
+ "disk" : {
+ "disk_free" : 495.644319444,
+ "disk_total" : 525.79,
+ "part_max_used" : 11.6
+ },
+ "jvm" : {
+ "HeapMemoryMax" : 1037959168,
+ "HeapMemoryUsed" : 15927976,
+ "NonHeapMemoryMax" : 136314880,
+ "NonHeapMemoryUsed" : 30819952,
+ "gcCount" : 0.0127777777778,
+ "gcTimeMillis" : 409,
+ "logError" : 0.0,
+ "logFatal" : 0.0,
+ "logInfo" : 0.0,
+ "logWarn" : 0.0,
+ "memHeapCommittedM" : 28.5625,
+ "memHeapUsedM" : 11.6042887139,
+ "memNonHeapCommittedM" : 29.625,
+ "memNonHeapUsedM" : 29.3762000417,
+ "threadsBlocked" : 0.0,
+ "threadsNew" : 0.0,
+ "threadsRunnable" : 8.0,
+ "threadsTerminated" : 0.0,
+ "threadsTimedWaiting" : 9.0,
+ "threadsWaiting" : 18.0
+ },
+ "load" : {
+ "load_fifteen" : 0.19775,
+ "load_five" : 0.211194444444,
+ "load_one" : 0.156638888889
+ },
+ "memory" : {
+ "mem_buffers" : 25446.6,
+ "mem_cached" : 160915.911111,
+ "mem_free" : 176156.088889,
+ "mem_shared" : 0.0,
+ "mem_total" : 1922680.0,
+ "swap_free" : 2593928.0,
+ "swap_total" : 2621432.0
+ },
+ "network" : {
+ "bytes_in" : 31580.1931111,
+ "bytes_out" : 102086.367833,
+ "pkts_in" : 45.7961111111,
+ "pkts_out" : 216.703472222
+ },
+ "process" : {
+ "proc_run" : 2.21111111111,
+ "proc_total" : 681.766666667
+ },
+ "rpc" : {
+ "NumOpenConnections" : 0.0,
+ "ReceivedBytes" : 0.0,
+ "RpcProcessingTime_avg_time" : 0.0,
+ "RpcProcessingTime_num_ops" : 0.0,
+ "RpcQueueTime_avg_time" : 0.0,
+ "RpcQueueTime_num_ops" : 0.0,
+ "SentBytes" : 0.0,
+ "callQueueLen" : 0.0,
+ "rpcAuthenticationFailures" : 0.0,
+ "rpcAuthenticationSuccesses" : 0.0,
+ "rpcAuthorizationFailures" : 0.0,
+ "rpcAuthorizationSuccesses" : 0.0
+ },
+ "ugi" : {
+ "loginFailure_avg_time" : 0.0,
+ "loginFailure_num_ops" : 0.0,
+ "loginSuccess_avg_time" : 0.0,
+ "loginSuccess_num_ops" : 0.0
+ }
+ },
+ "component" : [
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/services/HDFS/components/DATANODE",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "cl1",
+ "component_name" : "DATANODE",
+ "service_name" : "HDFS"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/hostmodel_get_host_components.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/hostmodel_get_host_components.json b/ambari-client/python-client/src/test/python/json/hostmodel_get_host_components.json
new file mode 100644
index 0000000..8148d18
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/hostmodel_get_host_components.json
@@ -0,0 +1,222 @@
+{
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components?fields=HostRoles/state",
+ "items" : [
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/DATANODE",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "DATANODE",
+ "host_name" : "myhost",
+ "state" : "STARTED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "myhost",
+ "state" : "STARTED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/HBASE_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "HBASE_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/HBASE_MASTER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "HBASE_MASTER",
+ "ha_status" : "active",
+ "host_name" : "myhost",
+ "state" : "STARTED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/HBASE_REGIONSERVER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "HBASE_REGIONSERVER",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/HCAT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "HCAT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/HDFS_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "HDFS_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/HIVE_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "HIVE_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/MAPREDUCE2_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "MAPREDUCE2_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/NAMENODE",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "NAMENODE",
+ "host_name" : "myhost",
+ "state" : "STARTED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/NODEMANAGER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "NODEMANAGER",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/OOZIE_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "OOZIE_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/PIG",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "PIG",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/RESOURCEMANAGER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "RESOURCEMANAGER",
+ "host_name" : "myhost",
+ "state" : "STARTED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/SQOOP",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "SQOOP",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/YARN_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "YARN_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/ZOOKEEPER_CLIENT",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "ZOOKEEPER_CLIENT",
+ "host_name" : "myhost",
+ "state" : "INSTALLED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ },
+ {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost/host_components/ZOOKEEPER_SERVER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "ZOOKEEPER_SERVER",
+ "host_name" : "myhost",
+ "state" : "STARTED"
+ },
+ "host" : {
+ "href" : "http://myhost:8080/api/v1/clusters/cl1/hosts/myhost"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/servicemodel_get_component.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/servicemodel_get_component.json b/ambari-client/python-client/src/test/python/json/servicemodel_get_component.json
new file mode 100644
index 0000000..c6cbd08
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/servicemodel_get_component.json
@@ -0,0 +1,20 @@
+{
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/services/GANGLIA/components/GANGLIA_SERVER",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_SERVER",
+ "service_name" : "GANGLIA",
+ "state" : "STARTED",
+ "desired_configs" : { }
+ },
+ "host_components" : [
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/hosts/c6402.ambari.apache.org/host_components/GANGLIA_SERVER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_SERVER",
+ "host_name" : "c6402.ambari.apache.org"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/servicemodel_get_components.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/servicemodel_get_components.json b/ambari-client/python-client/src/test/python/json/servicemodel_get_components.json
new file mode 100644
index 0000000..b9efe73
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/servicemodel_get_components.json
@@ -0,0 +1,61 @@
+{
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/services/GANGLIA/components?fields=*",
+ "items" : [
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/services/GANGLIA/components/GANGLIA_MONITOR",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_MONITOR",
+ "service_name" : "GANGLIA",
+ "state" : "STARTED",
+ "desired_configs" : { }
+ },
+ "host_components" : [
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/hosts/c6401.ambari.apache.org/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "c6401.ambari.apache.org"
+ }
+ },
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/hosts/c6402.ambari.apache.org/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "c6402.ambari.apache.org"
+ }
+ },
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/hosts/c6403.ambari.apache.org/host_components/GANGLIA_MONITOR",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_MONITOR",
+ "host_name" : "c6403.ambari.apache.org"
+ }
+ }
+ ]
+ },
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/services/GANGLIA/components/GANGLIA_SERVER",
+ "ServiceComponentInfo" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_SERVER",
+ "service_name" : "GANGLIA",
+ "state" : "INSTALLED",
+ "desired_configs" : { }
+ },
+ "host_components" : [
+ {
+ "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/hosts/c6402.ambari.apache.org/host_components/GANGLIA_SERVER",
+ "HostRoles" : {
+ "cluster_name" : "cl1",
+ "component_name" : "GANGLIA_SERVER",
+ "host_name" : "c6402.ambari.apache.org"
+ }
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/status_error_with_message.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/status_error_with_message.json b/ambari-client/python-client/src/test/python/json/status_error_with_message.json
new file mode 100644
index 0000000..69ca96d
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/status_error_with_message.json
@@ -0,0 +1,4 @@
+{
+ "status" : 400,
+ "message" : "java.lang.IllegalArgumentException: No enum const class org.apache.ambari.server.state.State.ILLEGAL_STATE"
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/json/status_ok_with_id.json
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/json/status_ok_with_id.json b/ambari-client/python-client/src/test/python/json/status_ok_with_id.json
new file mode 100644
index 0000000..c805e38
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/json/status_ok_with_id.json
@@ -0,0 +1,7 @@
+{
+ "href" : "http://localhost:8080/api/v1/clusters/test1/requests/19",
+ "Requests" : {
+ "id" : 19,
+ "status" : "InProgress"
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/unitTests.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/unitTests.py b/ambari-client/python-client/src/test/python/unitTests.py
new file mode 100755
index 0000000..eadfade
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/unitTests.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+
+import unittest
+import doctest
+from os.path import dirname, split, isdir
+import logging.handlers
+import logging
+
+LOG_FILE_NAME='tests.log'
+SELECTED_PREFIX = "_"
+PY_EXT='.py'
+
+class TestAgent(unittest.TestSuite):
+ def run(self, result):
+ run = unittest.TestSuite.run
+ run(self, result)
+ return result
+
+
+def parent_dir(path):
+ if isdir(path):
+ if path.endswith(os.sep):
+ path = os.path.dirname(path)
+ parent_dir = os.path.dirname(path)
+ else:
+ parent_dir = os.path.dirname(os.path.dirname(path))
+
+ return parent_dir
+
+
+def all_tests_suite():
+
+
+ src_dir = os.getcwd()
+ files_list=os.listdir(src_dir)
+ tests_list = []
+
+ logger.info('------------------------TESTS LIST:-------------------------------------')
+ # If test with special name exists, run only this test
+ selected_test = None
+ for file_name in files_list:
+ if file_name.endswith(PY_EXT) and not file_name == __file__ and file_name.startswith(SELECTED_PREFIX):
+ logger.info("Running only selected test " + str(file_name))
+ selected_test = file_name
+ if selected_test is not None:
+ tests_list.append(selected_test.replace(PY_EXT, ''))
+ else:
+ for file_name in files_list:
+ if file_name.endswith(PY_EXT) and not file_name == __file__:
+ logger.info(file_name)
+ tests_list.append(file_name.replace(PY_EXT, ''))
+ logger.info('------------------------------------------------------------------------')
+
+ suite = unittest.TestLoader().loadTestsFromNames(tests_list)
+ return TestAgent([suite])
+
+def main():
+
+ logger.info('------------------------------------------------------------------------')
+ logger.info('PYTHON AGENT TESTS')
+ logger.info('------------------------------------------------------------------------')
+ runner = unittest.TextTestRunner(verbosity=2, stream=sys.stdout)
+ suite = all_tests_suite()
+ result = runner.run(suite)
+ for error in result.errors:
+ logger.error('Failed test:' + error[0]._testMethodName + '\n' + error[1])
+ for failure in result.failures:
+ logger.error('Failed test:' + failure[0]._testMethodName + '\n' + failure[1])
+ status = result.wasSuccessful()
+
+ if not status:
+ logger.error('-----------------------------------------------------------------------')
+ logger.error('Python unit tests failed')
+ logger.error('Find detailed logs in ' + path)
+ logger.error('-----------------------------------------------------------------------')
+ exit(1)
+ else:
+ logger.info('------------------------------------------------------------------------')
+ logger.info('Python unit tests finished succesfully')
+ logger.info('------------------------------------------------------------------------')
+
+if __name__ == '__main__':
+ import os
+ import sys
+ import io
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + os.sep + 'main' + os.sep + 'python')
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + os.sep + 'main' + os.sep + 'python' + os.sep + 'ambari_agent')
+ logger = logging.getLogger()
+ logger.setLevel(logging.INFO)
+ formatter = logging.Formatter("[%(levelname)s] %(message)s")
+ src_dir = os.getcwd()
+ target_dir = parent_dir(parent_dir(parent_dir(src_dir))) + os.sep + 'target'
+ if not os.path.exists(target_dir):
+ os.mkdir(target_dir)
+ path = target_dir + os.sep + LOG_FILE_NAME
+ file=open(path, "w")
+ consoleLog = logging.StreamHandler(file)
+ consoleLog.setFormatter(formatter)
+ logger.addHandler(consoleLog)
+ main()
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/python-client/src/test/python/utils/HttpClientInvoker.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/utils/HttpClientInvoker.py b/ambari-client/python-client/src/test/python/utils/HttpClientInvoker.py
new file mode 100644
index 0000000..dd753b2
--- /dev/null
+++ b/ambari-client/python-client/src/test/python/utils/HttpClientInvoker.py
@@ -0,0 +1,153 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+import logging
+import unittest
+class HttpClientInvoker():
+ @staticmethod
+ def http_client_invoke_side_effects(*args, **kwargs):
+ localss = locals()
+ logger = logging.getLogger()
+ logger.info(localss)
+ http_method = args[0]
+ url = args[1]
+ payload = kwargs.get("payload",None)
+
+ mocked_code = 200
+ mocked_content = "text/plain"
+
+ if http_method == "GET":
+ # ClusterModel mocking
+ if url == "//clusters/test1":
+ mocked_response = open('json/clustermodel_get_cluster.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/hosts/myhost":
+ mocked_response = open('json/clustermodel_get_host.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/hosts?fields=*":
+ mocked_response = open('json/clustermodel_get_all_hosts.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/configurations?type=global&tag=version1":
+ mocked_response = open('json/clustermodel_get_global_config.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/configurations?type=core-site&tag=version1":
+ mocked_response = open('json/clustermodel_get_core_site_config.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/configurations?type=hdfs-site&tag=version1":
+ mocked_response = open('json/clustermodel_get_hdfs_site_config.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/configurations?type=mapred-site&tag=version1":
+ mocked_response = open('json/clustermodel_get_mapred_site_config.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ # HostModel mocking
+ elif url == '//clusters/test1/hosts/myhost/host_components/DATANODE':
+ mocked_response = open('json/hostmodel_get_host_component.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == '//clusters/test1/hosts/myhost/host_components?fields=HostRoles/state':
+ mocked_response = open('json/hostmodel_get_host_components.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ # ComponentModel mocking
+ elif url == "//clusters/cl1/hosts/myhost/host_components/DATANODE?fields=metrics":
+ mocked_response = open('json/componentmodel_get_metrics.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ # ServiceModel mocking
+ elif url == "//clusters/test1/services/GANGLIA/components?fields=*":
+ mocked_response = open('json/servicemodel_get_components.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/services/GANGLIA/components/GANGLIA_SERVER":
+ mocked_response = open('json/servicemodel_get_component.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ # AmbariClient mocking
+ elif url == "//clusters":
+ mocked_response = open('json/ambariclient_get_all_clusters.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//hosts":
+ mocked_response = open('json/ambariclient_get_all_hosts.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//hosts/dev06.hortonworks.com":
+ mocked_response = open('json/ambariclient_get_host.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//stacks2/HDP/versions/1.3.0/stackServices/HDFS/configurations?fields=*":
+ mocked_response = open('json/ambariclient_get_config.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//stacks2/HDP/versions/1.3.0/stackServices/HDFS/serviceComponents?fields=*":
+ mocked_response = open('json/ambariclient_get_components.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ # others
+ elif url == "//clusters/test1/services/GANGLIA":
+ mocked_response = open('json/clustermodel_get_service.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test1/services?fields=*":
+ mocked_response = open('json/clustermodel_get_all_services.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//stacks2/HDP/versions/2.0.5/stackServices/HDFS/serviceComponents?fields=*":
+ mocked_response = open('json/get_components_from_stack.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test6/services/GANGLIA":
+ mocked_response = open('json/get_cluster_service.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test6/hosts/r01wn01/host_components/NAMENODE":
+ mocked_response = open('json/get_host_component.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test6/hosts/r01wn01/host_components?ServiceComponentInfo":
+ mocked_response = open('json/get_host_components.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test6/services/GANGLIA/components/GANGLIA_MONITOR":
+ mocked_response = open('json/get_service_component.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == "//clusters/test6/services/GANGLIA/components?fields=*":
+ mocked_response = open('json/get_service_components.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ else:
+ print "Unknown get request on url: %s" % url
+ elif http_method == "DELETE":
+ # ClusterModel
+ if url == "//clusters/test1/hosts/deleted_nonexistant_cluster":
+ mocked_response = open('json/clustermodel_error_deleting_host.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ else: # DELETE (generally does not require any response)
+ return "", mocked_code , mocked_content
+ elif http_method == "POST":
+ # AmbariClient
+ if url == "//bootstrap":
+ mocked_response = open('json/ambariclient_bootstrap_hosts.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif url == '//clusters/test1/hosts?Hosts/host_name=myhost':
+ mocked_code = 201
+ return "", mocked_code , mocked_content
+ else: # POST (generally does not require any response)
+ return "", mocked_code , mocked_content
+ else: # PUT (generally does not require any response)
+ # ServiceModel mocking
+ if url == "//clusters/test1/services/GANGLIA":
+ payload_stop = {'ServiceInfo': {'state': 'INSTALLED'}}
+ payload_started = {'ServiceInfo': {'state': 'STARTED'}}
+ payload_illegal = {'ServiceInfo': {'state': 'ILLEGAL_STATE'}}
+ if payload_stop == payload:
+ mocked_response = open('json/status_ok_with_id.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif payload_started == payload:
+ mocked_response = open('json/status_ok_with_id.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ elif payload_illegal == payload:
+ mocked_response = open('json/status_error_with_message.json', 'r').read()
+ return mocked_response, mocked_code , mocked_content
+ else:
+ return "", mocked_code , mocked_content
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/src/examples/create.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/create.py b/ambari-client/src/examples/create.py
deleted file mode 100755
index c5f2658..0000000
--- a/ambari-client/src/examples/create.py
+++ /dev/null
@@ -1,147 +0,0 @@
- #
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import sys
-import logging
-from ambari_client.ambari_api import AmbariClient
-
-
-def main():
-
- path = os.getcwd() ;
- print path
- sys.path.append(path)
-
- logging.basicConfig(filename="ambari_api.log", level=logging.DEBUG , filemode="w")
- logging.info("Program started")
-
-
-
- client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
- print client.version
- print client.host_url
- print"\n"
-
-
- ###############################
- # cluster creation
- ###############################
- # 1) create cluster
- cluster = client.create_cluster("test33", "HDP-1.3.0")
- print cluster
-
-
- cluster = client.get_cluster('test33')
- print cluster
- print cluster.to_json_dict()
- print"\n"
-
- # 2) create services
- services_list = ["HDFS", "MAPREDUCE", "NAGIOS", "GANGLIA"]
- s2 = cluster.create_services(services_list)
- print s2
-
- s2 = cluster.create_service("ZOOKEEPER")
- print s2
-
- # 3) create global config
- s3 = cluster.add_config("global", "version1" , {})
- print s3
- s3 = cluster.add_config("core-site", "version1" , {})
- print s3
- s3 = cluster.add_config("hdfs-site", "version1" , {})
- print s3
- s3 = cluster.add_config("mapred-site", "version1" , {})
- print s3
-# s3 = cluster.add_config("hbase-site", "version1" , {})
-# print s3
-# s3 = cluster.add_config("oozie-site", "version1" , {})
-# print s3
-# s3 = cluster.add_config("hive-site", "version1" , {})
-# print s3
-# s3 = cluster.add_config("webhcat-site", "version1" , {})
-# print s3
-
-
-
-
-# hdfs_components = client.get_components("1.3.0", "HDFS")
-# print hdfs_components
-# mr_components = client.get_components("1.3.0", "MAPREDUCE")
-# print mr_components
-# ganglia_components = client.get_components("1.3.0", "GANGLIA")
-# print ganglia_components
-# nagios_components = client.get_components("1.3.0", "NAGIOS")
-# print nagios_components
-
-
- # 4) add service components
- s2 = cluster.create_service_components("1.3.0", "HDFS")
- print s2
- s2 = cluster.create_service_components("1.3.0", "MAPREDUCE")
- print s2
- s2 = cluster.create_service_components("1.3.0", "GANGLIA")
- print s2
- s2 = cluster.create_service_components("1.3.0", "NAGIOS")
- print s2
-
-
- all_hosts = client.get_all_hosts()
- h_l = [x.host_name for x in all_hosts]
- print h_l
-
- # 5) add hosts
- s3 = cluster.create_hosts(h_l)
- print s3
- print"\n"
-
- # 6) add hosts roles
- host1 = cluster.get_host('r01wn01')
- print host1
- s4 = host1.assign_role("NAMENODE")
- print s4
- print"\n"
-
- # 7) add hosts roles
- s4 = cluster.start_all_services()
- print s4
- print"\n"
-
-
- all_clusters = client.get_all_clusters()
- print all_clusters.to_json_dict()
- print all_clusters
- print"\n"
-
- all_hosts = client.get_all_hosts()
- print all_hosts
- print all_hosts.to_json_dict()
- print"\n"
-
- serviceList = cluster.get_all_services()
- print serviceList
- print serviceList.to_json_dict()
- print"\n"
-########################################################################
-#
-# The "main" entry
-#
-########################################################################
-if __name__ == '__main__':
- main()
-########################################################################
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/src/examples/delete.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/delete.py b/ambari-client/src/examples/delete.py
deleted file mode 100755
index 3debc4c..0000000
--- a/ambari-client/src/examples/delete.py
+++ /dev/null
@@ -1,66 +0,0 @@
- #
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import sys
-import logging
-from ambari_client.ambari_api import AmbariClient
-
-
-def main():
-
- path = os.getcwd() ;
- print path
- sys.path.append(path)
-
- logging.basicConfig(filename="ambari_api.log", level=logging.DEBUG , filemode="w")
- logging.info("Program started")
-
-
-
- client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
- print client.version
- print client.host_url
- print"\n"
-
- ###############################
- # cluster delete
- ###############################
- print dir(client)
-
- s1 = client.delete_cluster("test33")
- print s1
- print s1.to_json_dict()
-
- s1 = client.delete_host("test33")
- print s1
- print s1.to_json_dict()
-
- s1 = client.delete_host("r01wn01")
- print s1
- print s1.to_json_dict()
-
-
-
-########################################################################
-#
-# The "main" entry
-#
-########################################################################
-if __name__ == '__main__':
- main()
-########################################################################
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/src/examples/example.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/example.py b/ambari-client/src/examples/example.py
deleted file mode 100755
index 6702eda..0000000
--- a/ambari-client/src/examples/example.py
+++ /dev/null
@@ -1,133 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import sys
-import logging
-from ambari_client.ambari_api import AmbariClient
-
-
-def main():
-
- path = os.getcwd() ;
- print path
- sys.path.append(path)
-
- logging.basicConfig(filename="ambari_api.log", level=logging.DEBUG , filemode="w")
- logging.info("Program started")
-
-
-
- client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
- print client.version
- print client.host_url
- print"\n"
-
- ######################################
- # High level
- ######################################
- all_clusters = client.get_all_clusters()
- print all_clusters.to_json_dict()
- print all_clusters
- print"\n"
-
- all_hosts = client.get_all_hosts()
- print all_hosts
- print all_hosts.to_json_dict()
- print"\n"
-
-
- ######################################
- # going into a specific cluster
- ######################################
- cluster = client.get_cluster('test46')
- print cluster
- print cluster.to_json_dict()
- print"\n"
-
-
- clusters_hosts = cluster.get_all_hosts()
- print clusters_hosts.to_json_dict()
- print clusters_hosts
- print"\n"
-
-
- #host1 = cluster.get_host('r01wn01')
- host1 = cluster.get_host('r01hn01')
- print host1
- print host1.clusterRef.cluster_name
- print host1.to_json_dict()
- print"\n"
-
-
- host1_comp = host1.get_host_components()
- print host1_comp
- print host1_comp.to_json_dict()
- print"\n"
-
-
- nn = host1.get_host_component("NAMENODE")
- print nn
- print nn.to_json_dict()
- print nn.clusterRef.cluster_name
- print"\n"
-
-
- serviceList = cluster.get_all_services()
- print serviceList
- print serviceList.to_json_dict()
- print"\n"
-
-
- ganglia = cluster.get_service("GANGLIA")
- print ganglia
- print ganglia.to_json_dict()
- print"\n"
-
-
- ganglia_comps = ganglia.get_service_components()
- print ganglia_comps
- print ganglia_comps.to_json_dict()
- print"\n"
-
-
- ganglia_comp1 = ganglia.get_service_component('GANGLIA_MONITOR')
- print ganglia_comp1
- print ganglia_comp1.to_json_dict()
- print ganglia_comp1.clusterRef.cluster_name
- print"\n"
-
- s = client.get_config("1.3.0", "HDFS")
- print s
- print"\n"
-
- s = client.get_components("1.3.0", "HDFS")
- print s
-
-# ganglia.stop()
-# ganglia.start()
-
-
-
-########################################################################
-#
-# The "main" entry
-#
-########################################################################
-if __name__ == '__main__':
- main()
-########################################################################
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/src/examples/main.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/main.py b/ambari-client/src/examples/main.py
deleted file mode 100755
index 04db4c0..0000000
--- a/ambari-client/src/examples/main.py
+++ /dev/null
@@ -1,166 +0,0 @@
- #
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import sys
-import logging
-from ambari_client.ambari_api import AmbariClient
-
-
-def main():
-
- path = os.getcwd() ;
- print path
- sys.path.append(path)
-
- logging.basicConfig(filename="ambari_api.log", level=logging.DEBUG , filemode="w")
- logging.info("Program started")
-
-
-
- client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
- print client.version
- print client.host_url
- print"\n"
-
- ######################################
- # High level
- ######################################
- all_clusters = client.get_all_clusters()
- print all_clusters.to_json_dict()
- print all_clusters
-
-
- all_hosts = client.get_all_hosts()
- print all_hosts
- print all_hosts.to_json_dict()
- print"\n"
-
-
- ######################################
- # going into a specific cluster
- ######################################
- cluster = client.get_cluster('test46')
- print cluster
- print cluster.to_json_dict()
- print"\n"
-
-
- clusters_hosts = cluster.get_all_hosts()
- print clusters_hosts.to_json_dict()
- print clusters_hosts
- print"\n"
-
-
- host1 = cluster.get_host('r01wn01')
- print host1
- print host1.clusterRef.cluster_name
- print host1.to_json_dict()
- print"\n"
-
- print "==================== host components ====================\n"
- host1_comp = host1.get_host_components()
- print host1_comp
- print host1_comp.to_json_dict()
- print"\n"
-
-
- nn = host1.get_host_component("NAMENODE")
- print nn
- print nn.to_json_dict()
- print nn.clusterRef.cluster_name
- metric_json = nn.get_metrics()
- print metric_json["metrics"]["cpu"]
- print"\n"
-
-
- serviceList = cluster.get_all_services()
- print serviceList
- print serviceList.to_json_dict()
- print"\n"
-
-
- ganglia = cluster.get_service("GANGLIA")
- print ganglia
- print ganglia.to_json_dict()
- print"\n"
-
-
- print "==================== service components ====================\n"
- ganglia_comps = ganglia.get_service_components()
- print ganglia_comps
- print ganglia_comps.to_json_dict()
- print"\n"
-
-
- ganglia_comp1 = ganglia.get_service_component('GANGLIA_MONITOR')
- print ganglia_comp1
- print ganglia_comp1.to_json_dict()
- print ganglia_comp1.clusterRef.cluster_name
- print"\n"
-
- mr = cluster.get_service("MAPREDUCE")
- print mr
- print mr.to_json_dict()
- print"\n"
-
- mr_comp1 = mr.get_service_component('TASKTRACKER')
- print mr_comp1
- print mr_comp1.to_json_dict()
- print mr_comp1.clusterRef.cluster_name
- metric_json = mr_comp1.get_metrics()
- print metric_json["metrics"]["cpu"]
- print"\n"
-
- ######################################
- # configurations
- ######################################
- hdfs_config = cluster.get_hdfs_site_config()
- print hdfs_config
- print hdfs_config.properties
-
- global_config = cluster.get_global_config()
- core_config = cluster.get_core_site_config()
- mapred_config = cluster.get_mapred_site_config()
- print global_config
- print core_config
- print mapred_config
- print global_config.clusterRef.cluster_name
- print core_config.clusterRef.cluster_name
- print mapred_config.clusterRef.cluster_name
-
- hdfs_config.properties["dfs.replication.max"] = 51
- #print hdfs_config.properties
- hdfs_config1 = cluster.update_hdfs_site_config(hdfs_config)
- print hdfs_config1.properties
-
-
- ######################################
- # create cluster
- ######################################
-# ganglia.stop()
-# ganglia.start()
-
-
-########################################################################
-#
-# The "main" entry
-#
-########################################################################
-if __name__ == '__main__':
- main()
-########################################################################
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/src/examples/trial.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/trial.py b/ambari-client/src/examples/trial.py
deleted file mode 100755
index 942236e..0000000
--- a/ambari-client/src/examples/trial.py
+++ /dev/null
@@ -1,145 +0,0 @@
- #
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import sys
-import logging
-from ambari_client.ambari_api import AmbariClient
-
-
-def main():
-
- path = os.getcwd() ;
- print path
- sys.path.append(path)
-
- logging.basicConfig(filename="ambari_api.log", level=logging.DEBUG , filemode="w")
- logging.info("Program started")
-
-
-
- client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
- print client.version
- print client.host_url
- print"\n"
-
-# s = client.get_config("1.3.0", "HDFS")
-# print s
-#
-# s = client.get_components("1.3.0", "HDFS")
-# print s
-#
-# mycluster = client.create_cluster("test46", "HDP-1.3.0")
-# print mycluster
-#
- mycluster = client.get_cluster('test46')
- print mycluster
- print mycluster.to_json_dict()
- print"\n"
-#
-# services_list = ["HDFS", "MAPREDUCE", "NAGIOS", "GANGLIA"]
-# s2 = mycluster.create_services(services_list)
-# print s2
-#
-#
-# propr_dict = {"dfs_name_dir":"/data/1/hadoop/hdfs/namenode,/data/2/hadoop/hdfs/namenode,/data/3/hadoop/hdfs/namenode,/data/4/hadoop/hdfs/namenode,/data/5/hadoop/hdfs/namenode,/data/6/hadoop/hdfs/namenode,/data/7/hadoop/hdfs/namenode,/data/8/hadoop/hdfs/namenode", "namenode_heapsize":"1024m", "namenode_opt_newsize":"200m", "fs_checkpoint_dir":"/data/1/hadoop/hdfs/namesecondary", "dfs_data_dir":"/data/1/hadoop/hdfs/data,/data/2/hadoop/hdfs/data,/data/3/hadoop/hdfs/data,/data/4/hadoop/hdfs/data,/data/5/hadoop/hdfs/data,/data/6/hadoop/hdfs/data,/data/7/hadoop/hdfs/data,/data/8/hadoop/hdfs/data,/data/9/hadoop/hdfs/data,/data/10/hadoop/hdfs/data", "dtnode_heapsize":"1024m", "dfs_datanode_failed_volume_tolerated":"0", "dfs_webhdfs_enabled":"true", "hadoop_heapsize":"1024", "datanode_du_reserved":"0", "fs_checkpoint_period":"21600", "fs_checkpoint_size":"67108864", "hdfs_log_dir_prefix":"/var/log/hadoop", "hadoop_pid_dir_prefix":"/var/run/hadoop", "namenode_opt_maxnewsize":"200m", "dfs
_exclude":"dfs.exclude", "dfs_include":"dfs.include", "dfs_replication":"3", "dfs_block_local_path_access_user":"hbase", "dfs_datanode_data_dir_perm":"750", "security_enabled":"false", "namenode_formatted_mark_dir":"/var/run/hadoop/hdfs/namenode/formatted/", "hcat_conf_dir":"", "jtnode_opt_newsize":"200m", "jtnode_opt_maxnewsize":"200m", "jtnode_heapsize":"1024m", "mapred_local_dir":"/data/1/hadoop/mapred,/data/2/hadoop/mapred,/data/3/hadoop/mapred,/data/4/hadoop/mapred,/data/5/hadoop/mapred,/data/6/hadoop/mapred,/data/7/hadoop/mapred,/data/8/hadoop/mapred,/data/9/hadoop/mapred,/data/10/hadoop/mapred", "mapred_map_tasks_max":"4", "mapred_red_tasks_max":"2", "mapred_child_java_opts_sz":"768", "scheduler_name":"org.apache.hadoop.mapred.CapacityTaskScheduler", "mapred_cluster_map_mem_mb":"1536", "mapred_cluster_red_mem_mb":"2048", "mapred_cluster_max_map_mem_mb":"6144", "mapred_cluster_max_red_mem_mb":"4096", "mapred_job_map_mem_mb":"1536", "mapred_job_red_mem_mb":"2048", "io_sort_mb":
"200", "io_sort_spill_percent":"0.9", "mapreduce_userlog_retainhours":"24", "maxtasks_per_job":"-1", "lzo_enabled":"true", "snappy_enabled":"true", "rca_enabled":"true", "mapred_system_dir":"/mapred/system", "mapred_hosts_exclude":"mapred.exclude", "mapred_hosts_include":"mapred.include", "mapred_jobstatus_dir":"file:////mapred/jobstatus", "nagios_web_login":"nagiosadmin", "nagios_web_password":"admin", "nagios_contact":"admin@admin.com", "nagios_group":"nagios", "hbase_conf_dir":"/etc/hbase", "proxyuser_group":"users", "dfs_datanode_address":"50010", "dfs_datanode_http_address":"50075", "gpl_artifacts_download_url":"", "apache_artifacts_download_url":"", "ganglia_runtime_dir":"/var/run/ganglia/hdp", "java64_home":"/usr/jdk/jdk1.6.0_31", "run_dir":"/var/run/hadoop", "hadoop_conf_dir":"/etc/hadoop", "hdfs_user":"hdfs", "mapred_user":"mapred", "hbase_user":"hbase", "hive_user":"hive", "hcat_user":"hcat", "webhcat_user":"hcat", "oozie_user":"oozie", "zk_user":"zookeeper", "gmetad_user"
:"nobody", "gmond_user":"nobody", "nagios_user":"nagios", "smokeuser":"ambari-qa", "user_group":"hadoop", "rrdcached_base_dir":"/var/lib/ganglia/rrds"}
-# print propr_dict
-# s3 = mycluster.add_config("global", "version1" , propr_dict)
-# print s3
-#
-# s2 = mycluster.create_service_components("1.3.0", "HDFS")
-# print s2
-# s2 = mycluster.create_service_components("1.3.0", "MAPREDUCE")
-# print s2
-# s2 = mycluster.create_service_components("1.3.0", "GANGLIA")
-# print s2
-# s2 = mycluster.create_service_components("1.3.0", "NAGIOS")
-# print s2
-#
-# h_l = ['apspal44-83', 'apspal44-84', 'apspal44-85', 'apspal44-86', 'apspal44-87', 'apspal44-88', 'apspal44-89', 'r01hn01', 'r01wn01', 'r01wn02', 'r01wn03']
-# print h_l
-# s3 = mycluster.create_hosts(h_l)
-# print s3
-# print"\n"
-#
-# # 6) add hosts roles
-# host1 = mycluster.get_host('r01hn01')
-# print host1
-# s4 = host1.assign_role("NAMENODE")
-# print s4
-# print"\n"
-#
-# s4 = mycluster.install_all_services()
-# print s4
-# print"\n"
-
-# s4 = mycluster.start_all_services(run_smoke_test=True)
-# print s4
-# print"\n"
-#
-# s4 = mycluster.stop_all_services()
-# print s4
-# print"\n"
-
-# s2 = mycluster.create_service("ZOOKEEPER")
-# print s2
-
-# s2 = mycluster.create_service_components("1.3.0", "ZOOKEEPER")
-# print s2
-#
-
-
-
-# host1 = mycluster.get_host('r01wn01')
-# print host1
-# s4 = host1.assign_role("ZOOKEEPER_SERVER")
-# print s4
-# host1 = mycluster.get_host('r01wn02')
-# print host1
-# s4 = host1.assign_role("ZOOKEEPER_SERVER")
-# print s4
-# host1 = mycluster.get_host('r01wn03')
-# print host1
-# s4 = host1.assign_role("ZOOKEEPER_SERVER")
-# print s4
-# host1 = mycluster.get_host('r01wn03')
-# print host1
-# s4 = host1.assign_role("ZOOKEEPER_CLIENT")
-# print s4
-
- zk = mycluster.get_service("ZOOKEEPER")
- print zk
-
- s = zk.stop()
- print s
-
-
- ######################################
- # create cluster
- ######################################
-# ganglia.stop()
-# ganglia.start()
-
-
-########################################################################
-#
-# The "main" entry
-#
-########################################################################
-if __name__ == '__main__':
- main()
-########################################################################
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/ambari-client/src/main/python/ambari_client/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/__init__.py b/ambari-client/src/main/python/ambari_client/__init__.py
deleted file mode 100755
index 278df2e..0000000
--- a/ambari-client/src/main/python/ambari_client/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
http://git-wip-us.apache.org/repos/asf/ambari/blob/11dd9df8/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
deleted file mode 100755
index daf5e1e..0000000
--- a/ambari-client/src/main/python/ambari_client/ambari_api.py
+++ /dev/null
@@ -1,185 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-from ambari_client.core.http_client import HttpClient
-from ambari_client.resources import clusters , hosts , stacks
-from ambari_client.core.rest_resource import RestResource
-
-__docformat__ = "epytext"
-
-LOG = logging.getLogger(__name__)
-
-
-API_VERSION = 1
-
-
-
-
-class AmbariClient(RestResource):
- """
- AmbariClient top-level root resources.
- """
-
- def __init__(self, host_name, port=None, user_name="admin", password="admin", use_https = False,
- version=API_VERSION , client=None ,http_header=None):
- """
- Creates a RestResource object.
-
- @param host_name: The hostname server.
- @param port: The port of the server.
- @param user_name: Login name.
- @param password: Login password.
- @param version: API version.
- @return RestResource object referring to the root.
- """
-
- self._version = version
-
- if use_https:
- protocol = "https"
- if port is None:
- port = 8443
- else:
- protocol = "http"
- 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 )
- if http_header:
- client.set_headers(http_header)
- RestResource.__init__(self, client)
-
-
-
- @property
- def version(self):
- """
- Returns the API version .
- """
- return self._version
-
-
- def get_all_clusters(self):
- """
- Get all clusters.
- @return : A ModelList of ClusterModel.
- """
- return clusters._get_all_clusters(self)
-
-
- def get_cluster(self, cluster_name):
- """
- Get a cluster by cluster_name.
-
- @param cluster_name : Cluster's cluster_name.
- @return : An ClusterModel.
- """
- return clusters._get_cluster(self, cluster_name)
-
- def get_host(self, host_name):
- """
- Lookup a host by name
- @param root_resource: The root Resource.
- @param host_name: Host name
- @return: A HostModel object
- """
- return hosts._get_host(self, host_name)
-
-
- def get_all_hosts(self):
- """
- Get all hosts in the Data Center
- @return: A ModelList of HostModel objects.
- """
- return hosts._get_all_hosts(self)
-
-
- def get_request_status(self , request_id):
- """
- Get request status
- @param request_id : request id for the request
- @return: A StatusModel object.
- """
- return "TODO"
-
-
- def bootstrap_hosts(self , hosts_list , ssh_key=None):
- """
- Bootstrap hosts.
- @param hosts_list :list of host_names.
- @param ssh_key : ssh key for password-less access
- @return: A StatusModel object.
- """
- return hosts._bootstrap_hosts(self, hosts_list , ssh_key)
-
-
- def create_cluster(self, cluster_name, version):
- """
- Create a new cluster.
- @param cluster_name: Cluster name.
- @param version : HDP version.
- @return ClusterModel object.
- """
- return clusters._create_cluster(self, cluster_name, version)
-
- def delete_cluster(self , cluster_name):
- """
- Delete a cluster
- @param cluster_name: Cluster to be deleted
- """
- return clusters._delete_cluster(self, cluster_name)
-
-
- def delete_host(self , host_name):
- """
- Delete a cluster
- @param host_name: host to be deleted
- """
- return hosts._delete_host(self, host_name)
-
-
- def get_config(self, version, service_name):
- """
- get configurations from stack
- @param version: The HDP version.
- @param service_name: service name
- @return: A ConfigModel object
- """
- return stacks._get_config(self, version, service_name)
-
-
- def get_components(self, version, service_name):
- """
- get components from stack
- @param version: The HDP version.
- @param service_name: service name
- @return: A ConfigModel object
- """
- return stacks._get_components(self, version, service_name)
-
-
-
-
-def get_root_resource(server_host, server_port=None, username="admin", password="admin",
- version=1):
- """
- AmbariClient.
- """
- return AmbariClient(server_host, server_port, username, password, version)