You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/09/10 20:11:10 UTC

[4/4] git commit: AMBARI-3073. Amabri Client refactoring -2. (Subin via mahadev)

AMBARI-3073. Amabri Client refactoring -2. (Subin 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/dd5b2aa4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/dd5b2aa4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/dd5b2aa4

Branch: refs/heads/trunk
Commit: dd5b2aa46ad2e6c39e2bd03f2e4994c33f34f246
Parents: a4a26da
Author: Mahadev Konar <ma...@apache.org>
Authored: Tue Sep 10 11:10:36 2013 -0700
Committer: Mahadev Konar <ma...@apache.org>
Committed: Tue Sep 10 11:10:36 2013 -0700

----------------------------------------------------------------------
 ambari-client/pom.xml                           |    1 +
 ambari-client/src/examples/create.py            |  147 +
 ambari-client/src/examples/delete.py            |   66 +
 ambari-client/src/examples/example.py           |  107 +-
 ambari-client/src/examples/main.py              |  166 ++
 ambari-client/src/examples/trial.py             |  145 +
 .../src/main/python/ambari_client/__init__.py   |    0
 .../src/main/python/ambari_client/ambari_api.py |   84 +-
 .../main/python/ambari_client/core/__init__.py  |    0
 .../main/python/ambari_client/core/coreutils.py |   16 +
 .../main/python/ambari_client/core/errors.py    |    7 +-
 .../python/ambari_client/core/http_client.py    |    0
 .../python/ambari_client/core/http_utils.py     |    0
 .../python/ambari_client/core/rest_resource.py  |   28 +-
 .../main/python/ambari_client/model/__init__.py |    0
 .../python/ambari_client/model/base_model.py    |   31 +-
 .../main/python/ambari_client/model/cluster.py  |  283 +-
 .../python/ambari_client/model/component.py     |   97 +
 .../python/ambari_client/model/configuration.py |  109 +
 .../src/main/python/ambari_client/model/host.py |  155 +-
 .../main/python/ambari_client/model/paths.py    |   31 +-
 .../main/python/ambari_client/model/service.py  |  153 +-
 .../main/python/ambari_client/model/stack.py    |   79 +
 .../main/python/ambari_client/model/status.py   |   38 +-
 .../main/python/ambari_client/model/utils.py    |  180 +-
 .../python/ambari_client/resources/__init__.py  |    0
 .../python/ambari_client/resources/clusters.py  |   38 +-
 .../python/ambari_client/resources/hosts.py     |   36 +-
 .../python/ambari_client/resources/services.py  |   40 -
 .../python/ambari_client/resources/stacks.py    |   41 +
 ambari-client/src/main/python/setup.py          |    0
 ambari-client/src/packages/tarball/all.xml      |    0
 .../src/test/python/TestAmbariClient.py         |   90 +-
 .../src/test/python/json/get_all_clusters.json  |    0
 .../src/test/python/json/get_all_hosts.json     |   77 +
 .../src/test/python/json/get_all_services.json  |  120 -
 .../src/test/python/json/get_cluster.json       |    0
 .../src/test/python/json/get_cluster_host.json  |  250 ++
 .../src/test/python/json/get_cluster_hosts.json | 2770 ++++++++++++++++++
 .../test/python/json/get_cluster_service.json   |   27 +
 .../test/python/json/get_cluster_services.json  |  120 +
 .../test/python/json/get_host_component.json    |   41 +
 .../test/python/json/get_host_components.json   |   60 +
 .../src/test/python/json/get_service.json       |    0
 .../test/python/json/get_service_component.json |  108 +
 .../python/json/get_service_components.json     |  133 +
 ambari-client/src/test/python/unitTests.py      |    0
 47 files changed, 5388 insertions(+), 486 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-client/pom.xml b/ambari-client/pom.xml
old mode 100644
new mode 100755
index 807266c..bd6b320
--- a/ambari-client/pom.xml
+++ b/ambari-client/pom.xml
@@ -39,6 +39,7 @@
     <skipTests>false</skipTests>
     <install.dir>/usr/lib/python2.6/site-packages/ambari_client</install.dir>
     <lib.dir>/usr/lib/ambari-client/lib</lib.dir>
+    <python.ver>python &gt;= 2.6</python.ver>
   </properties>
   <build>
     <plugins>

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/examples/create.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/create.py b/ambari-client/src/examples/create.py
new file mode 100755
index 0000000..c5f2658
--- /dev/null
+++ b/ambari-client/src/examples/create.py
@@ -0,0 +1,147 @@
+ #
+#  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/incubator-ambari/blob/dd5b2aa4/ambari-client/src/examples/delete.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/delete.py b/ambari-client/src/examples/delete.py
new file mode 100755
index 0000000..3debc4c
--- /dev/null
+++ b/ambari-client/src/examples/delete.py
@@ -0,0 +1,66 @@
+ #
+#  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/incubator-ambari/blob/dd5b2aa4/ambari-client/src/examples/example.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/example.py b/ambari-client/src/examples/example.py
old mode 100644
new mode 100755
index f619f92..6702eda
--- a/ambari-client/src/examples/example.py
+++ b/ambari-client/src/examples/example.py
@@ -14,11 +14,7 @@
 #  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
@@ -26,50 +22,103 @@ from ambari_client.ambari_api import  AmbariClient
 
 
 def main():
-  """
-  This method has few examples on how to use the ambari_client api
-  """
+
     path = os.getcwd() ;
     print path
     sys.path.append(path)
     
-    logging.basicConfig(filename="ambari_client.log", level=logging.DEBUG ,filemode="w")
+    logging.basicConfig(filename="ambari_api.log", level=logging.DEBUG , filemode="w")
     logging.info("Program started")
      
      
      
-    client = AmbariClient("localhost", 8080, "admin","admin",version=1)
-
+    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
     print all_clusters.to_json_dict()
+    print all_clusters
     print"\n"
     
-    cluster = client.get_cluster('test1')
-    print cluster
+    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"\n"
-#    
-#    
-#    for service in serviceList:
-#        print str(service.service_name)+" = "+str(service.state)
-#    print"\n"    
-
-    ganglia = cluster.get_service("GANGLIA")       
-    print  ganglia.state
+    ######################################
+    #    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"
     
-#    cluster_ref =  ganglia.clusterRef
-#    print cluster_ref.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.stop()
 #    ganglia.start()
        
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/examples/main.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/main.py b/ambari-client/src/examples/main.py
new file mode 100755
index 0000000..04db4c0
--- /dev/null
+++ b/ambari-client/src/examples/main.py
@@ -0,0 +1,166 @@
+ #
+#  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/incubator-ambari/blob/dd5b2aa4/ambari-client/src/examples/trial.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/examples/trial.py b/ambari-client/src/examples/trial.py
new file mode 100755
index 0000000..942236e
--- /dev/null
+++ b/ambari-client/src/examples/trial.py
@@ -0,0 +1,145 @@
+ #
+#  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/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755
index 6cdaf8c..14e8734
--- a/ambari-client/src/main/python/ambari_client/ambari_api.py
+++ b/ambari-client/src/main/python/ambari_client/ambari_api.py
@@ -17,7 +17,7 @@
 
 import logging
 from ambari_client.core.http_client import HttpClient
-from ambari_client.resources import  clusters ,hosts
+from ambari_client.resources import  clusters , hosts , stacks
 from ambari_client.core.rest_resource import RestResource
 
 __docformat__ = "epytext"
@@ -35,8 +35,8 @@ class AmbariClient(RestResource):
   AmbariClient top-level root resources.
   """
 
-  def __init__(self, host_name, port=None,user_name="admin", password="admin",
-               version=API_VERSION , client = None):
+  def __init__(self, host_name, port=None, user_name="admin", password="admin",
+               version=API_VERSION , client=None):
     """
     Creates a RestResource object.
 
@@ -52,9 +52,9 @@ class AmbariClient(RestResource):
     protocol = "http"
     if port is None: 
       port = 8080
-    host_url = "%s://%s:%s/api/v%s" %(protocol, host_name, port, version)
+    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)
     RestResource.__init__(self, client)
 
 
@@ -70,71 +70,97 @@ class AmbariClient(RestResource):
   def get_all_clusters(self):
     """
     Get all clusters.
-    @return: A list of ModelList.
+    @return : A ModelList of ClusterModel.
     """
-    return clusters.get_all_clusters(self)
-
-
+    return clusters._get_all_clusters(self)
 
 
   def get_cluster(self, cluster_name):
     """
     Get a cluster by cluster_name.
 
-    @param cluster_name Cluster cluster_name.
-    @return An ClusterModel.
+    @param cluster_name : Cluster's cluster_name.
+    @return : An ClusterModel.
     """
-    return clusters.get_cluster(self, cluster_name)
-
+    return clusters._get_cluster(self, cluster_name)
 
 
   def get_all_hosts(self):
     """
-    Get all hosts
-    @return: A list of HostModel objects.
+    Get all hosts in the Data Center
+    @return: A ModelList of HostModel objects.
     """
-    return hosts.get_all_hosts(self)
+    return hosts._get_all_hosts(self)
 
 
-  def get_request_status(self , request_path):
+  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):
+  def bootstrap_hosts(self , hosts_list , ssh_key=None):
     """
     Bootstrap hosts.
-    @param hosts list of host_names.
+    @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)
+    return hosts._bootstrap_hosts(self, hosts_list , ssh_key)
 
 
   def create_cluster(self, cluster_name, version):
     """
     Create a new cluster.
-    @param name Cluster name.
-    @param version HDP version.
+    @param cluster_name: Cluster name.
+    @param version : HDP version.
     @return  ClusterModel object.
     """
-    return clusters.create_cluster(self, cluster_name, version)  
+    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_cluster(self ,cluster_name):
+  def delete_host(self , host_name):
     """
-    Create a cluster
-    @param root_resource: The root Resource.
-    @param cluster_name: Cluster cluster_name
+    Delete a cluster
+    @param host_name: host to be deleted
     """
-    return clusters.delete_cluster(self, cluster_name)
+    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",
+def get_root_resource(server_host, server_port=None, username="admin", password="admin",
                        version=1):
   """
    AmbariClient.

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/core/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/core/__init__.py b/ambari-client/src/main/python/ambari_client/core/__init__.py
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/core/coreutils.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/core/coreutils.py b/ambari-client/src/main/python/ambari_client/core/coreutils.py
new file mode 100755
index 0000000..d3e1b4f
--- /dev/null
+++ b/ambari-client/src/main/python/ambari_client/core/coreutils.py
@@ -0,0 +1,16 @@
+#
+#  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/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/core/errors.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/core/errors.py b/ambari-client/src/main/python/ambari_client/core/errors.py
old mode 100644
new mode 100755
index 7031d52..65515ed
--- a/ambari-client/src/main/python/ambari_client/core/errors.py
+++ b/ambari-client/src/main/python/ambari_client/core/errors.py
@@ -17,14 +17,17 @@
 
 class ResourceError(Exception):
 
-    def __init__(self, msg=None, code=None, response=None):
+    def __init__(self, msg=None, http_code=None, response=None):
         self.msg = msg or ''
-        self.status_code = code
+        self.status_code = http_code
         self.response = response
         Exception.__init__(self)
         
     def _get_message(self):
         return self.msg
+    def _set_message(self, msg):
+        self.msg = msg or ''
+    message = property(_get_message, _set_message)    
     
     def __str__(self):
         if self.msg:

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/core/http_utils.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/core/http_utils.py b/ambari-client/src/main/python/ambari_client/core/http_utils.py
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/core/rest_resource.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/core/rest_resource.py b/ambari-client/src/main/python/ambari_client/core/rest_resource.py
old mode 100644
new mode 100755
index 683d1af..2a79ee7
--- a/ambari-client/src/main/python/ambari_client/core/rest_resource.py
+++ b/ambari-client/src/main/python/ambari_client/core/rest_resource.py
@@ -51,8 +51,7 @@ class RestResource(object):
       return { 'Content-Type': content_type }
     return None
 
-
-  def make_invoke(self, http_method, payload, headers, path):
+  def _make_invoke(self, http_method, payload, headers, path):
       return self._client.invoke(http_method, path, payload=payload, headers=headers)
 
   def invoke(self, http_method, url_path=None, payload=None, headers=None):
@@ -60,18 +59,22 @@ class RestResource(object):
     Invoke an API http_method.
     """
     path = self._join_uri(url_path)
-    resp ,code , content  = self.make_invoke(http_method, payload, headers, path)
+    resp , code , content = self._make_invoke(http_method, payload, headers, path)
 
-    LOG.debug ("RESPONSE from the REST request >>>>>>> \n"+str(resp) )
+    LOG.debug ("RESPONSE from the REST request >>>>>>> \n" + str(resp))
     LOG.debug ("\n===========================================================")
     #take care of REST calls with no response
-    if not resp and (code!=200 and code!=201):
-        raise Exception("Command '%s %s' failed with error %s" %(http_method, path,code))
-    if resp and (code==404 or code==405):
-        raise Exception("Command '%s %s' failed with error %s" %(http_method, path,code))
+    if not resp and (code != 200 and code != 201):
+        LOG.error("Command '%s %s' failed with error %s" % (http_method, path, code))
+        return {"status":code , "message":"Command '%s %s' failed with error %s" % (http_method, path, code)}
+        #raise Exception("Command '%s %s' failed with error %s" % (http_method, path, code))
+    if resp and (code == 404 or code == 405):
+        LOG.error("Command '%s %s' failed with error %s" % (http_method, path, code))
+        return {"status":code , "message":"Command '%s %s' failed with error %s" % (http_method, path, code)}
+        #raise Exception("Command '%s %s' failed with error %s" % (http_method, path, code))
     try:
-        if (code==200 or code==201) and not resp:
-          return {}
+        if (code == 200 or code == 201) and not resp:
+          return {"status":code}
         json_dict = json.loads(resp)
         return json_dict
     except Exception, ex:
@@ -79,7 +82,6 @@ class RestResource(object):
         raise ex
 
 
-
   def get(self, path=None):
     """
     Invoke the GET method .
@@ -97,7 +99,7 @@ class RestResource(object):
     @param content_type: 
     @return: A dictionary of the REST result.
     """
-    return self.invoke("PUT", path, payload,self._set_headers(content_type))
+    return self.invoke("PUT", path, payload, self._set_headers(content_type))
 
 
   def post(self, path=None, payload=None, content_type=None):
@@ -108,7 +110,7 @@ class RestResource(object):
     @param content_type: 
     @return: A dictionary of the REST result.
     """
-    return self.invoke("POST", path, payload,self._set_headers(content_type))
+    return self.invoke("POST", path, payload, self._set_headers(content_type))
 
 
   def delete(self, path=None, payload=None,):

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/model/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/__init__.py b/ambari-client/src/main/python/ambari_client/model/__init__.py
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755
index 1c00e60..f99c0b8
--- a/ambari-client/src/main/python/ambari_client/model/base_model.py
+++ b/ambari-client/src/main/python/ambari_client/model/base_model.py
@@ -18,7 +18,7 @@
 import sys
 import logging
 import time
-from  ambari_client.model.utils  import get_REF_object,get_unicode,getREF_var_name
+from  ambari_client.model.utils  import get_REF_object, get_unicode, getREF_var_name , LIST_KEY
 
 
 __docformat__ = "epytext"
@@ -35,18 +35,17 @@ class BaseModel(object):
   REF_ATTR - A REF attribute   
 
   """
-  RO_ATTR = ( )         
-  RW_ATTR = ( )         
-  REF_ATTR = ( )        
-
+  RO_ATTR = ()         
+  RW_ATTR = ()         
+  REF_ATTR = ()        
   
   def __init__(self, resource_root, **rw_attrs):
     #print" ================== base_model\n"
-    print locals()
+    #print locals()
     self._resource_root = resource_root
     for k, v in rw_attrs.items():
       if k not in self.RW_ATTR:
-        raise ValueError("Unknown argument '%s' in %s" %
+        raise ValueError("Unknown argument '%s' in %s" % 
                          (k, self.__class__.__name__))
       self._setattr(k, v)
 
@@ -66,27 +65,23 @@ class BaseModel(object):
 
   def _setattr(self, k, v):
     """Set an attribute. """
-    value=v
+    value = v
     if v and k.endswith("Ref"):
-      cls_name =  k[0].upper() + k[1:] 
+      cls_name = k[0].upper() + k[1:] 
       cls_name = cls_name[:-3] + "ModelRef"
-      cls=get_REF_object(cls_name)
-      LOG.debug(str(cls_name) +"  -  "+str(cls))
+      cls = get_REF_object(cls_name)
+      LOG.debug(str(cls_name) + "  -  " + str(cls))
       v = get_unicode(v)
-      var_name=getREF_var_name(cls_name)
-      c={str(var_name):str(v)}
+      var_name = getREF_var_name(cls_name)
+      c = {str(var_name):str(v)}
       LOG.debug(c)
       value = cls(self._get_resource_root(), **c)
     setattr(self, k, value)
 
 
 
-
-
-
 class ModelList(object):
   """A list of Model objects"""
-  LIST_KEY = "items"
 
   def __init__(self, objects):
     self.objects = objects
@@ -97,7 +92,7 @@ class ModelList(object):
         ", ".join([str(item) for item in self.objects]))
 
   def to_json_dict(self):
-    return { ModelList.LIST_KEY :
+    return { LIST_KEY :
             [ x.to_json_dict() for x in self.objects ] }
 
   def __len__(self):

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755
index 7a012dd..f4cd6f5
--- a/ambari-client/src/main/python/ambari_client/model/cluster.py
+++ b/ambari-client/src/main/python/ambari_client/model/cluster.py
@@ -17,37 +17,35 @@
 
 import logging
 import time
-from ambari_client.model.base_model import  BaseModel 
-from ambari_client.model.paths import CLUSTERS_PATH 
-from ambari_client.model import service ,host
-from ambari_client.model.utils import ModelUtils ,retain_self_helper
+from ambari_client.model.base_model import  BaseModel , ModelList
+from ambari_client.model import service , host , paths , status, configuration , utils
 
 
 LOG = logging.getLogger(__name__)
 
 
-def get_cluster(resource_root, cluster_name):
+def _get_cluster(resource_root, cluster_name):
   """
   Lookup a cluster by cluster_name
   @param resource_root: The root Resource .
   @param cluster_name: cluster_name
   @return: A ClusterModel object
   """
-  dic = resource_root.get("%s/%s" % (CLUSTERS_PATH, cluster_name))
-  return ModelUtils.create_model(ClusterModel ,dic, resource_root,"Clusters")
+  dic = resource_root.get("%s/%s" % (paths.CLUSTERS_PATH, cluster_name))
+  return utils.ModelUtils.create_model(ClusterModel , dic, resource_root, "Clusters")
 
-def get_all_clusters(root_resource, details=None):
+
+def _get_all_clusters(root_resource):
   """
   Get all clusters
   @param root_resource: The root Resource .
   @return: A list of ClusterModel objects.
   """
-  dic = root_resource.get(CLUSTERS_PATH)
-  return ModelUtils.get_model_list(ClusterModel, dic, root_resource ,"Clusters")
-
+  dic = root_resource.get(paths.CLUSTERS_PATH)
+  return utils.ModelUtils.get_model_list(ModelList, ClusterModel, dic, root_resource , "Clusters")
 
 
-def create_cluster(root_resource, cluster_name, version):
+def _create_cluster(root_resource, cluster_name, version):
   """
   Create a cluster
   @param root_resource: The root Resource.
@@ -55,68 +53,277 @@ def create_cluster(root_resource, cluster_name, version):
   @param version: HDP version
   @return: An ClusterModel object
   """
-  data={"Clusters":{"version":str(version)}}
+  data = {"Clusters":{"version":str(version)}}
   cluster = ClusterModel(root_resource, cluster_name, version)
-  path = CLUSTERS_PATH+"/%s" % (cluster_name)
+  path = paths.CLUSTERS_PATH + "/%s" % (cluster_name)
   root_resource.post(path=path , payload=data)
-  return get_cluster(root_resource, cluster_name)
+  return _get_cluster(root_resource, cluster_name)
+
 
-def delete_cluster(root_resource, cluster_name):
+def _delete_cluster(root_resource, cluster_name):
   """
   Delete a cluster by name
-  @param root_resource: The root Resource object.
+  @param root_resource: The root Resource .
+  @param name: Cluster name
+  """
+  resp = root_resource.delete("%s/%s" % (paths.CLUSTERS_PATH, cluster_name))
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _install_all_services(root_resource, cluster_name):
+  """
+  Start all services
+  @param root_resource: The root Resource .
   @param name: Cluster name
   """
-  root_resource.delete("%s/%s" % (CLUSTERS_PATH, cluster_name))
-  time.sleep(3)
-  return None
+  cpath = paths.CLUSTER_START_ALL_SERVICES % cluster_name
+  data = {"RequestInfo": {"context" :"Install Services"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}
+  resp = root_resource.put(path=cpath , payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
 
+def _stop_all_services(root_resource, cluster_name):
+  """
+  Start all services
+  @param root_resource: The root Resource .
+  @param name: Cluster name
+  """
+  cpath = paths.CLUSTER_STOP_ALL_SERVICES % cluster_name
+  data = {"RequestInfo": {"context" :"Stop All Services"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}
+  resp = root_resource.put(path=cpath , payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _start_all_services(root_resource, cluster_name , run_smoke_test=False):
+  """
+  Start all services
+  @param root_resource: The root Resource .
+  @param name: Cluster name
+  """
+  cpath = paths.CLUSTER_START_ALL_SERVICES % cluster_name
+  if run_smoke_test:
+     cpath = "%s&%s" % (cpath, "params/run_smoke_test=true&params/reconfigure_client=false")
+  data = {"RequestInfo": {"context" :"Start All Services"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}
+  resp = root_resource.put(path=cpath , payload=data)
+  if isinstance(resp, dict) and resp.has_key("Requests"):
+      resp = resp["Requests"]      
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+    
     
+        
 class ClusterModel(BaseModel):
-
+  """
+  The ClusterModel class
+  """
   RW_ATTR = ('cluster_name', 'version')
- 
   
   def __init__(self, resource_root, cluster_name, version):
-    retain_self_helper(**locals())
+    utils.retain_self_helper(BaseModel, **locals())
 
   def __str__(self):
-    return "<<ClusterModel>> = %s; version = %s" % (self.cluster_name, self.version)
+    return "<<ClusterModel>> cluster_name = %s; version = %s" % (self.cluster_name, self.version)
 
   def _path(self):
-    return "%s/%s" % (CLUSTERS_PATH, self.cluster_name)
+    return "%s/%s" % (paths.CLUSTERS_PATH, self.cluster_name)
 
   def get_service(self, service_name):
     """
     Get a service by service_name.
-    @param service_name: Service service_name
+    @param service_name: Service name
     @return: A ServiceModel object
     """
-    return service.get_service(self._get_resource_root(), service_name, self.cluster_name)
+    return service._get_service(self._get_resource_root(), service_name, self.cluster_name)
 
-  def get_all_services(self, detail = None):
+  def get_all_services(self, detail=None):
     """
     Get all services in this cluster.
-    @return: A list of ServiceModel objects.
+    @return: ModelList containing ServiceModel objects.
     """
-    return service.get_all_services(self._get_resource_root(), self.cluster_name)
+    return service._get_all_services(self._get_resource_root(), self.cluster_name)
 
-  def get_all_hosts(self, detail = None):
+  def get_all_hosts(self, detail=None):
     """
     Get all hosts in this cluster.
-    @return: A list of HostModel objects.
+    @return: ModelList containing HostModel objects.
     """
-    return host.get_all_cluster_hosts(self._get_resource_root(), self.cluster_name)
+    return host._get_all_cluster_hosts(self._get_resource_root(), self.cluster_name)
 
-
-  def get_host(self, hostname , detail = None):
+  def get_host(self, hostname , detail=None):
     """
     Get a specific hosts in this cluster.
     @return: A HostModel object.
     """
-    return host.get_host(self._get_resource_root(), self.cluster_name, hostname)
+    return host._get_host(self._get_resource_root(), self.cluster_name, hostname)
+
+  def get_global_config(self, detail=None):
+    """
+    Get global configuration of  cluster.
+    @return: A ConfigModel object.
+    """
+    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "global")
+
+  def get_core_site_config(self, detail=None):
+    """
+    Get core-site configuration of  cluster.
+    @return: A ConfigModel object.
+    """
+    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "core-site")
+
+  def get_hdfs_site_config(self, detail=None):
+    """
+    Get hdfs-site configuration of  cluster.
+    @return: A ConfigModel object.
+    """
+    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "hdfs-site")
+
+  def get_mapred_site_config(self, detail=None):
+    """
+    Get mapred-site configuration of  cluster.
+    @return: A ConfigModel object.
+    """
+    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "mapred-site")
+
+  def update_global_config(self, config_model , 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)
+
+  def update_core_site_config(self, config_model , 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)
+
+  def update_hdfs_site_config(self, config_model , 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)
+
+  def update_mapred_site_config(self, config_model , 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)
+
+  def create_services(self, services_list , detail=None):
+    """
+    Creates services.
+    @param services_list: list of services
+    @return: StatusModel.
+    """
+    return service._create_services(self._get_resource_root(), self.cluster_name , services_list)
+
+  def create_service(self, service_name , detail=None):
+    """
+    Creates a single service 
+    @param service_name: service name
+    @return: StatusModel.
+    """
+    return service._create_service(self._get_resource_root(), self.cluster_name , service_name)
+
+  def create_service_components(self, version , service_name , detail=None):
+    """
+    Creates service with components
+    @param version: version
+    @param service_name: service_name
+    @return: StatusModel.
+    """
+    return service._create_service_components(self._get_resource_root(), self.cluster_name , version, service_name)
+
+  def create_service_component(self, version , service_name , component_name , detail=None):
+    """
+    Create service with component
+    @param version: version
+    @param service_name: service_name
+    @return: StatusModel.
+    """
+    return service._create_service_component(self._get_resource_root(), self.cluster_name , version, service_name, component_name)
+
+  def create_hosts(self, host_list , detail=None):
+    """
+    Creates hosts.
+    @param host_list: list of Host name
+    @return: StatusModel.
+    """
+    return host._add_hosts(self._get_resource_root(), self.cluster_name , host_list)
+
+  def create_host(self, host_name, ip, rack_info='/default-rack', detail=None):
+    """
+    Creates host.
+    @param host_name: Host name
+    @param ip: ip of Host 
+    @param rack_info: rack information
+    @return: StatusModel.
+    """
+    return host._add_host(self._get_resource_root(), self.cluster_name , host_name , ip , rack_info)
+
+  def delete_host(self, host_name, detail=None):
+    """
+    deletes a host.
+    @param host_name: Host name
+    @return: StatusModel.
+    """
+    return host._delete_cluster_host(self._get_resource_root(), self.cluster_name , host_name)
+
+  def start_all_services(self, run_smoke_test=False , detail=None):
+    """
+    Start all the services.
+    @return: StatusModel.
+    """
+    return _start_all_services(self._get_resource_root(), self.cluster_name, run_smoke_test)
+
+  def stop_all_services(self, detail=None):
+    """
+    Stop all the services.
+    @return: StatusModel.
+    """
+    return _stop_all_services(self._get_resource_root(), self.cluster_name)
+
+  def install_all_services(self, detail=None):
+    """
+    INIT all the services.
+    @return: StatusModel.
+    """
+    return _install_all_services(self._get_resource_root(), self.cluster_name)
+
+  def add_config(self , type, tag , properties):
+    """
+    add configurations to the cluster
+    @param type: the type of config
+    @param tag: tag
+    @param properties: a dict of properties
+    @return: A StatusModel object
+    """
+    return configuration._add_config(self._get_resource_root(), self.cluster_name , type, tag , properties)   
+
+  def create_config(self , type, tag , properties):
+    """
+    create configurations to the cluster
+    @param type: the type of config
+    @param tag: tag
+    @param properties: a dict of properties
+    @return: A StatusModel object
+    """
+    return configuration._create_config(self._get_resource_root(), self.cluster_name , type, tag , properties)   
+
+
 
 class ClusterModelRef(BaseModel):
+  """
+  The ClusterModelRef class
+    Some models need reference to cluster
+  """
   RW_ATTR = ('cluster_name',)
-  def __init__(self, resource_root, cluster_name = None):
-    retain_self_helper(**locals())
+  def __init__(self, resource_root, cluster_name=None):
+    utils.retain_self_helper(BaseModel, **locals())

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/model/component.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/component.py b/ambari-client/src/main/python/ambari_client/model/component.py
new file mode 100755
index 0000000..586f21a
--- /dev/null
+++ b/ambari-client/src/main/python/ambari_client/model/component.py
@@ -0,0 +1,97 @@
+#
+#  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.model.base_model import  BaseModel , ModelList
+from ambari_client.model  import paths , utils , status
+
+
+
+LOG = logging.getLogger(__name__)
+
+
+def get_host_components(resource_root, cluster_name , host_name):
+  path = paths.HOSTS_COMPONENTS_PATH % (cluster_name, host_name)
+  dic = resource_root.get(path)
+  return utils.ModelUtils.get_model_list(ModelList, ComponentModel, dic, resource_root , "HostRoles")
+
+
+def get_host_component(resource_root, cluster_name , host_name , component_name):
+  path = paths.HOSTS_COMPONENT_PATH % (cluster_name, host_name , component_name)
+  dic = resource_root.get(path)
+  comp_model = utils.ModelUtils.create_model(ComponentModel, dic, resource_root , "HostRoles" , status.StatusModel)
+  #comp_model._setattr('host_name', dic["items"][0]['HostRoles']['host_name'])
+  return comp_model
+
+
+def _get_service_components(resource_root, cluster_name , service_name):
+  path = paths.SERVICE_COMPONENTS_PATH % (cluster_name, service_name)
+  dic = resource_root.get(path)
+  return utils.ModelUtils.get_model_list(ModelList, ComponentModel, dic, resource_root , "ServiceComponentInfo")
+
+
+def _get_service_component(resource_root, cluster_name , service_name , component_name):
+  path = paths.SERVICE_COMPONENT_PATH % (cluster_name, service_name , component_name)
+  dic = resource_root.get(path)
+  return utils.ModelUtils.create_model(ComponentModel, dic, resource_root , "ServiceComponentInfo")
+
+
+
+
+
+
+
+
+class ComponentModel(BaseModel):
+  """
+  The ComponentModel class
+  """
+  RO_ATTR = ('stack_id',)
+  RW_ATTR = ('host_name', 'component_name', 'service_name', 'state')
+  REF_ATTR = ('cluster_name',)
+  
+  def __init__(self, resource_root, component_name, host_name=None , service_name=None , state=None):
+    utils.retain_self_helper(BaseModel, **locals())
+
+  def __str__(self):
+    return "<<ComponentModel>> component_name = %s; state = %s" % (self.component_name, self.state)
+  
+  def _get_cluster_name(self):
+    if self.clusterRef:
+      return self.clusterRef.cluster_name
+    return None
+
+  def _path(self):
+    """
+    Return the API path for this service.
+    """
+    if self._get_cluster_name():
+      return paths.HOSTS_COMPONENTS_PATH % (self._get_cluster_name(), self.host_name)
+    else:
+      return ''
+
+  def get_metrics(self, detail=None):
+    """
+    Gets the json containing all the metrics data
+    @return: json.
+    """
+    if self.service_name:
+      metricpath = paths.SERVICE_COMPONENT_PATH % (self._get_cluster_name(), self.service_name , self.component_name) + "?fields=metrics"
+    elif self.host_name:
+      metricpath = paths.HOSTS_COMPONENT_PATH % (self._get_cluster_name(), self.host_name , self.component_name) + "?fields=metrics"
+    metricjson = self._get_resource_root().get(metricpath)
+    return metricjson

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/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
new file mode 100755
index 0000000..222ce5c
--- /dev/null
+++ b/ambari-client/src/main/python/ambari_client/model/configuration.py
@@ -0,0 +1,109 @@
+#
+#  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.
+
+
+from ambari_client.model.base_model import  BaseModel 
+from ambari_client.model import paths , status , utils
+
+
+
+
+def _get_configuration(resource_root, cluster_name , type , tag="version1"):
+  """
+  Get configuration of a cluster
+  @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_PATH % (cluster_name, type, tag))
+  config_model = utils.ModelUtils.create_model(ConfigModel , dic["items"][0], resource_root, "NO_KEY")
+  ref_clss = utils.getREF_class_name("cluster_name")
+  config_model._setattr(ref_clss, dic["items"][0]['Config']['cluster_name'])
+  return config_model
+
+
+def _update_configuration(resource_root, cluster_name , type , tag , config_model):
+  """
+  Update configuration of a cluster
+  @param resource_root: The root Resource .
+  @param cluster_name: cluster_name
+  @param type: type of config
+  @param config_model: config model object
+  @return: A ConfigModel object
+  """
+  data = {"Clusters":{"desired_configs":{ "type":type, "tag":tag, "properties":config_model.properties}}}
+  resource_root.post(path=paths.CREATE_CONFIGURATION_PATH % cluster_name , payload=data)
+  return _get_configuration(resource_root, cluster_name , type , tag="version1")
+
+
+def _add_config(root_resource, cluster_name, type, tag , properties):
+  """
+  add configurations 
+  @param type: the type of config
+  @param tag: tag
+  @param properties: a dict of properties
+  @return: A StatusModel object
+  """
+  cpath = paths.CLUSTERS_CONFIG_PATH % cluster_name
+  data = {"Clusters":{"desired_configs":{"type":type, "tag":tag, "properties":properties}}}
+  resp = root_resource.put(path=cpath , payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY") 
+    
+
+def _create_config(root_resource, cluster_name, type, tag , properties):
+  """
+  create a new  configurations 
+  @param type: the type of config
+  @param tag: tag
+  @param properties: a dict of properties
+  @return: A StatusModel object
+  """
+  cpath = paths.CLUSTERS_CONFIG_PATH % cluster_name
+  data = {"type":type, "tag":tag, "properties":properties}
+  resp = root_resource.put(path=cpath , payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY") 
+
+
+
+class ConfigModel(BaseModel):
+  """
+  The ConfigModel class
+  """
+  RO_ATTR = ('properties',)
+  RW_ATTR = ('tag', 'type')
+  REF_ATTR = ('cluster_name',)
+  
+  def __init__(self, resource_root, tag , type=None):
+    utils.retain_self_helper(BaseModel, **locals())
+
+  def __str__(self):
+    return "<<ConfigModel>> tag = %s; type = %s" % (self.tag, self.type)
+  
+  def _get_cluster_name(self):
+    if self.clusterRef:
+      return self.clusterRef.cluster_name
+    return None
+
+  def _path(self):
+    """
+    Return the API path for this service.
+    """
+    if self._get_cluster_name():
+      return paths.CONFIGURATION_PATH % (self._get_cluster_name(), self.type , self.tag)
+    else:
+      return ''

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/model/host.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/host.py b/ambari-client/src/main/python/ambari_client/model/host.py
old mode 100644
new mode 100755
index 3e7fc48..d88ba8d
--- a/ambari-client/src/main/python/ambari_client/model/host.py
+++ b/ambari-client/src/main/python/ambari_client/model/host.py
@@ -21,17 +21,17 @@ except ImportError:
   import simplejson as json
 import logging
 from ambari_client.model.base_model import  BaseModel , ModelList
-from ambari_client.model.paths import HOSTS_PATH , CLUSTER_HOSTS_PATH , CLUSTER_HOST_PATH ,BOOTSTRAP_PATH
-from ambari_client.model import service ,status
-from ambari_client.model.utils import ModelUtils , retain_self_helper
+from ambari_client.model import status , component , paths , utils
+
 
 
 LOG = logging.getLogger(__name__)
 
-def create_host(root_resource, host_name, ip, rack_info=None):
+
+def _create_host(root_resource, host_name, ip, rack_info=None):
   """
   Create a host
-  @param root_resource: The root Resource object.
+  @param root_resource: The root Resource.
   @param host_name: Host name
   @param ip: IP address
   @param rack_info: Rack id. Default None
@@ -40,14 +40,12 @@ def create_host(root_resource, host_name, ip, rack_info=None):
   host = HostModel(root_resource, host_name, ip, rack_info)
   host_list = ModelList([host])
   body = json.dumps(host_list.to_json_dict())
-  resp = root_resource.post(HOSTS_PATH, data=body)
+  resp = root_resource.post(paths.HOSTS_PATH, data=body)
   # The server returns a created hosts 
-  return get_host(root_resource, host_name)
-
-
+  return _get_host(root_resource, host_name)
 
 
-def get_host(root_resource, cluster_name , host_name):
+def _get_host(root_resource, cluster_name , host_name):
   """
   Lookup up by host_name
   @param root_resource: The root Resource object.
@@ -55,70 +53,159 @@ def get_host(root_resource, cluster_name , host_name):
   @param host_name: Host name
   @return: A HostModel object
   """
-  path = CLUSTER_HOST_PATH % (cluster_name, host_name)
+  path = paths.CLUSTER_HOST_PATH % (cluster_name, host_name)
   dic = root_resource.get(path)
-  return ModelUtils.create_model(HostModel , dic, root_resource, "Hosts") 
+  return utils.ModelUtils.create_model(HostModel , dic, root_resource, "Hosts") 
 
 
+def _add_hosts(root_resource, cluster_name , host_list):
+  """
+  Lookup up by host_name
+  @param root_resource: The root Resource object.
+  @param cluster_name: Cluster name
+  @param host_list: list of hostnames
+  @return: A StatusModel object
+  """
+  cpath = paths.HOSTS_CREATE_PATH % (cluster_name)
+  data = [{"Hosts":{"host_name":x}} for x in host_list]
+  resp = root_resource.post(path=cpath, payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _add_host(root_resource, cluster_name , host_name , ip, rack_info):
+  """
+  Creates host.
+  @param host_name: Host name
+  @param ip: ip of Host 
+  @param rack_info: rack information
+  @return: StatusModel.
+  """
+  cpath = paths.HOSTS_CREATE_PATH % (cluster_name)
+  data = [{"Hosts":{"host_name":host_name , "ip":ip, "rack_info":rack_info}}]
+  resp = root_resource.post(path=cpath, payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _assign_role(root_resource, cluster_name , host_name , component_name):
+  """
+  Lookup up by host_name
+  @param root_resource: The root Resource object.
+  @param cluster_name: Cluster name
+  @param component_name : name of component.
+  @param host_name: name of host
+  @return: StatusModel
+  """
+  data = {"host_components":[{"HostRoles":{"component_name":component_name}}]}
+  cpath = paths.HOSTS_ASSIGN_ROLE % (cluster_name, host_name)
+  resp = root_resource.post(path=cpath, payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
 
-def get_all_hosts(root_resource):
+def _get_all_hosts(root_resource):
   """
   Get all hosts
   @param root_resource: The root Resource.
   @return: A list of HostModel objects.
   """
-  dic = root_resource.get(HOSTS_PATH)
-  return ModelUtils.get_model_list(HostModel, dic, root_resource , "Hosts")
+  dic = root_resource.get(paths.HOSTS_PATH)
+  return utils.ModelUtils.get_model_list(ModelList, HostModel, dic, root_resource , "Hosts")
   
   
-  
-def get_all_cluster_hosts(root_resource, cluster_name):
+def _get_all_cluster_hosts(root_resource, cluster_name):
   """
   Get all hosts in the cluster
   @param root_resource: The root Resource.
+  @param cluster_name: The name of the cluster.
   @return: A list of HostModel objects.
   """
-  path = "%s/%s" % (HOSTS_PATH, cluster_name)
+  path = paths.CLUSTER_HOSTS_PATH % (cluster_name)
+  path = path + '?fields=*'
   dic = root_resource.get(path)
-  return ModelUtils.get_model_list(HostModel, dic, root_resource , "Hosts")
-
+  return utils.ModelUtils.get_model_list(ModelList, HostModel, dic, root_resource , "Hosts")
 
 
-def delete_host(root_resource, host_id):
+def _delete_host(root_resource, host_name):
   """
   Delete a host by id
   @param root_resource: The root Resource object.
-  @param host_id: Host id
-  @return: The deleted HostModel object
+  @param host_name: Host name
+  @return: StatusModel object
   """
-  resp = root_resource.delete("%s/%s" % (HOSTS_PATH, host_id))
-  return HostModel.from_json_dict(resp, root_resource)
+  resp = root_resource.delete("%s/%s" % (paths.HOSTS_PATH, host_name))
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
   
-  
-def bootstrap_hosts(root_resource , hosts_list,ssh_key):
+
+def _delete_cluster_host(root_resource, cluster_name , host_name):
+  """
+  Delete a host by id
+  @param root_resource: The root Resource object.
+  @param host_name: Host name
+  @param cluster_name: cluster name
+  @return: StatusModel object
+  """
+  path = paths.CLUSTER_HOST_PATH % (cluster_name, host_name)
+  resp = root_resource.delete(path)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _bootstrap_hosts(root_resource , hosts_list, ssh_key):
   """
   Bootstrap hosts.
   @param hosts_list list of host_names.
   @return: A  StatusModel object.
   """
-  payload_dic = {'sshKey':ssh_key.encode('string_escape') ,'hosts':hosts_list}
-  resp = root_resource.post(BOOTSTRAP_PATH,payload_dic ,content_type="application/json")
-  return ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
-
+  #payload_dic = {'sshKey':ssh_key.encode('string_escape') , 'hosts':hosts_list}
+  payload_dic = {'sshKey':ssh_key , 'hosts':hosts_list}
+  resp = root_resource.post(paths.BOOTSTRAP_PATH, payload_dic , content_type="application/json")
+  LOG.debug(resp)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
 
 
  
+
+
 class HostModel(BaseModel):
+  """
+  The HostModel class
+  """
   RO_ATTR = ('host_state', 'public_host_name')
   RW_ATTR = ('host_name', 'ip', 'rack_info')
   REF_ATTR = ('cluster_name',)
   
   def __init__(self, resource_root, host_name, ip=None , rack_info=None):
-    retain_self_helper(**locals())
+    utils.retain_self_helper(BaseModel, **locals())
 
   def __str__(self):
-    return "<<HostModel>>: = %s; ip = %s" % (self.host_name, self.ip)
+    return "<<HostModel>> hostname = %s; ip = %s ; rack_info = %s" % (self.host_name, self.ip, self.rack_info)
+
+  def _get_cluster_name(self):
+    if self.clusterRef:
+      return self.clusterRef.cluster_name
+    return None
 
   def _path(self):
-    return HOSTS_PATH + '/' + self.host_name
+    return paths.HOSTS_PATH + '/' + self.host_name
+
+  def get_host_components(self, detail=None):
+    """
+    Get a specific host's components.
+    @return: A ModelList containing ComponentModel objects.
+    """
+    return component.get_host_components(self._get_resource_root(), self._get_cluster_name(), self.host_name)
+
+  def get_host_component(self, component_name , detail=None):
+    """
+    Get a specific host's ,specific component.
+    @param component_name : name of component.
+    @return: A ComponentModel object.
+    """
+    return component.get_host_component(self._get_resource_root(), self._get_cluster_name(), self.host_name , component_name)
+
+  def assign_role(self, component_name , detail=None):
+    """
+    Assign a component role to the host
+    @param component_name : name of component.
+    @return: StatusModel.
+    """
+    return _assign_role(self._get_resource_root(), self._get_cluster_name(), self.host_name , component_name)
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755
index cc39a2a..9221fa0
--- a/ambari-client/src/main/python/ambari_client/model/paths.py
+++ b/ambari-client/src/main/python/ambari_client/model/paths.py
@@ -16,9 +16,32 @@
 #  limitations under the License.
 
 CLUSTERS_PATH = "/clusters"
-SERVICES_PATH = "/clusters/%s/services"
-SERVICE_PATH = "/clusters/%s/services/%s"
-HOSTS_PATH = "/hosts"
+CLUSTERS_CONFIG_PATH = "/clusters/%s"
 CLUSTER_HOSTS_PATH = "/clusters/%s/hosts"
 CLUSTER_HOST_PATH = "/clusters/%s/hosts/%s"
-BOOTSTRAP_PATH="/bootstrap"
+CLUSTER_START_ALL_SERVICES = "/clusters/%s/services?ServiceInfo/state=INSTALLED"
+CLUSTER_STOP_ALL_SERVICES = "/clusters/%s/services?ServiceInfo"
+
+
+SERVICES_PATH = "/clusters/%s/services"
+SERVICE_PATH = "/clusters/%s/services/%s"
+SERVICE_CREATE_PATH = "/clusters/%s/services/?ServiceInfo/service_name=%s"
+SERVICE_COMPONENTS_PATH = "/clusters/%s/services/%s/components?fields=*"
+SERVICE_COMPONENT_PATH = "/clusters/%s/services/%s/components/%s"
+
+
+HOSTS_PATH = "/hosts?fields=*"
+HOSTS_CREATE_PATH = "/clusters/%s/hosts"
+HOSTS_COMPONENTS_PATH = "/clusters/%s/hosts/%s/host_components?ServiceComponentInfo"
+HOSTS_COMPONENT_PATH = "/clusters/%s/hosts/%s/host_components/%s" 
+HOSTS_ASSIGN_ROLE = "/clusters/%s/hosts?Hosts/host_name=%s"
+
+BOOTSTRAP_PATH = "/bootstrap"
+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"
+CREATE_CONFIGURATION_PATH = "/clusters/%s/configurations"
+
+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/incubator-ambari/blob/dd5b2aa4/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
old mode 100644
new mode 100755
index 03b6421..c384473
--- a/ambari-client/src/main/python/ambari_client/model/service.py
+++ b/ambari-client/src/main/python/ambari_client/model/service.py
@@ -16,54 +16,124 @@
 
 import logging
 import time
-from ambari_client.model.base_model import  BaseModel 
-from ambari_client.model.paths import SERVICES_PATH ,SERVICE_PATH 
-from ambari_client.model.utils import ModelUtils ,retain_self_helper
+from ambari_client.model.base_model import  BaseModel , ModelList
+from ambari_client.model import component , paths , status , stack , utils
+
 
 LOG = logging.getLogger(__name__)
 
 
-def get_all_services(resource_root, cluster_name="default"):
-  path = SERVICES_PATH % (cluster_name,)
-  path = path +'?fields=*'
+
+def _get_all_services(resource_root, cluster_name):
+  """
+  Get all services in a cluster.
+  @param cluster_name :Cluster name.
+  @return: A  ModelList object.
+  """
+  path = paths.SERVICES_PATH % (cluster_name,)
+  path = path + '?fields=*'
   dic = resource_root.get(path)
-  return ModelUtils.get_model_list(ServiceModel, dic, resource_root ,"ServiceInfo")
+  return utils.ModelUtils.get_model_list(ModelList, ServiceModel, dic, resource_root , "ServiceInfo")
 
 
-def get_service(resource_root, service_name, cluster_name="default"):
-  path = "%s/%s" % (SERVICES_PATH % (cluster_name,), service_name)
+def _get_service(resource_root, service_name, cluster_name):
+  """
+  Get a specific services in a cluster.
+  @param service_name :Service name.
+  @param cluster_name :Cluster name.
+  @return: A  ServiceModel object.
+  """
+  path = "%s/%s" % (paths.SERVICES_PATH % (cluster_name,), service_name)
   dic = resource_root.get(path)
-  return ModelUtils.create_model(ServiceModel ,dic, resource_root,"ServiceInfo") 
+  return utils.ModelUtils.create_model(ServiceModel , dic, resource_root, "ServiceInfo") 
 
-def create_service(root_resource, service_name, cluster_name):
+
+def _create_services(root_resource, cluster_name , service_names):
   """
-  Create a service
+  Create services
   @param root_resource: The root Resource object.
-  @param service_name: Service service_name
+  @param service_names: list of service_names
+  @param cluster_name: Cluster name
+  @return: StatusModel
+  """
+  data = [{"ServiceInfo":{"service_name":x}} for x in service_names]
+  cpath = paths.SERVICES_PATH % cluster_name
+  resp = root_resource.post(path=cpath, payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _create_service(root_resource, cluster_name , service_name):
+  """
+  Create a single service
+  @param root_resource: The root Resource object.
+  @param service_name:  service_name
+  @param cluster_name: Cluster name
+  @return: StatusModel
+  """
+  data = {"ServiceInfo":{"service_name":service_name}} 
+  cpath = paths.SERVICES_PATH % cluster_name
+  resp = root_resource.post(path=cpath, payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _create_service_components(root_resource, cluster_name , version , service_name):
+  """
+  Create service with components
+  @param root_resource: The root Resource object.
+  @param service_name:  service_names
   @param cluster_name: Cluster service_name
   @return: An ServiceModel object
   """
-  data ={"ServiceInfo":{"service_name":str(service_name)}}
-  service = ServiceModel(root_resource, service_name,cluster_name)
-  path = SERVICE_PATH
-  root_resource.post(path=SERVICE_PATH , payload=data)
-  return get_service(root_resource, service_name, cluster_name)
-    
+  components = stack._get_components_from_stack(root_resource, version , service_name)
+  list_componnetinfo = [{"ServiceComponentInfo":{"component_name":x.component_name }} for x in components]
+  data = {"components":list_componnetinfo}
+  cpath = paths.SERVICE_CREATE_PATH % (cluster_name, service_name)
+  resp = root_resource.post(path=cpath, payload=data)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
 
+def _create_service_component(root_resource, cluster_name , version , service_name, component_name):
+  """
+  Create service with single component
+  @param root_resource: The root Resource object.
+  @param service_name:  service_names
+  @param cluster_name: Cluster service_name
+  @param component_name: name of component
+  @return: An ServiceModel object
+  """
+  cpath = paths.SERVICE_COMPONENT_PATH % (cluster_name, service_name, component_name)
+  resp = root_resource.post(path=cpath, payload=None)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+
+
+def _delete_service(root_resource, service_name, cluster_name):
+  """
+  Delete a service by service_name
+  @param root_resource: The root Resource object.
+  @param service_name: Service service_name
+  @param cluster_name: Cluster service_name
+  @return: The StatusModel object
+  """
+  resp = root_resource.delete("%s/%s" % (paths.SERVICES_PATH % (cluster_name,), service_name))
+  time.sleep(3)
+  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+   
    
     
 class ServiceModel(BaseModel):
-  RO_ATTR = ('state',  'cluster_name')
-  RW_ATTR = ('service_name', 'type')
+  """
+  The ServiceModel class
+  """
+  #RO_ATTR = ('state', 'cluster_name')
+  RW_ATTR = ('service_name', 'state')
   REF_ATTR = ('cluster_name',)
 
-  def __init__(self, resource_root, service_name ):
+  def __init__(self, resource_root, service_name , state):
     #BaseModel.__init__(self, **locals())
-    retain_self_helper(**locals())
-
+    utils.retain_self_helper(BaseModel, **locals())
 
   def __str__(self):
-    return "<<ServiceModel>> = %s (cluster_name = %s)" % (self.service_name, self._get_cluster_name())
+    return "<<ServiceModel>> = %s ;state = %s ; cluster_name = %s" % (self.service_name, self.state , self._get_cluster_name())
 
   def _get_cluster_name(self):
     if self.clusterRef:
@@ -72,32 +142,49 @@ class ServiceModel(BaseModel):
 
   def _path(self):
     """
-    Return the API path for this service.
+    Return the API path for this object.
     """
     if self._get_cluster_name():
-      return SERVICE_PATH % (self._get_cluster_name(), self.service_name)
+      return paths.SERVICE_PATH % (self._get_cluster_name(), self.service_name)
     else:
       return ''
 
-
   def _action(self, data=None):
     path = self._path() 
-    self._get_resource_root().put(path, payload=data)
-    return None
-
+    resp = self._get_resource_root().put(path, payload=data)
+    return utils.ModelUtils.create_model(status.StatusModel, resp, self._get_resource_root(), "NO_KEY")
 
   def start(self):
     """
     Start a service.
     """
-    data={"ServiceInfo": {"state": "STARTED"}}
+    data = {"ServiceInfo": {"state": "STARTED"}}
     return self._action(data)
 
   def stop(self):
     """
     Stop a service.
     """
-    data={"ServiceInfo": {"state": "INSTALLED"}}
+    data = {"ServiceInfo": {"state": "INSTALLED"}}
     return self._action(data)
 
+  def install(self):
+    """
+    Install a service.
+    """
+    data = {"ServiceInfo": {"state": "INSTALLED"}}
+    return self._action(data)
 
+  def get_service_components(self, detail=None):
+    """
+    Get a specific services's components.
+    @return: A ComponentModel object.
+    """
+    return component._get_service_components(self._get_resource_root(), self._get_cluster_name(), self.service_name)
+
+  def get_service_component(self, component_name , detail=None):
+    """
+    Get a specific services's components.
+    @return: A ComponentModel object.
+    """
+    return component._get_service_component(self._get_resource_root(), self._get_cluster_name(), self.service_name, component_name)

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/dd5b2aa4/ambari-client/src/main/python/ambari_client/model/stack.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/stack.py b/ambari-client/src/main/python/ambari_client/model/stack.py
new file mode 100755
index 0000000..40088f7
--- /dev/null
+++ b/ambari-client/src/main/python/ambari_client/model/stack.py
@@ -0,0 +1,79 @@
+#
+#  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.
+
+
+from ambari_client.model.base_model import  BaseModel , ModelList
+from ambari_client.model import paths , utils
+
+
+def _get_configuration_from_stack(resource_root, version , service_name , tag="version1"):
+  """
+  Get configuration from stack
+  @param resource_root: The root Resource .
+  @param cluster_name: cluster_name
+  @param type: type of config
+  @return: A ModelList of ConfigModel object
+  """
+  dic = resource_root.get(paths.STACK_SERVICES_CONFIG_PATH % (version, service_name))
+  return utils.ModelUtils.get_model_list(ModelList, StackConfigModel, dic, resource_root , "StackConfigurations")
+
+
+def _get_components_from_stack(resource_root, version , service_name , tag="version1"):
+  """
+  Get configuration from stack
+  @param resource_root: The root Resource .
+  @param cluster_name: cluster_name
+  @param type: type of config
+  @return: A ModelList of ConfigModel object
+  """
+  path = paths.STACK_SERVICES_COMPONENTS_PATH % (version, service_name)
+  dic = resource_root.get(path)
+  return utils.ModelUtils.get_model_list(ModelList, StackComponentModel, dic, resource_root , "StackServiceComponents")
+
+
+class StackConfigModel(BaseModel):
+  """
+  The StackConfigModel class
+  """
+  RO_ATTR = ('stack_name', 'type', 'property_description')
+  RW_ATTR = ('property_name', 'property_value', 'service_name', 'stack_version')
+  REF_ATTR = ()
+  
+  def __init__(self, resource_root, property_name , property_value=None , service_name=None , stack_version=None):
+    utils.retain_self_helper(BaseModel, **locals())
+
+  def __str__(self):
+    return "<<StackConfigModel>> property_name=%s; property_value=%s ;service_name= %s" % (self.property_name, self.property_value, self.service_name)
+  
+
+
+
+
+class StackComponentModel(BaseModel):
+  """
+  The StackComponentModel class
+  """
+  RO_ATTR = ('stack_name', 'is_master', 'is_client', 'component_category')
+  RW_ATTR = ('component_name', 'service_name', 'stack_version')
+  REF_ATTR = ()
+  
+  def __init__(self, resource_root, component_name , service_name=None , stack_version=None):
+    utils.retain_self_helper(BaseModel, **locals())
+
+  def __str__(self):
+    return "<<StackComponentModel>> component_name = %s; service_name = %s" % (self.component_name, self.service_name)
+