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

[1/3] AMBARI-6316 Python client improvements(subin)

Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 47091c2e5 -> 82ce9aeb2


http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/test/python/TestStatusModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/TestStatusModel.py b/ambari-client/python-client/src/test/python/TestStatusModel.py
index 7f88771..cf0e633 100644
--- a/ambari-client/python-client/src/test/python/TestStatusModel.py
+++ b/ambari-client/python-client/src/test/python/TestStatusModel.py
@@ -67,16 +67,18 @@ class TestStatusModel(unittest.TestCase):
 
   def test_get_bootstrap_path(self):
     http_client_mock = MagicMock()
-
+    
     ssh_key = 'abc!@#$%^&*()_:"|<>?[];\'\\./'
     host_list = ['dev05.hortonworks.com','dev06.hortonworks.com']
+    ssh_user='root'
+ 
     expected_path = '//bootstrap'
-    expected_payload = {'hosts': ['dev05.hortonworks.com', 'dev06.hortonworks.com'], 'sshKey': 'abc!@#$%^&*()_:"|<>?[];\\\'\\\\./'}
     expected_headers = {'Content-Type': 'application/json'}
-    expected_bootstrap_path = '/bootstrap/5'
-
+    expected_request = {'user': ssh_user,'hosts': str(host_list),'verbose':True, 'sshKey': ssh_key}
+    expected_response = {'status': 201, 'message': u'Running Bootstrap now.', 'requestId': 5}
+    expected_bootstrap_path = '/bootstrap/5'                           
     client = self.create_client(http_client_mock)
-    resp = client.bootstrap_hosts(host_list, ssh_key)
+    resp = client.bootstrap_hosts(host_list, ssh_key, ssh_user)
 
     self.assertEqual(resp.get_bootstrap_path(),expected_bootstrap_path)
-    http_client_mock.invoke.assert_called_with('POST', expected_path, headers=expected_headers, payload=expected_payload)
+    http_client_mock.invoke.assert_called_with('POST', expected_path, headers=expected_headers, payload={'user': 'root', 'hosts': "['dev05.hortonworks.com', 'dev06.hortonworks.com']", 'verbose': True, 'sshKey': 'abc!@#$%^&*()_:"|<>?[];\\\'\\\\./'})


[2/3] AMBARI-6316 Python client improvements(subin)

Posted by su...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/configuration.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/configuration.py b/ambari-client/python-client/src/main/python/ambari_client/model/configuration.py
old mode 100755
new mode 100644
index 883caf2..730ca33
--- a/ambari-client/python-client/src/main/python/ambari_client/model/configuration.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/configuration.py
@@ -6,9 +6,9 @@
 #  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.
@@ -16,123 +16,164 @@
 #  limitations under the License.
 
 
-from ambari_client.model.base_model import  BaseModel , ModelList
-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))
-  
-  if len(dic["items"]) == 0:
-    return None
-  
-  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 _get_all_configuration(resource_root, cluster_name , type ):
-  """
-  Gets ALL configuration of a cluster of a given type
-  @param resource_root: The root Resource .
-  @param cluster_name: cluster_name
-  @param type: type of config
-  @return: A ConfigModel object
-  """
-  dic = resource_root.get(paths.CONFIGURATION_ALL_PATH % (cluster_name, type))
-  
-  if len(dic["items"]) == 0:
-    return None
-
-  objects = []
-  for cfgm in dic["items"]:
-      config_model = utils.ModelUtils.create_model(ConfigModel , cfgm, resource_root, "NO_KEY")
-      ref_clss = utils.getREF_class_name("cluster_name")
-      config_model._setattr(ref_clss, cfgm['Config']['cluster_name'])
-      objects.append(config_model)
-  return ModelList(objects)
-  
-  
-def _update_configuration(resource_root, cluster_name , type , tag , config_model):
-  """
-  Update configuration of a cluster
-  @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}}}
-  resp = resource_root.put(path=paths.UPDATE_CONFIGURATION_PATH % cluster_name , payload=data )
-  return utils.ModelUtils.create_model(status.StatusModel, resp, resource_root, "NO_KEY")
-
-
-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") 
+from ambari_client.model.base_model import BaseModel, ModelList
+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))
+
+    if len(dic["items"]) == 0:
+        return None
+
+    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 _get_all_configuration(resource_root, cluster_name, type):
+    """
+    Gets ALL configuration of a cluster of a given type
+    @param resource_root: The root Resource .
+    @param cluster_name: cluster_name
+    @param type: type of config
+    @return: A ConfigModel object
+    """
+    dic = resource_root.get(
+        paths.CONFIGURATION_ALL_PATH %
+        (cluster_name, type))
+
+    if len(dic["items"]) == 0:
+        return None
+
+    objects = []
+    for cfgm in dic["items"]:
+        config_model = utils.ModelUtils.create_model(
+            ConfigModel,
+            cfgm,
+            resource_root,
+            "NO_KEY")
+        ref_clss = utils.getREF_class_name("cluster_name")
+        config_model._setattr(ref_clss, cfgm['Config']['cluster_name'])
+        objects.append(config_model)
+    return ModelList(objects)
+
+
+def _update_configuration(
+        resource_root,
+        cluster_name,
+        type,
+        tag,
+        config_model):
+    """
+    Update configuration of a cluster
+    @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}}}
+    resp = resource_root.put(
+        path=paths.UPDATE_CONFIGURATION_PATH %
+        cluster_name,
+        payload=data)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        resource_root,
+        "NO_KEY")
+
+
+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 __lt__(self, other):
-    return self.tag < other.tag
-
-  def _path(self):
+
     """
-    Return the API path for this service.
+    The ConfigModel class
     """
-    if self._get_cluster_name():
-      return paths.CONFIGURATION_PATH % (self._get_cluster_name(), self.type , self.tag)
-    else:
-      return ''
+    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 __lt__(self, other):
+        return self.tag < other.tag
+
+    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/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/host.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/host.py b/ambari-client/python-client/src/main/python/ambari_client/model/host.py
old mode 100755
new mode 100644
index f261deb..05bdf6e
--- a/ambari-client/python-client/src/main/python/ambari_client/model/host.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/host.py
@@ -6,9 +6,9 @@
 #  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.
@@ -16,240 +16,305 @@
 #  limitations under the License.
 
 try:
-  import json
+    import json
 except ImportError:
-  import simplejson as json
+    import simplejson as json
 import logging
-from ambari_client.model.base_model import  BaseModel , ModelList
-from ambari_client.model import status , component , paths , utils
-
+from ambari_client.model.base_model import BaseModel, ModelList
+from ambari_client.model import status, component, paths, utils
 
 
 LOG = logging.getLogger(__name__)
 
 
 def _get_host(root_resource, host_name):
-  """
-  Lookup up by host_name
-  @param root_resource: The root Resource object.
-  @param cluster_name: Cluster name
-  @param host_name: Host name
-  @return: A HostModel object
-  """
-  path = paths.HOST_PATH % (host_name)
-  dic = root_resource.get(path)
-  
-  return utils.ModelUtils.create_model(HostModel , dic, root_resource, "Hosts")
-
-def _get_cluster_host(root_resource, cluster_name , host_name):
-  """
-  Lookup cluster host up by host_name
-  @param root_resource: The root Resource object.
-  @param cluster_name: Cluster name
-  @param host_name: Host name
-  @return: A HostModel object
-  """
-  path = paths.CLUSTER_HOST_PATH % (cluster_name, host_name)
-  dic = root_resource.get(path)
-  return utils.ModelUtils.create_model(HostModel , dic, root_resource, "Hosts")
+    """
+    Lookup up by host_name
+    @param root_resource: The root Resource object.
+    @param cluster_name: Cluster name
+    @param host_name: Host name
+    @return: A HostModel object
+    """
+    path = paths.HOST_PATH % (host_name)
+    dic = root_resource.get(path)
+
+    return utils.ModelUtils.create_model(
+        HostModel,
+        dic,
+        root_resource,
+        "Hosts")
+
 
+def _get_cluster_host(root_resource, cluster_name, host_name):
+    """
+    Lookup cluster host up by host_name
+    @param root_resource: The root Resource object.
+    @param cluster_name: Cluster name
+    @param host_name: Host name
+    @return: A HostModel object
+    """
+    path = paths.CLUSTER_HOST_PATH % (cluster_name, host_name)
+    dic = root_resource.get(path)
+    return utils.ModelUtils.create_model(
+        HostModel,
+        dic,
+        root_resource,
+        "Hosts")
 
 
 def _create_hosts(root_resource, host_list):
-  """
-  Create hosts from list
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @param ip: IP address
-  @param rack_info: Rack id. Default None
-  @return: An HostList object
-  """
-  
-  data = [{"Hosts":{"host_name":x.host_name,"ip":x.ip,"rack_info":x.rack_info}} 
-          for x in host_list]
-  resp = root_resource.post(paths.HOSTS_PATH, payload=data)
-  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+    """
+    Create hosts from list
+    @param root_resource: The root Resource.
+    @param host_name: Host name
+    @param ip: IP address
+    @param rack_info: Rack id. Default None
+    @return: An HostList object
+    """
+
+    data = [{"Hosts": {"host_name": x.host_name,
+                       "ip": x.ip,
+                       "rack_info": x.rack_info}} for x in host_list]
+    resp = root_resource.post(paths.HOSTS_PATH, payload=data)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        root_resource,
+        "NO_KEY")
+
 
 def _create_host(root_resource, host_name, ip, rack_info=None):
-  """
-  Create a host
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @param ip: IP address
-  @param rack_info: Rack id. Default None
-  @return: An HostModel object
-  """
-  host_list = ModelList([HostModel(root_resource, host_name, ip, rack_info)])
-  return _create_hosts(root_resource, host_list)
-
-def _add_hosts(root_resource, cluster_name , host_list):
-  """
-  Adds a hosts to a cluster.
-  @param root_resource: The root Resource object.
-  @param cluster_name: Cluster name
-  @param host_list: list of hosts
-  @return: A StatusModel object
-  """
-  cpath = paths.HOSTS_CREATE_PATH % (cluster_name)
-  data = [{"Hosts":{"host_name":x.host_name,"ip":x.ip,"rack_info":x.rack_info}} 
-          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=None):
-  """
-  Adds a host to a cluster.
-  @param host_name: Host name
-  @param ip: ip of Host 
-  @param rack_info: rack information
-  @return: StatusModel.
-  """
-  host_list = ModelList([HostModel(root_resource, host_name, ip, rack_info)])
-  return _add_hosts(root_resource, cluster_name, host_list)
-
-
-def _assign_role(root_resource, cluster_name , host_name , component_name):
-  """
-  Add a new component to a node
-  @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")
+    """
+    Create a host
+    @param root_resource: The root Resource.
+    @param host_name: Host name
+    @param ip: IP address
+    @param rack_info: Rack id. Default None
+    @return: An HostModel object
+    """
+    host_list = ModelList([HostModel(root_resource, host_name, ip, rack_info)])
+    return _create_hosts(root_resource, host_list)
 
 
-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(paths.HOSTS_PATH)
-  return utils.ModelUtils.get_model_list(ModelList, HostModel, dic, root_resource , "Hosts")
-  
-  
-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 = paths.CLUSTER_HOSTS_PATH % (cluster_name)
-  path = path + '?fields=*'
-  dic = root_resource.get(path)
-  return utils.ModelUtils.get_model_list(ModelList, HostModel, dic, root_resource , "Hosts")
+def _add_hosts(root_resource, cluster_name, host_list):
+    """
+    Adds a hosts to a cluster.
+    @param root_resource: The root Resource object.
+    @param cluster_name: Cluster name
+    @param host_list: list of hosts
+    @return: A StatusModel object
+    """
+    cpath = paths.HOSTS_CREATE_PATH % (cluster_name)
+    data = [{"Hosts": {"host_name": x.host_name,
+                       "ip": x.ip,
+                       "rack_info": x.rack_info}} 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=None):
+    """
+    Adds a host to a cluster.
+    @param host_name: Host name
+    @param ip: ip of Host
+    @param rack_info: rack information
+    @return: StatusModel.
+    """
+    host_list = ModelList([HostModel(root_resource, host_name, ip, rack_info)])
+    return _add_hosts(root_resource, cluster_name, host_list)
 
 
-def _delete_host(root_resource, host_name):
-  """
-  Delete a host by id
-  @param root_resource: The root Resource object.
-  @param host_name: Host name
-  @return: StatusModel object
-  """
-  resp = root_resource.delete(paths.HOST_PATH % (host_name))
-  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_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(paths.BOOTSTRAP_PATH, payload_dic , content_type="application/json")
-  status_dict = _bootstrap_resp_to_status_dict(resp)
-  return utils.ModelUtils.create_model(status.StatusModel, status_dict, root_resource, "NO_KEY")
+def _assign_role(root_resource, cluster_name, host_name, component_name):
+    """
+    Add a new component to a node
+    @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 _bootstrap_resp_to_status_dict(resp):
-  """
-  Bootstrap response has a little odd format
-  that's why we have to convert it to the normal
-  format to handle it properly later.
-  """
-  
-  # if we got other response, like an error 400 happened on higher level
-  if isinstance( resp['status'], int ):
-    return resp
-  
-  new_resp = {}
-  
-  if resp['status'] == "OK":
-    new_resp['status'] = 201
-  else: # ERROR
-    new_resp['status'] = 500
-    
-  new_resp['message'] = resp['log']
-  new_resp['requestId'] = resp['requestId']
-  return new_resp
-
-
- 
 
+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(paths.HOSTS_PATH)
+    return utils.ModelUtils.get_model_list(
+        ModelList,
+        HostModel,
+        dic,
+        root_resource,
+        "Hosts")
 
-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='/default-rack'):
-    utils.retain_self_helper(BaseModel, **locals())
 
-  def __str__(self):
-    return "<<HostModel>> hostname = %s; ip = %s ; rack_info = %s" % (self.host_name, self.ip, self.rack_info)
+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 = paths.CLUSTER_HOSTS_PATH % (cluster_name)
+    path = path + '?fields=*'
+    dic = root_resource.get(path)
+    return utils.ModelUtils.get_model_list(
+        ModelList,
+        HostModel,
+        dic,
+        root_resource,
+        "Hosts")
 
-  def _get_cluster_name(self):
-    if self.clusterRef:
-      return self.clusterRef.cluster_name
-    return None
 
-  def _path(self):
-    return paths.HOSTS_PATH + '/' + self.host_name
+def _delete_host(root_resource, host_name):
+    """
+    Delete a host by id
+    @param root_resource: The root Resource object.
+    @param host_name: Host name
+    @return: StatusModel object
+    """
+    resp = root_resource.delete(paths.HOST_PATH % (host_name))
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        root_resource,
+        "NO_KEY")
 
-  def get_host_components(self, detail=None):
+
+def _delete_cluster_host(root_resource, cluster_name, host_name):
     """
-    Get a specific host's components.
-    @return: A ModelList containing ComponentModel objects.
+    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
     """
-    return component.get_host_components(self._get_resource_root(), self._get_cluster_name(), self.host_name)
+    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 get_host_component(self, component_name , detail=None):
+def _bootstrap_hosts(root_resource, hosts_list, ssh_key, ssh_user):
     """
-    Get a specific host's ,specific component.
-    @param component_name : name of component.
-    @return: A ComponentModel object.
+    Bootstrap hosts.
+    @param hosts_list list of host_names.
+    @return: A  StatusModel object.
     """
-    return component.get_host_component(self._get_resource_root(), self._get_cluster_name(), self.host_name , component_name)
+    payload_dic = {"verbose":True, "sshKey": ssh_key.encode(
+        'string_escape')  , "hosts":str(hosts_list) , "user": ssh_user }
+    resp = root_resource.post(
+        paths.BOOTSTRAP_PATH,
+        payload_dic,
+        content_type="application/json")
+    status_dict = _bootstrap_resp_to_status_dict(resp)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        status_dict,
+        root_resource,
+        "NO_KEY")
 
-  def assign_role(self, component_name , detail=None):
+
+def _bootstrap_resp_to_status_dict(resp):
     """
-    Assign a component role to the host
-    @param component_name : name of component.
-    @return: StatusModel.
+    Bootstrap response has a little odd format
+    that's why we have to convert it to the normal
+    format to handle it properly later.
     """
-    return _assign_role(self._get_resource_root(), self._get_cluster_name(), self.host_name , component_name)
 
+    # if we got other response, like an error 400 happened on higher level
+    if isinstance(resp['status'], int):
+        return resp
+
+    new_resp = {}
+
+    if resp['status'] == "OK":
+        new_resp['status'] = 201
+    else:  # ERROR
+        new_resp['status'] = 500
+
+    new_resp['message'] = resp['log']
+    new_resp['requestId'] = resp['requestId']
+    return new_resp
+
+
+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='/default-rack'):
+        utils.retain_self_helper(BaseModel, **locals())
+
+    def __str__(self):
+        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 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/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/paths.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/paths.py b/ambari-client/python-client/src/main/python/ambari_client/model/paths.py
old mode 100755
new mode 100644
index f34c26d..3643129
--- a/ambari-client/python-client/src/main/python/ambari_client/model/paths.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/paths.py
@@ -6,9 +6,9 @@
 #  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.
@@ -34,7 +34,7 @@ HOST_PATH = "/hosts/%s"
 HOSTS_PATH = "/hosts"
 HOSTS_CREATE_PATH = "/clusters/%s/hosts"
 HOSTS_COMPONENTS_PATH = "/clusters/%s/hosts/%s/host_components?fields=HostRoles/state"
-HOSTS_COMPONENT_PATH = "/clusters/%s/hosts/%s/host_components/%s" 
+HOSTS_COMPONENT_PATH = "/clusters/%s/hosts/%s/host_components/%s"
 HOSTS_ASSIGN_ROLE = "/clusters/%s/hosts?Hosts/host_name=%s"
 
 BOOTSTRAP_PATH = "/bootstrap"
@@ -44,7 +44,16 @@ REQUEST_PATH = "clusters/%s/requests/%s"
 CONFIGURATION_PATH = "/clusters/%s/configurations?type=%s&tag=%s"
 CONFIGURATION_ALL_PATH = "/clusters/%s/configurations?type=%s"
 CREATE_CONFIGURATION_PATH = "/clusters/%s/configurations"
-UPDATE_CONFIGURATION_PATH="/clusters/%s"
+UPDATE_CONFIGURATION_PATH = "/clusters/%s"
+
+STACKS_PATH = "/stacks2"
 
+STACKS_VERSIONS_PATH = "stacks2/HDP/versions"
+STACKS_OS_REPO_PATH = "stacks2/HDP/versions/%s/operatingSystems/%s/repositories/HDP-%s"
 STACK_SERVICES_COMPONENTS_PATH = "/stacks2/HDP/versions/%s/stackServices/%s/serviceComponents?fields=*"
 STACK_SERVICES_CONFIG_PATH = "/stacks2/HDP/versions/%s/stackServices/%s/configurations?fields=*"
+
+TASKS_PATH = "clusters/%s/requests/%s/tasks?fields=*"
+
+BLUEPRINT_ALL_PATH = "blueprints?fields=*"
+BLUEPRINT_PATH = "blueprints/%s"

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/service.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/service.py b/ambari-client/python-client/src/main/python/ambari_client/model/service.py
old mode 100755
new mode 100644
index ed91d7c..acd7528
--- a/ambari-client/python-client/src/main/python/ambari_client/model/service.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/service.py
@@ -5,9 +5,9 @@
 #  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.
@@ -16,188 +16,255 @@
 
 import logging
 import time
-from ambari_client.model.base_model import  BaseModel , ModelList
-from ambari_client.model import component , paths , status , stack , utils
+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):
-  """
-  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 utils.ModelUtils.get_model_list(ModelList, ServiceModel, dic, resource_root , "ServiceInfo")
+    """
+    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 utils.ModelUtils.get_model_list(
+        ModelList,
+        ServiceModel,
+        dic,
+        resource_root,
+        "ServiceInfo")
 
 
 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 utils.ModelUtils.create_model(ServiceModel , dic, resource_root, "ServiceInfo") 
-
-
-def _create_services(root_resource, cluster_name , service_names):
-  """
-  Create services
-  @param root_resource: The root Resource object.
-  @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
-  """
-  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")
+    """
+    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 utils.ModelUtils.create_model(
+        ServiceModel,
+        dic,
+        resource_root,
+        "ServiceInfo")
 
 
-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):
-  """
-  The ServiceModel class
-  """
-  #RO_ATTR = ('state', 'cluster_name')
-  RW_ATTR = ('service_name', 'state')
-  REF_ATTR = ('cluster_name',)
-
-  def __init__(self, resource_root, service_name , state):
-    #BaseModel.__init__(self, **locals())
-    utils.retain_self_helper(BaseModel, **locals())
-
-  def __str__(self):
-    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:
-      return self.clusterRef.cluster_name
-    return None
-
-  def _path(self):
-    """
-    Return the API path for this object.
-    """
-    if self._get_cluster_name():
-      return paths.SERVICE_PATH % (self._get_cluster_name(), self.service_name)
-    else:
-      return ''
-
-  def _action(self, data=None):
-    path = self._path() 
-    resp = self._get_resource_root().put(path, payload=data)
-    status_model = utils.ModelUtils.create_model(status.StatusModel, resp, self._get_resource_root(), "NO_KEY")
-    if status_model._get_id() is not None:
-      status_model.request_path = paths.REQUEST_PATH % (self._get_cluster_name(), status_model._get_id())
-    else:
-      status_model.request_path = None
-    return status_model
-
-  def start(self ,message = None):
-    """
-    Start a service.
-    """
-    data = None
-    if message:
-        data = {"RequestInfo":{"context":message},"Body":{"ServiceInfo":{"state":"STARTED"}}}
-    else:
-        data = {"ServiceInfo": {"state": "STARTED"}}
-    return self._action(data)
-
-  def stop(self ,message = None):
-    """
-    Stop a service.
-    """
-    data = None
-    if message:
-        data = {"RequestInfo":{"context":message},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}
-    else:
-        data = {"ServiceInfo": {"state": "INSTALLED"}}
-    return self._action(data)
+def _create_services(root_resource, cluster_name, service_names):
+    """
+    Create services
+    @param root_resource: The root Resource object.
+    @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 install(self):
+def _create_service(root_resource, cluster_name, service_name):
     """
-    Install a service.
+    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": {"state": "INSTALLED"}}
-    return self._action(data)
+    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 get_service_components(self, detail=None):
+def _create_service_components(
+        root_resource,
+        cluster_name,
+        version,
+        service_name):
     """
-    Get a specific services's components.
-    @return: A ComponentModel object.
+    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
     """
-    return component._get_service_components(self._get_resource_root(), self._get_cluster_name(), self.service_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 get_service_component(self, component_name , detail=None):
+
+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):
     """
-    Get a specific services's components.
-    @return: A ComponentModel object.
+    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
     """
-    return component._get_service_component(self._get_resource_root(), self._get_cluster_name(), self.service_name, component_name)
+    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):
+
+    """
+    The ServiceModel class
+    """
+    #RO_ATTR = ('state', 'cluster_name')
+    RW_ATTR = ('service_name', 'state')
+    REF_ATTR = ('cluster_name',)
+
+    def __init__(self, resource_root, service_name, state):
+        #BaseModel.__init__(self, **locals())
+        utils.retain_self_helper(BaseModel, **locals())
+
+    def __str__(self):
+        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:
+            return self.clusterRef.cluster_name
+        return None
+
+    def _path(self):
+        """
+        Return the API path for this object.
+        """
+        if self._get_cluster_name():
+            return paths.SERVICE_PATH % (
+                self._get_cluster_name(), self.service_name)
+        else:
+            return ''
+
+    def _action(self, data=None):
+        path = self._path()
+        resp = self._get_resource_root().put(path, payload=data)
+        status_model = utils.ModelUtils.create_model(
+            status.StatusModel,
+            resp,
+            self._get_resource_root(),
+            "NO_KEY")
+        if status_model._get_id() is not None:
+            status_model.request_path = paths.REQUEST_PATH % (
+                self._get_cluster_name(), status_model._get_id())
+        else:
+            status_model.request_path = None
+        return status_model
+
+    def start(self, message=None):
+        """
+        Start a service.
+        """
+        data = None
+        if message:
+            data = {
+                "RequestInfo": {
+                    "context": message}, "Body": {
+                    "ServiceInfo": {
+                        "state": "STARTED"}}}
+        else:
+            data = {"ServiceInfo": {"state": "STARTED"}}
+        return self._action(data)
+
+    def stop(self, message=None):
+        """
+        Stop a service.
+        """
+        data = None
+        if message:
+            data = {
+                "RequestInfo": {
+                    "context": message}, "Body": {
+                    "ServiceInfo": {
+                        "state": "INSTALLED"}}}
+        else:
+            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/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/stack.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/stack.py b/ambari-client/python-client/src/main/python/ambari_client/model/stack.py
old mode 100755
new mode 100644
index 40088f7..4d63376
--- a/ambari-client/python-client/src/main/python/ambari_client/model/stack.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/stack.py
@@ -6,9 +6,9 @@
 #  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.
@@ -16,64 +16,172 @@
 #  limitations under the License.
 
 
-from ambari_client.model.base_model import  BaseModel , ModelList
-from ambari_client.model import paths , utils
+from ambari_client.model.base_model import BaseModel, ModelList
+from ambari_client.model import paths, utils, status
+
+
+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")
+
+
+def _get_stacks(resource_root, versions=False):
+    """
+    Get configuration from stack
+    @param resource_root: The root Resource .
+    @param cluster_name: cluster_name
+    @param type: type of config
+    @return: A ModelList of StackModel object
+    """
+    if(versions):
+        path = paths.STACKS_VERSIONS_PATH
+        dic = resource_root.get(path)
+        return utils.ModelUtils.get_model_list(
+            ModelList,
+            StackModel,
+            dic,
+            resource_root,
+            "Versions")
+    else:
+        path = paths.STACKS_PATH
+        dic = resource_root.get(path)
+        return utils.ModelUtils.get_model_list(
+            ModelList,
+            StackModel,
+            dic,
+            resource_root,
+            "Stacks")
 
 
-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_stack(resource_root, versions):
+    """
+    Get configuration from stack
+    @param resource_root: The root Resource .
+    @param cluster_name: cluster_name
+    @param type: type of config
+    @return: A ModelList of StackModel object
+    """
+    pass
 
 
-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")
+def _put_stacks_and_repo(resource_root, version, os_type, repo):
+    """
+    Get configuration from stack
+    @param resource_root: The root Resource .
+    @param cluster_name: cluster_name
+    @param type: type of config
+    @return: A ModelList of StackModel object
+    """
+    path = (paths.STACKS_OS_REPO_PATH) % (version, os_type, version)
+    data = '{"Repositories":{"base_url":' + repo + ',"verify_base_url":true}}'
+    dictt = resource_root.put(path, payload=data)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        dictt,
+        resource_root,
+        "NO_KEY")
+
+
+class StackModel(BaseModel):
+
+    """
+    The StackModel class
+    """
+    RO_ATTR = ('stack_version')
+    RW_ATTR = ('stack_name')
+    REF_ATTR = ()
+
+    def __init__(self, resource_root, stack_name):
+        utils.retain_self_helper(BaseModel, **locals())
+
+    def __str__(self):
+        return "<<StackConfigModel>> stack_name= %s" % (self.stack_name)
 
 
 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)
-  
+    """
+    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; service_name= %s" % (
+            self.property_name, 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)
-  
+
+    """
+    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)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/status.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/status.py b/ambari-client/python-client/src/main/python/ambari_client/model/status.py
old mode 100755
new mode 100644
index f88a534..37ca8fd
--- a/ambari-client/python-client/src/main/python/ambari_client/model/status.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/status.py
@@ -5,9 +5,9 @@
 #  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.
@@ -15,57 +15,60 @@
 #  limitations under the License.
 
 import logging
-from ambari_client.model.base_model import  BaseModel 
-from ambari_client.model import paths , utils
+from ambari_client.model.base_model import BaseModel
+from ambari_client.model import paths, utils
 
 
 LOG = logging.getLogger(__name__)
 
 
 class StatusModel(BaseModel):
-  """
-  The ServiceModel class
-  """
-  RO_ATTR = ('id',)
-  RW_ATTR = ('status', 'requestId', "message")
-  REF_ATTR = ('cluster_name',)
 
-  def __init__(self, resource_root, status , requestId=None, message=None):
-    #BaseModel.__init__(self, **locals())
-    utils.retain_self_helper(BaseModel, **locals())
+    """
+    The ServiceModel class
+    """
+    RO_ATTR = ('id',)
+    RW_ATTR = ('status', 'requestId', "message")
+    REF_ATTR = ('cluster_name',)
 
-  def __str__(self):
-    return "<<StatusModel>> status = %s ; requestId = %s ;message = %s" % (self._get_status(), self._get_id() , self.get_message())
+    def __init__(self, resource_root, status, requestId=None, message=None):
+        #BaseModel.__init__(self, **locals())
+        utils.retain_self_helper(BaseModel, **locals())
 
-  def get_bootstrap_path(self):
-    return paths.BOOTSTRAP_PATH + '/' + str(self.requestId)
+    def __str__(self):
+        return "<<StatusModel>> status = %s ; requestId = %s ;message = %s" % (
+            self._get_status(), self._get_id(), self.get_message())
 
-  def get_request_path(self):
-    return self.request_path
+    def get_bootstrap_path(self):
+        return paths.BOOTSTRAP_PATH + '/' + str(self.requestId)
 
-  def get_message(self):
-    if hasattr(self, 'message'):
-        return self.message
-    else:
-        None
+    def get_request_path(self):
+        return self.request_path
 
-  def is_error(self):
-    return (self.status != 200 and self.status != 201 and self.status != 202)  
-        
-  def _get_id(self):
-    if hasattr(self, 'requestId') and self.requestId:
-        return self.requestId
-    elif hasattr(self, 'id') and self.id:
-        return self.id
-    else:
-        None
+    def get_message(self):
+        if hasattr(self, 'message'):
+            return self.message
+        else:
+            None
 
-  def _get_status(self):
-    if hasattr(self, 'status') and isinstance(self.status, basestring):
-        self.message = self.status
-        self.status = 200
-        return self.status
-    elif hasattr(self, 'status') and isinstance(self.status, int):
-        return self.status
-    else:
-        None
\ No newline at end of file
+    def is_error(self):
+        return (
+            self.status != 200 and self.status != 201 and self.status != 202)
+
+    def _get_id(self):
+        if hasattr(self, 'requestId') and self.requestId:
+            return self.requestId
+        elif hasattr(self, 'id') and self.id:
+            return self.id
+        else:
+            None
+
+    def _get_status(self):
+        if hasattr(self, 'status') and isinstance(self.status, basestring):
+            self.message = self.status
+            self.status = 200
+            return self.status
+        elif hasattr(self, 'status') and isinstance(self.status, int):
+            return self.status
+        else:
+            None

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/utils.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/utils.py b/ambari-client/python-client/src/main/python/ambari_client/model/utils.py
old mode 100755
new mode 100644
index 0b3b6a0..e1f1479
--- a/ambari-client/python-client/src/main/python/ambari_client/model/utils.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/utils.py
@@ -6,9 +6,9 @@
 #  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.
@@ -23,209 +23,281 @@ from ambari_client.core import errors
 LOG = logging.getLogger(__name__)
 
 
-ref_dic = {"cluster_name":"clusterRef"}
-ref_class_dic = {"ClusterModelRef":"cluster_name"}
-ref_pkg_dic = {"ClusterModelRef":"ambari_client.model.cluster"}
+ref_dic = {"cluster_name": "clusterRef"}
+ref_class_dic = {"ClusterModelRef": "cluster_name"}
+ref_pkg_dic = {"ClusterModelRef": "ambari_client.model.cluster"}
 LIST_KEY = "items"
-ALL="ALL" 
-  
+ALL = "ALL"
+
+
 class ModelUtils(object):
-  
-  @staticmethod
-  def _check_is_error(expected_class, model_dict, resource_root):
-    from ambari_client.model.status import StatusModel
-
-    if model_dict.has_key("status"):
-      resp = ModelUtils.create_model(StatusModel, model_dict.copy(), resource_root, "NO_KEY", check_errors=False)
-      
-      if expected_class!=StatusModel or resp.is_error():
-        if resp.status in errors._exceptions_to_codes:
-          raise errors._exceptions_to_codes[resp.status](resp, resource_root)
+
+    @staticmethod
+    def _check_is_error(expected_class, model_dict, resource_root):
+        from ambari_client.model.status import StatusModel
+        from ambari_client.model.cluster import TaskModel
+
+        if expected_class == TaskModel:
+            resp = ModelUtils.create_model(
+                TaskModel,
+                model_dict.copy(),
+                resource_root,
+                "NO_KEY",
+                check_errors=False)
+            return
+
+        if "status" in model_dict:
+            resp = ModelUtils.create_model(
+                StatusModel,
+                model_dict.copy(),
+                resource_root,
+                "NO_KEY",
+                check_errors=False)
+
+            if expected_class != StatusModel or resp.is_error():
+                if resp.status in errors._exceptions_to_codes:
+                    raise errors._exceptions_to_codes[
+                        resp.status](
+                        resp,
+                        resource_root)
+                else:
+                    raise errors.UnknownServerError(resp, resource_root)
+
+    @staticmethod
+    def get_model_list(
+            member_list_clss,
+            member_cls,
+            collection_dict,
+            resource_root,
+            RESOURCE_KEY_WORD,
+            check_errors=True):
+        """
+        create a model.
+        @param member_list_clss : model_list class.
+        @param model_cls : model class.
+        @param collection_dict : collection dict used for creating the list of objects.
+        @param resource_root : resource object.
+        @param RESOURCE_KEY_WORD : tsake subset of model_dict based on this key.
+        @return: A  ModelList object.
+        """
+        tLIST_KEY = LIST_KEY
+
+        if check_errors:
+            ModelUtils._check_is_error(
+                member_list_clss,
+                collection_dict,
+                resource_root)
+
+        # print locals()
+        json_list = []
+
+        # remove items
+        if isinstance(collection_dict, dict) and tLIST_KEY in collection_dict:
+            json_list = collection_dict[tLIST_KEY]
+            LOG.debug(
+                "get_model_list: collection_dict is dict ? %s ; has_key = %s" %
+                (isinstance(
+                    collection_dict,
+                    dict),
+                    LIST_KEY in collection_dict))
+            LOG.debug(
+                "get_model_list: collection_dict has %s ;subset = %s" %
+                (tLIST_KEY, str(json_list)))
         else:
-          raise errors.UnknownServerError(resp, resource_root)
+            json_list = collection_dict
+            LOG.error(
+                "get_model_list: collection_dict is dict ? %s ; has_key = %s" %
+                (isinstance(
+                    collection_dict,
+                    dict),
+                    LIST_KEY in collection_dict))
 
-  @staticmethod
-  def get_model_list(member_list_clss, member_cls, collection_dict, resource_root , RESOURCE_KEY_WORD, check_errors=True):
-    """
-    create a model.
-    @param member_list_clss : model_list class.
-    @param model_cls : model class.
-    @param collection_dict : collection dict used for creating the list of objects.
-    @param resource_root : resource object.
-    @param RESOURCE_KEY_WORD : tsake subset of model_dict based on this key.
-    @return: A  ModelList object.
-    """
-    if check_errors:
-      ModelUtils._check_is_error(member_list_clss, collection_dict, resource_root)
-    
-    #print locals()
-    json_list = []
-    
-    #remove items
-    if isinstance(collection_dict, dict) and collection_dict.has_key(LIST_KEY):
-        json_list = collection_dict[LIST_KEY]
-        LOG.debug("get_model_list: collection_dict is dict ? %s ; has_key = %s" % (isinstance(collection_dict, dict), collection_dict.has_key(LIST_KEY)))
-        LOG.debug ("get_model_list: collection_dict has %s ;subset = %s" % (LIST_KEY, str(json_list)))
-    else:
-        json_list = collection_dict
-        LOG.error("get_model_list: collection_dict is dict ? %s ; has_key = %s" % (isinstance(collection_dict, dict), collection_dict.has_key(LIST_KEY)))
-    
-    LOG.debug ("get_model_list: json_list  value : \n\t" + str(json_list))
-    if isinstance(json_list, list):
-        json_list_new = [ x.get(RESOURCE_KEY_WORD) for x in json_list]
-        LOG.debug("get_model_list: json_list is list ? %s ; " % (isinstance(json_list, list)))
-    else: 
-        json_list_new = [json_list]
-        LOG.error("get_model_list: json_list is list ? %s ; " % (isinstance(json_list, list)))
-    
-    LOG.debug ("get_model_list: json_list_new used for creating ModelList  \n\t" + str(json_list_new))
-    objects = [ ModelUtils.create_model(member_cls, x, resource_root , RESOURCE_KEY_WORD) for x in json_list_new ]
-    LOG.debug (objects)
-    return member_list_clss(objects)
-
-
-  @staticmethod
-  def create_model(model_cls, model_dict, resource_root, RESOURCE_KEY_WORD, check_errors=True):
-    """
-    create a model.
-    @param model_cls : model class.
-    @param model_dict : model dict used for creating the object.
-    @param resource_root : resource object.
-    @param RESOURCE_KEY_WORD : tsake subset of model_dict based on this key.
-    @return: A model_cls object.
-    """
-    if check_errors:
-      ModelUtils._check_is_error(model_cls, model_dict, resource_root)
-      
-    #print locals()
-    rw_dict = { }
-    LOG.debug ("model_dict =   " + str(model_dict))
-    
-    if isinstance(model_dict, dict) and model_dict.has_key(RESOURCE_KEY_WORD):
-        model_dict = model_dict[RESOURCE_KEY_WORD]
-        LOG.debug ("model_dict has %s ;subset = %s" % (RESOURCE_KEY_WORD, str(model_dict.items())))
-    if isinstance(model_dict, dict) and model_dict.has_key("Requests"):
-        model_dict = model_dict["Requests"]
-        LOG.debug ("model_dict has Requests ;subset = %s" % (str(model_dict.items())))
-     
-      
-    for k, v in model_dict.items():
-      LOG.debug("key = %s ; value = %s " % (str(k), str(v)))
-      if k in model_cls.RW_ATTR:
-        LOG.debug (k + " is there in RW_ATTR")
-        rw_dict[k] = v
-        del model_dict[k]
-
-    rw_dict = get_unicode_kw(rw_dict)
-    obj = model_cls(resource_root, **rw_dict)
-
-    for attr in model_cls.RO_ATTR:
-      obj._setattr(attr, None)
-
-    for k, v in model_dict.items():
-      if k in model_cls.RO_ATTR:
-        obj._setattr(k, v)
-      else:
-        LOG.debug("Unexpected attribute '%s' in %s json" % (k, model_cls.__name__))
-
-    for attr in model_cls.REF_ATTR:
-      LOG.debug("%s found as reference var" % (attr))
-      obj._setattr(getREF_class_name(attr), None)
-
-    for k, v in model_dict.items():
-      if k in model_cls.REF_ATTR:
-        obj._setattr(getREF_class_name(k), v)
-      else:
-        LOG.debug("Unknown attribute '%s' found in model_dict for %s " % (k, model_cls.__name__))
-    return obj
-
-
-#get attribute with REF
+        LOG.debug("get_model_list: json_list  value : \n\t" + str(json_list))
+        if isinstance(json_list, list):
+            json_list_new = [x.get(RESOURCE_KEY_WORD) for x in json_list]
+            LOG.debug(
+                "get_model_list: json_list is list ? %s ; " %
+                (isinstance(
+                    json_list,
+                    list)))
+        else:
+            json_list_new = [json_list]
+            LOG.error(
+                "get_model_list: json_list is list ? %s ; " %
+                (isinstance(
+                    json_list,
+                    list)))
+
+        LOG.debug(
+            "get_model_list: json_list_new used for creating ModelList  \n\t" +
+            str(json_list_new))
+        objects = [
+            ModelUtils.create_model(
+                member_cls,
+                x,
+                resource_root,
+                RESOURCE_KEY_WORD) for x in json_list_new]
+        LOG.debug(objects)
+        return member_list_clss(objects)
+
+    @staticmethod
+    def create_model(
+            model_cls,
+            model_dict,
+            resource_root,
+            RESOURCE_KEY_WORD,
+            check_errors=True):
+        """
+        create a model.
+        @param model_cls : model class.
+        @param model_dict : model dict used for creating the object.
+        @param resource_root : resource object.
+        @param RESOURCE_KEY_WORD : tsake subset of model_dict based on this key.
+        @return: A model_cls object.
+        """
+        if check_errors:
+            ModelUtils._check_is_error(model_cls, model_dict, resource_root)
+
+        # print locals()
+        rw_dict = {}
+        LOG.debug("model_dict =   " + str(model_dict))
+
+        if isinstance(model_dict, dict) and RESOURCE_KEY_WORD in model_dict:
+            model_dict = model_dict[RESOURCE_KEY_WORD]
+            LOG.debug(
+                "model_dict has %s ;subset = %s" %
+                (RESOURCE_KEY_WORD, str(
+                    model_dict.items())))
+        if isinstance(model_dict, dict) and "Requests" in model_dict:
+            model_dict = model_dict["Requests"]
+            LOG.debug(
+                "model_dict has Requests ;subset = %s" %
+                (str(
+                    model_dict.items())))
+
+        for k, v in model_dict.items():
+            LOG.debug("key = %s ; value = %s " % (str(k), str(v)))
+            if k in model_cls.RW_ATTR:
+                LOG.debug(k + " is there in RW_ATTR")
+                rw_dict[k] = v
+                del model_dict[k]
+
+        rw_dict = get_unicode_kw(rw_dict)
+        obj = model_cls(resource_root, **rw_dict)
+
+        for attr in model_cls.RO_ATTR:
+            obj._setattr(attr, None)
+
+        for k, v in model_dict.items():
+            if k in model_cls.RO_ATTR:
+                obj._setattr(k, v)
+            else:
+                LOG.debug(
+                    "Unexpected attribute '%s' in %s json" %
+                    (k, model_cls.__name__))
+
+        for attr in model_cls.REF_ATTR:
+            LOG.debug("%s found as reference var" % (attr))
+            obj._setattr(getREF_class_name(attr), None)
+
+        for k, v in model_dict.items():
+            if k in model_cls.REF_ATTR:
+                obj._setattr(getREF_class_name(k), v)
+            else:
+                LOG.debug(
+                    "Unknown attribute '%s' found in model_dict for %s " %
+                    (k, model_cls.__name__))
+        return obj
+
+
+# get attribute with REF
 def getREF_class_name(REF_name):
-  if ref_dic.has_key(REF_name):
-    return ref_dic[str(REF_name)]
-  else:
-    return None
-  
+    if REF_name in ref_dic:
+        return ref_dic[str(REF_name)]
+    else:
+        return None
+
 
 def getREF_var_name(REF_name):
-  if ref_class_dic.has_key(REF_name):
-    return ref_class_dic[str(REF_name)]
-  else:
-    return None
+    if REF_name in ref_class_dic:
+        return ref_class_dic[str(REF_name)]
+    else:
+        return None
 
 
 def get_REF_object(ref_class_name):
-  """
-  Gets the Ref object based on class_name
-  """
-  class_ref = getattr(sys.modules[ref_pkg_dic[ref_class_name]], ref_class_name)
-  LOG.debug(class_ref)
-  return class_ref  
+    """
+    Gets the Ref object based on class_name
+    """
+    class_ref = getattr(
+        sys.modules[
+            ref_pkg_dic[ref_class_name]],
+        ref_class_name)
+    LOG.debug(class_ref)
+    return class_ref
 
 
 def get_unicode(v):
-  #import unicodedata
-  if v:
-    if isinstance(v, unicode):
-      v = unicodedata.normalize('NFKD', v).encode('ascii', 'ignore')
-      LOG.debug(v)
-    elif isinstance(v, str):
-      LOG.debug("warning: string found while expecting unicode %s" % v)
-  return v
+    #import unicodedata
+    if v:
+        if isinstance(v, unicode):
+            v = unicodedata.normalize('NFKD', v).encode('ascii', 'ignore')
+            LOG.debug(v)
+        elif isinstance(v, str):
+            LOG.debug("warning: string found while expecting unicode %s" % v)
+    return v
 
 
 def retain_self_helper(memclass, self=None, **kwargs):
-    #print locals()
-    #from ambari_client.model.base_model import  BaseModel 
+        # print locals()
+        #from ambari_client.model.base_model import  BaseModel
     memclass.__init__(self, **kwargs)
 
 
 def get_unicode_kw(dic):
-  """
-  We use unicode strings as keys in kwargs.
-  """
-  res = { }
-  for k, v in dic.iteritems():
-    res[str(k)] = v
-  return res
+    """
+    We use unicode strings as keys in kwargs.
+    """
+    res = {}
+    for k, v in dic.iteritems():
+        res[str(k)] = v
+    return res
 
 
 def get_config_type(service_name):
-  """
-  get the config type based on service_name
-  """
-  if service_name == "HDFS":
-      type = "hdfs-site"
-  elif service_name == "HDFS":
-      type = "core-site"
-  elif service_name == "MAPREDUCE":
-      type = "mapred-site"
-  elif service_name == "HBASE":
-      type = "hbase-site"
-  elif service_name == "OOZIE":
-      type = "oozie-site"
-  elif service_name == "HIVE":
-      type = "hive-site"
-  elif service_name == "WEBHCAT":
-      type = "webhcat-site"
-  else:
-      type = "global"
-  return type
-      
-      
-def get_key_value(dictt , key):
-  """
-  Search for some random key in the dict
-  """
-  if isinstance(dictt, dict) and dictt.has_key(key):
-    return dictt[key]
-  elif isinstance(dictt, dict) and not dictt.has_key(key):
-    #check if values has it?
-    for v in dictt.values():
-      if isinstance(v, dict):
-        return get_key_value(v, key)
-      elif isinstance(v, list):
-        for l in list:
-          return get_key_value(l, key)
+    """
+    get the config tmp_type based on service_name
+    """
+    if service_name == "HDFS":
+        tmp_type = "hdfs-site"
+    elif service_name == "HDFS":
+        tmp_type = "core-site"
+    elif service_name == "MAPREDUCE":
+        tmp_type = "mapred-site"
+    elif service_name == "HBASE":
+        tmp_type = "hbase-site"
+    elif service_name == "OOZIE":
+        tmp_type = "oozie-site"
+    elif service_name == "HIVE":
+        tmp_type = "hive-site"
+    elif service_name == "WEBHCAT":
+        tmp_type = "webhcat-site"
+    else:
+        tmp_type = "global"
+    return tmp_type
+
 
+def get_key_value(dictt, key):
+    """
+    Search for some random key in the dict
+    """
+    if isinstance(dictt, dict) and key in dictt:
+        return dictt[key]
+    elif isinstance(dictt, dict) and key not in dictt:
+        # check if values has it?
+        for v in dictt.values():
+            if isinstance(v, dict):
+                return get_key_value(v, key)
+            elif isinstance(v, list):
+                for l in list:
+                    return get_key_value(l, key)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/views.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/views.py b/ambari-client/python-client/src/main/python/ambari_client/model/views.py
new file mode 100644
index 0000000..561cdbd
--- /dev/null
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/views.py
@@ -0,0 +1,33 @@
+#  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__)
+
+# TODO
+
+
+def get_views(resource_root, blueprint_name):
+    pass
+
+
+# TODO
+class ViewModel(BaseModel):
+    pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/resources/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/resources/__init__.py b/ambari-client/python-client/src/main/python/ambari_client/resources/__init__.py
deleted file mode 100755
index 278df2e..0000000
--- a/ambari-client/python-client/src/main/python/ambari_client/resources/__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/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/resources/clusters.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/resources/clusters.py b/ambari-client/python-client/src/main/python/ambari_client/resources/clusters.py
deleted file mode 100755
index ca3cca6..0000000
--- a/ambari-client/python-client/src/main/python/ambari_client/resources/clusters.py
+++ /dev/null
@@ -1,58 +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.
-
-from ambari_client.model import  cluster
-__docformat__ = "epytext"
-
-
-def _get_cluster(resource_root, cluster_name):
-  """
-  Get a cluster by cluster_name
-  @param resource_root: The root Resource.
-  @param cluster_name: Cluster's name
-  @return: ClusterModel object
-  """
-  return cluster._get_cluster(resource_root, cluster_name)
-
-
-def _get_all_clusters(root_resource):
-  """
-  Get all clusters in Ambari.
-  @param root_resource: The root Resource object.
-  @return: A list of ClusterModel objects in ModelList.
-  """
-  return cluster._get_all_clusters(root_resource)
-
- 
-def _create_cluster(root_resource, cluster_name, version):
-  """
-  Create a cluster
-  @param root_resource: The root Resource.
-  @param cluster_name: Cluster cluster_name
-  @param version: HDP version
-  @return: An ClusterModel object
-  """
-  return cluster._create_cluster(root_resource, cluster_name, version)
-  
-  
-def _delete_cluster(root_resource, cluster_name):
-  """
-  Create a cluster
-  @param root_resource: The root Resource.
-  @param cluster_name: Cluster cluster_name
-  """
-  return cluster._delete_cluster(root_resource, cluster_name)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/resources/hosts.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/resources/hosts.py b/ambari-client/python-client/src/main/python/ambari_client/resources/hosts.py
deleted file mode 100755
index 0d53711..0000000
--- a/ambari-client/python-client/src/main/python/ambari_client/resources/hosts.py
+++ /dev/null
@@ -1,127 +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.
-
-from ambari_client.model import  host
-__docformat__ = "epytext"
-
-def _add_hosts(root_resource, cluster_name , host_list):
-  """
-  Adds a hosts to a cluster.
-  @param root_resource: The root Resource object.
-  @param cluster_name: Cluster name
-  @param host_list: list of hosts
-  @return: A StatusModel object
-  """
-  return _add_hosts(root_resource, cluster_name , host_list)
-
-def _add_host(root_resource, cluster_name , host_name , ip, rack_info=None):
-  """
-  Adds a host to a cluster.
-  @param host_name: Host name
-  @param ip: ip of Host 
-  @param rack_info: rack information
-  @return: StatusModel.
-  """
-  return _add_host(root_resource, cluster_name , host_name , ip, rack_info)
-
-
-def _create_hosts(root_resource, host_list):
-  """
-  Create a host
-  @param root_resource: The root Resource.
-  @param host_list: ModelList list of hosts
-  @return: A HostModel object
-  """
-  return host._create_hosts(root_resource, host_list)
-
-def _create_host(root_resource, host_name, ip, rack_info=None):
-  """
-  Create a host
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @param ip: IP address
-  @param rack_info: Rack id. Default None
-  @return: A HostModel object
-  """
-  return host._create_host(root_resource, host_name, ip, rack_info)
-
-
-def _get_host(root_resource, host_name):
-  """
-  Lookup a host by name
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @return: A HostModel object
-  """
-  return host._get_host(root_resource, host_name)
-
-def _get_cluster_host(root_resource, cluster_name, host_name):
-  """
-  Lookup a host by name
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @return: A HostModel object
-  """
-  return host._get_cluster_host(root_resource, cluster_name, host_name)
-
-
-
-
-def _get_all_hosts(root_resource):
-  """
-  Get all hosts
-  @param root_resource: The root Resource.
-  @return: A list of HostModel objects.
-  """
-  return host._get_all_hosts(root_resource)
-
-def _get_all_cluster_hosts(root_resource, cluster_name):
-  """
-  Get all cluster hosts
-  @param root_resource: The root Resource.
-  @return: A list of HostModel objects.
-  """
-  return host._get_all_cluster_hosts(root_resource, cluster_name)
-
-
-def _delete_host(root_resource, host_name):
-  """
-  Delete a host by id
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @return: The deleted HostModel object
-  """
-  return host._delete_host(root_resource, host_name)
-
-def _delete_cluster_host(root_resource, cluster_name , host_name):
-  """
-  Delete a cluster host by id
-  @param root_resource: The root Resource.
-  @param host_name: Host name
-  @return: The deleted HostModel object
-  """
-  return host._delete_cluster_host(root_resource, cluster_name , host_name)
-
-
-def _bootstrap_hosts(root_resource , hosts_list , ssh_key):
-  """
-  Bootstrap hosts.
-  @param hosts_list: list of host_names.
-  @param ssh_key: ssh key for password-less access.
-  @return: A  StatusModel object.
-  """
-  return host._bootstrap_hosts(root_resource, hosts_list , ssh_key)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/resources/stacks.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/resources/stacks.py b/ambari-client/python-client/src/main/python/ambari_client/resources/stacks.py
deleted file mode 100755
index f4ef518..0000000
--- a/ambari-client/python-client/src/main/python/ambari_client/resources/stacks.py
+++ /dev/null
@@ -1,41 +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.
-
-from ambari_client.model import   stack , component
-
-__docformat__ = "epytext"
-
-
-def _get_config(root_resource, version, service_name):
-  """
-  Get service configurations from stack
-  @param version: The HDP version.
-  @param service_name: service name
-  @return: A ConfigModel object
-  """
-  return stack._get_configuration_from_stack(root_resource, version, service_name)
-
-
-def _get_components(root_resource, version, service_name):
-  """
-  Get service components from stack
-  @param version: The HDP version.
-  @param service_name: service name
-  @return: A ComponentModel object
-  """
-  return stack._get_components_from_stack(root_resource, version, service_name)
-

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/test/python/TestAmbariClient.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/test/python/TestAmbariClient.py b/ambari-client/python-client/src/test/python/TestAmbariClient.py
index 1831f89..3d78646 100755
--- a/ambari-client/python-client/src/test/python/TestAmbariClient.py
+++ b/ambari-client/python-client/src/test/python/TestAmbariClient.py
@@ -124,17 +124,18 @@ class TestAmbariClient(unittest.TestCase):
     
     ssh_key = 'abc!@#$%^&*()_:"|<>?[];\'\\./'
     host_list = ['dev05.hortonworks.com','dev06.hortonworks.com']
-    
+    ssh_user='root'
+ 
     expected_path = '//bootstrap'
     expected_headers = {'Content-Type': 'application/json'}
-    expected_request = {'hosts': host_list, 'sshKey': 'abc!@#$%^&*()_:"|<>?[];\\\'\\\\./'}
+    expected_request = {'user': ssh_user,'hosts': str(host_list),'verbose':True, 'sshKey': ssh_key}
     expected_response = {'status': 201, 'message': u'Running Bootstrap now.', 'requestId': 5}
                                
     client = self.create_client(http_client_mock)
-    resp = client.bootstrap_hosts(host_list, ssh_key)
+    resp = client.bootstrap_hosts(host_list, ssh_key, ssh_user)
 
     self.assertEqual(resp.to_json_dict(), expected_response)
-    http_client_mock.invoke.assert_called_with('POST', expected_path, headers=expected_headers, payload=expected_request)
+    http_client_mock.invoke.assert_called_with('POST', expected_path, headers=expected_headers, payload={'user': 'root', 'hosts': "['dev05.hortonworks.com', 'dev06.hortonworks.com']", 'verbose': True, 'sshKey': 'abc!@#$%^&*()_:"|<>?[];\\\'\\\\./'})
   
   def test_create_cluster(self):
     """
@@ -208,4 +209,4 @@ class TestAmbariClient(unittest.TestCase):
     self.assertEquals(len(components), 4)
     self.assertEquals(str(components[0]),str(expected_first_item))
     self.assertEquals(components.to_json_dict(), expected_dict)
-  
\ No newline at end of file
+  


[3/3] git commit: AMBARI-6316 Python client improvements(subin)

Posted by su...@apache.org.
AMBARI-6316 Python client improvements(subin)


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

Branch: refs/heads/branch-1.6.1
Commit: 82ce9aeb204e237ab851ef9c62d903f0650479b6
Parents: 47091c2
Author: Subin <su...@apache.org>
Authored: Mon Jun 30 19:40:40 2014 +0530
Committer: Subin <su...@apache.org>
Committed: Mon Jun 30 19:40:40 2014 +0530

----------------------------------------------------------------------
 ambari-client/python-client/pom.xml             |   2 +-
 .../src/main/python/ambari_client/ambari_api.py | 378 ++++++----
 .../main/python/ambari_client/core/__init__.py  |   0
 .../main/python/ambari_client/core/coreutils.py |   4 +-
 .../main/python/ambari_client/core/errors.py    | 129 ++--
 .../python/ambari_client/core/http_client.py    | 278 ++++----
 .../python/ambari_client/core/http_utils.py     |   8 +-
 .../python/ambari_client/core/rest_resource.py  | 200 +++---
 .../main/python/ambari_client/model/__init__.py |   0
 .../python/ambari_client/model/base_model.py    | 144 ++--
 .../python/ambari_client/model/blueprint.py     | 125 ++++
 .../main/python/ambari_client/model/cluster.py  | 706 ++++++++++++-------
 .../python/ambari_client/model/component.py     | 169 +++--
 .../python/ambari_client/model/configuration.py | 273 ++++---
 .../src/main/python/ambari_client/model/host.py | 475 +++++++------
 .../main/python/ambari_client/model/paths.py    |  17 +-
 .../main/python/ambari_client/model/service.py  | 401 ++++++-----
 .../main/python/ambari_client/model/stack.py    | 208 ++++--
 .../main/python/ambari_client/model/status.py   |  89 +--
 .../main/python/ambari_client/model/utils.py    | 440 +++++++-----
 .../main/python/ambari_client/model/views.py    |  33 +
 .../python/ambari_client/resources/__init__.py  |  16 -
 .../python/ambari_client/resources/clusters.py  |  58 --
 .../python/ambari_client/resources/hosts.py     | 127 ----
 .../python/ambari_client/resources/stacks.py    |  41 --
 .../src/test/python/TestAmbariClient.py         |  11 +-
 .../src/test/python/TestStatusModel.py          |  14 +-
 27 files changed, 2477 insertions(+), 1869 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/pom.xml b/ambari-client/python-client/pom.xml
index 8438b80..74fc0f5 100644
--- a/ambari-client/python-client/pom.xml
+++ b/ambari-client/python-client/pom.xml
@@ -115,7 +115,7 @@
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>rpm-maven-plugin</artifactId>
-        <version>2.1-alpha-2</version>
+        <version>2.0.1</version>
         <executions>
           <execution>
             <phase>none</phase>

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/ambari_api.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/ambari_api.py b/ambari-client/python-client/src/main/python/ambari_client/ambari_api.py
old mode 100755
new mode 100644
index daf5e1e..470db36
--- a/ambari-client/python-client/src/main/python/ambari_client/ambari_api.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/ambari_api.py
@@ -6,9 +6,9 @@
 #  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.
@@ -17,8 +17,8 @@
 
 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
+from ambari_client.model import blueprint, stack, cluster, host
 
 __docformat__ = "epytext"
 
@@ -28,158 +28,234 @@ 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):
+    AmbariClient top-level root resources.
     """
-    Get a cluster by cluster_name.
 
-    @param cluster_name : Cluster's cluster_name.
-    @return : An ClusterModel.
+    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 cluster._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 cluster._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 host._get_host(self, host_name)
+
+    def get_all_hosts(self):
+        """
+        Get all hosts in the Data Center
+        @return: A ModelList of HostModel objects.
+        """
+        return host._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, ssh_user=None):
+        """
+        Bootstrap hosts.
+        @param hosts_list :list of host_names.
+        @param ssh_key : ssh key for password-less access
+        @return: A  StatusModel object.
+        """
+        return host._bootstrap_hosts(self, hosts_list, ssh_key, ssh_user)
+
+    def create_cluster(self, cluster_name, version):
+        """
+        Create a new cluster.
+        @param cluster_name: Cluster name.
+        @param version : HDP version.
+        @return  ClusterModel object.
+        """
+        return cluster._create_cluster(self, cluster_name, version)
+
+    def delete_cluster(self, cluster_name):
+        """
+        Delete a cluster
+        @param cluster_name: Cluster to be deleted
+        """
+        return cluster._delete_cluster(self, cluster_name)
+
+    def delete_host(self, host_name):
+        """
+        Delete a cluster
+        @param host_name: host to be deleted
+        """
+        return host._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 stack._get_configuration_from_stack(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 stack._get_components_from_stack(self, version, service_name)
+
+    def get_stacks(self, view_all_versions=None):
+        """
+        get components from stack
+        @param version: The HDP version.
+        @param service_name: service name
+        @return: A ConfigModel object
+        """
+        return stack._get_stacks(self, view_all_versions)
+
+    def get_stack(self, version):
+        """
+        get components from stack
+        @param version: The HDP version.
+        @param service_name: service name
+        @return: A ConfigModel object
+        """
+        return stack._get_stack(self, version)
+
+    def get_stack_components(self, version, service_name):
+        """
+        get components from stack
+        @param version: The HDP version.
+        @param service_name: service name
+        @return: A ConfigModel object
+        """
+        return stack._get_components_from_stack(self, version, service_name)
+
+    def get_stack_configs(self, version, service_name):
+        """
+        get components from stack
+        @param version: The HDP version.
+        @param service_name: service name
+        @return: A ConfigModel object
+        """
+        return stack._get_configuration_from_stack(self, version, service_name)
+
+    def set_stacks(self, version, os_type, repo):
+        """
+        get components from stack
+        @param version: The HDP version.
+        @param service_name: service name
+        @return: A ConfigModel object
+        """
+        return stack._put_stacks_and_repo(self, version, os_type, repo)
+
+    def get_task_status(self, cluster_name, requestid=None):
+        """
+        get components from stack
+        @param version: The HDP version.
+        @param service_name: service name
+        @return: A ConfigModel object
+        """
+        return cluster._task_status(self, cluster_name, requestid)
+
+    def get_blueprint(self, blueprint_name=None):
+        """
+        get blueprint
+        @param blueprint_name:blueprint_name name.
+        @return: A BlueprintModel object
+        """
+        return blueprint.get_blueprint(self, blueprint_name)
+
+    def delete_blueprint(self, blueprint_name=None):
+        """
+        get blueprint
+        @param blueprint_name:blueprint_name name.
+        @return: A BlueprintModel object
+        """
+        return blueprint.delete_blueprint(self, blueprint_name)
+
+    def create_blueprint(self, blueprint_name=None):
+        """
+        get blueprint
+        @param blueprint_name:blueprint_name name.
+        @return: A BlueprintModel object
+        """
+        return blueprint.create_blueprint(self, blueprint_name)
+
+
+def get_root_resource(
+        server_host,
+        server_port=None,
+        username="admin",
+        password="admin",
+        version=1):
     """
-    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):
+     AmbariClient.
     """
-    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)
+    return AmbariClient(server_host, server_port, username, password, version)

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

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/core/coreutils.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/core/coreutils.py b/ambari-client/python-client/src/main/python/ambari_client/core/coreutils.py
old mode 100755
new mode 100644
index d3e1b4f..278df2e
--- a/ambari-client/python-client/src/main/python/ambari_client/core/coreutils.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/core/coreutils.py
@@ -6,9 +6,9 @@
 #  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.

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/core/errors.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/core/errors.py b/ambari-client/python-client/src/main/python/ambari_client/core/errors.py
old mode 100755
new mode 100644
index c691241..eb3644a
--- a/ambari-client/python-client/src/main/python/ambari_client/core/errors.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/core/errors.py
@@ -6,73 +6,98 @@
 #  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.
 
+
 class ResourceError(Exception):
 
-  def __init__(self, response, resource_root=None):
-    """
-    Create new exception based on not successful server response
-    @param response: StatusModel response
-    @param resource_root: The resource which sent an error response
-    """
-    self.response = response
-    self.resource_root = resource_root
-    Exception.__init__(self)
-        
-  def get_message(self):
-    """ Get an error message """
-    return self.response.get_message()
-  
-  def get_status_code(self):
-    """ Get a status(error) code from the server response """
-    return self.response.status
-  
-  def get_reponse(self):
-    """ StatusModel object """
-    return self.reponse
-  
-  def get_root_resource(self):
-    """ AmbariClient object """
-    return self.resource_root
-  
-  def __str__(self):
-    if self.get_message():
-      return "exception: %s. %s" % (self.response.status, self.get_message()) 
-    try:
-      return self._fmt % self.__dict__
-    except (NameError, ValueError, KeyError), e:
-      return 'exception %s: %s' \
-             % (self.__class__.__name__, str(e))
+    def __init__(self, response, resource_root=None):
+        """
+        Create new exception based on not successful server response
+        @param response: StatusModel response
+        @param resource_root: The resource which sent an error response
+        """
+        self.response = response
+        self.resource_root = resource_root
+        Exception.__init__(self)
+
+    def get_message(self):
+        """ Get an error message """
+        return self.response.get_message()
+
+    def get_status_code(self):
+        """ Get a status(error) code from the server response """
+        return self.response.status
+
+    def get_reponse(self):
+        """ StatusModel object """
+        return self.reponse
+
+    def get_root_resource(self):
+        """ AmbariClient object """
+        return self.resource_root
+
+    def __str__(self):
+        if self.get_message():
+            return "exception: %s. %s" % (
+                self.response.status, self.get_message())
+        try:
+            return self._fmt % self.__dict__
+        except (NameError, ValueError, KeyError) as e:
+            return 'exception %s: %s' \
+                   % (self.__class__.__name__, str(e))
+
 
 class ResourceConflict(ResourceError):
-  """ 409 status code """
+
+    """ 409 status code """
+
+
 class ResourceNotFound(ResourceError):
-  """ 404 status code """
+
+    """ 404 status code """
+
+
 class BadRequest(ResourceError):
-  """ 400 status code """
+
+    """ 400 status code """
+
+
 class AuthorizationError(ResourceError):
-  """ 401 status code """
+
+    """ 401 status code """
+
+
 class ForbiddenError(ResourceError):
-  """ 403 status code """
+
+    """ 403 status code """
+
+
 class InternalServerError(ResourceError):
-  """ 500 status code """
+
+    """ 500 status code """
+
+
 class MethodNotAllowed(ResourceError):
-  """ 405 status code """
+
+    """ 405 status code """
+
+
 class UnknownServerError(ResourceError):
-  """ Received other response code """
-  
-_exceptions_to_codes = { 409:ResourceConflict, 
-                        404:ResourceNotFound,
-                        400:BadRequest,
-                        401:AuthorizationError,
-                        403:ForbiddenError,
-                        500:InternalServerError,
-                        405:MethodNotAllowed }
\ No newline at end of file
+
+    """ Received other response code """
+
+_exceptions_to_codes = {409: ResourceConflict,
+                        404: ResourceNotFound,
+                        400: BadRequest,
+                        401: AuthorizationError,
+                        403: ForbiddenError,
+                        500: InternalServerError,
+                        405: MethodNotAllowed}

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/core/http_client.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/core/http_client.py b/ambari-client/python-client/src/main/python/ambari_client/core/http_client.py
old mode 100755
new mode 100644
index 484ef5d..299b279
--- a/ambari-client/python-client/src/main/python/ambari_client/core/http_client.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/core/http_client.py
@@ -6,9 +6,9 @@
 #  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.
@@ -19,157 +19,159 @@ import logging
 import posixpath
 import sys
 try:
-  import pycurl
+    import pycurl
 # pycurl is not necessary for testcases, mock it
 except ImportError:
-  from mock.mock import MagicMock
-  pycurl = MagicMock() 
+    from mock.mock import MagicMock
+    pycurl = MagicMock()
 import cStringIO
 import StringIO
 import pdb
 try:
-  import json
+    import json
 except ImportError:
-  import simplejson as json
+    import simplejson as json
 from ambari_client.core.http_utils import uri_encoding
 
 __docformat__ = "epytext"
 
 LOG = logging.getLogger(__name__)
 
- 
-class HttpClient(object):
-  """
-  Basic HTTP client for rest APIs.
-  """
-  def __init__(self, host_url, user_name , password ):
-    """
-    @param host_url: The base url to the API.
-
-    """
-
-    self._host_url = host_url.rstrip('/')
-    self._headers = { }
-    self.c = pycurl.Curl()
-    if user_name is not None:
-        self.c.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
-        userpass = user_name + ':'
-        if password is not None: 
-            userpass += password
-    LOG.debug( "pycurl.USERPWD value = "+str(userpass))
-    self.c.setopt(pycurl.USERPWD, userpass)
 
+class HttpClient(object):
 
-  def set_headers(self, headers):
-    """
-    Add headers to the request
     """
-    self._headers = headers
-    return self
-
-  @property
-  def host_url(self):
-    return self._host_url
-
-  def _get_headers(self, headers):
-    res = self._headers.copy()
-    if headers:
-      res.update(headers)
-    return res
-
-  def invoke(self, http_method, path, payload=None, headers=None):
+    Basic HTTP client for rest APIs.
     """
-    Submit an HTTP request.
-    @param http_method: GET, POST, PUT, DELETE
-    @param path: The path of the resource.
-    @param payload: The payload to attach to the body of the request.
-    @param headers: The headers to set for this request.
 
-    @return: The result of REST request
-    """
-    #pdb.set_trace()
-    LOG.debug ("invoke : http_method = "+str(http_method))
-    # Prepare URL and params
-    url = self._normalize(path)
-    if http_method in ("GET", "DELETE"):
-      if payload is not None:
-        self.logger.warn(
-            "GET http_method does not pass any payload. Path '%s'" % (path,))
-        payload = None
-
-
-    buf = cStringIO.StringIO()
-    self.c.setopt(pycurl.WRITEFUNCTION, buf.write)
-    self.c.setopt(pycurl.SSL_VERIFYPEER, 0)
-    
-    LOG.debug ("invoke : url = "+str(url))
-    # set http_method
-    if http_method == "GET":
-        self.c.setopt(pycurl.HTTPGET, 1)
-    elif http_method == "HEAD":
-        self.c.setopt(pycurl.HTTPGET, 1)
-        self.c.setopt(pycurl.NOBODY, 1)
-    elif http_method == "POST":
-        self.c.setopt(pycurl.POST, 1)
-    elif http_method == "PUT":
-        self.c.setopt(pycurl.UPLOAD, 1)
-    else:
-        self.c.setopt(pycurl.CUSTOMREQUEST, http_method)
-
-    data = None    
-    if http_method in ('POST','PUT'):
-      LOG.debug( "data..........."+str(payload))
-      data = json.dumps(payload)
-      #data= data.decode('unicode-escape')
-      #LOG.debug( "after unicode decode")
-      #LOG.debug( data)
-      data = self._to_bytestring(data)
-      LOG.debug( "after _to_bytestring")
-      LOG.debug( data)
-      content = StringIO.StringIO(data)
-      LOG.debug( content)
-      content_length = len(data)
-      LOG.debug( "content_length........."+str(content_length))
-
-      if http_method == 'POST':
-        self.c.setopt(pycurl.POSTFIELDSIZE, content_length)
-      else:
-        self.c.setopt(pycurl.INFILESIZE, content_length)
-        
-      self.c.setopt(pycurl.READFUNCTION, content.read)
-      
-
-    self.c.setopt(self.c.URL, url)
-    headers = self._get_headers(headers)
-    headers_l = ["%s: %s" % pair for pair in sorted(headers.iteritems())]
-    LOG.debug( headers_l)
-    self.c.setopt(pycurl.HTTPHEADER,headers_l)
-
-
-    LOG.debug ("invoke : pycurl.EFFECTIVE_URL = "+self.c.getinfo(pycurl.EFFECTIVE_URL))
-    try:
-        self.c.perform()
-    except Exception, ex:
-        LOG.debug (sys.stderr, str(ex))
-        raise ex
-    contents_type= self.c.getinfo(pycurl.CONTENT_TYPE)
-    LOG.debug ("invoke : pycurl.CONTENT_TYPE = "+contents_type)
-    code = self.c.getinfo(pycurl.RESPONSE_CODE)
-    LOG.debug ("invoke : pycurl.RESPONSE_CODE = "+str(code))
-    response = buf.getvalue()
-    buf.close()
-    LOG.debug ("invoke : COMPLETED ")
-    return response , code , contents_type
-
-  def _to_bytestring(self ,s):
-#    if not isinstance(s, basestring):
-#      raise TypeError("value should be a str or unicode")
-    if isinstance(s, unicode):
-      return s.encode('utf-8')
-    return s
-
-  def _normalize(self, path):
-    res = self._host_url
-    if path:
-      res += posixpath.normpath('/' + path.lstrip('/'))
-    return uri_encoding(res)
+    def __init__(self, host_url, user_name, password):
+        """
+        @param host_url: The base url to the API.
+
+        """
+
+        self._host_url = host_url.rstrip('/')
+        self._headers = {}
+        self.c = pycurl.Curl()
+        if user_name is not None:
+            self.c.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
+            userpass = user_name + ':'
+            if password is not None:
+                userpass += password
+        LOG.debug("pycurl.USERPWD value = " + str(userpass))
+        self.c.setopt(pycurl.USERPWD, userpass)
+
+    def set_headers(self, headers):
+        """
+        Add headers to the request
+        """
+        self._headers = headers
+        return self
+
+    @property
+    def host_url(self):
+        return self._host_url
+
+    def _get_headers(self, headers):
+        res = self._headers.copy()
+        if headers:
+            res.update(headers)
+        return res
+
+    def invoke(self, http_method, path, payload=None, headers=None):
+        """
+        Submit an HTTP request.
+        @param http_method: GET, POST, PUT, DELETE
+        @param path: The path of the resource.
+        @param payload: The payload to attach to the body of the request.
+        @param headers: The headers to set for this request.
+
+        @return: The result of REST request
+        """
+        # pdb.set_trace()
+        LOG.debug("invoke : http_method = " + str(http_method))
+        # Prepare URL and params
+        url = self._normalize(path)
+        if http_method in ("GET", "DELETE"):
+            if payload is not None:
+                self.logger.warn(
+                    "GET http_method does not pass any payload. Path '%s'" %
+                    (path,))
+                payload = None
+
+        buf = cStringIO.StringIO()
+        self.c.setopt(pycurl.WRITEFUNCTION, buf.write)
+        self.c.setopt(pycurl.SSL_VERIFYPEER, 0)
+
+        LOG.debug("invoke : url = " + str(url))
+        # set http_method
+        if http_method == "GET":
+            self.c.setopt(pycurl.HTTPGET, 1)
+        elif http_method == "HEAD":
+            self.c.setopt(pycurl.HTTPGET, 1)
+            self.c.setopt(pycurl.NOBODY, 1)
+        elif http_method == "POST":
+            self.c.setopt(pycurl.POST, 1)
+        elif http_method == "PUT":
+            self.c.setopt(pycurl.UPLOAD, 1)
+        else:
+            self.c.setopt(pycurl.CUSTOMREQUEST, http_method)
+
+        data = None
+        if http_method in ('POST', 'PUT'):
+            LOG.debug("data..........." + str(payload))
+            data = json.dumps(payload)
+            #data= data.decode('unicode-escape')
+            #LOG.debug( "after unicode decode")
+            #LOG.debug( data)
+            data = self._to_bytestring(data)
+            LOG.debug("after _to_bytestring")
+            LOG.debug(data)
+            content = StringIO.StringIO(data)
+            LOG.debug(content)
+            content_length = len(data)
+            LOG.debug("content_length........." + str(content_length))
+
+            if http_method == 'POST':
+                self.c.setopt(pycurl.POSTFIELDSIZE, content_length)
+            else:
+                self.c.setopt(pycurl.INFILESIZE, content_length)
+
+            self.c.setopt(pycurl.READFUNCTION, content.read)
+
+        self.c.setopt(self.c.URL, url)
+        headers = self._get_headers(headers)
+        headers_l = ["%s: %s" % pair for pair in sorted(headers.iteritems())]
+        LOG.debug(headers_l)
+        self.c.setopt(pycurl.HTTPHEADER, headers_l)
+
+        LOG.debug(
+            "invoke : pycurl.EFFECTIVE_URL = " +
+            self.c.getinfo(
+                pycurl.EFFECTIVE_URL))
+        try:
+            self.c.perform()
+        except Exception as ex:
+            LOG.debug(sys.stderr, str(ex))
+            raise ex
+        contents_type = self.c.getinfo(pycurl.CONTENT_TYPE)
+        LOG.debug("invoke : pycurl.CONTENT_TYPE = " + contents_type)
+        code = self.c.getinfo(pycurl.RESPONSE_CODE)
+        LOG.debug("invoke : pycurl.RESPONSE_CODE = " + str(code))
+        response = buf.getvalue()
+        buf.close()
+        LOG.debug("invoke : COMPLETED ")
+        return response, code, contents_type
+
+    def _to_bytestring(self, s):
+        #    if not isinstance(s, basestring):
+        #      raise TypeError("value should be a str or unicode")
+        if isinstance(s, unicode):
+            return s.encode('utf-8')
+        return s
+
+    def _normalize(self, path):
+        res = self._host_url
+        if path:
+            res += posixpath.normpath('/' + path.lstrip('/'))
+        return uri_encoding(res)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/core/http_utils.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/core/http_utils.py b/ambari-client/python-client/src/main/python/ambari_client/core/http_utils.py
old mode 100755
new mode 100644
index 07fea45..5c0dc2f
--- a/ambari-client/python-client/src/main/python/ambari_client/core/http_utils.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/core/http_utils.py
@@ -6,9 +6,9 @@
 #  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.
@@ -30,12 +30,11 @@ def uri_encoding(url):
     return urllib.quote(get_utf8_str(url), safe="/#%[]=:;$&()+,!?*@'~")
 
 
-
 def get_utf8_str(strr, encoding='utf-8'):
     """
     Returns a utf8 ecoded 'str'.
     """
-    errors='strict'
+    errors = 'strict'
     if not isinstance(strr, basestring):
         try:
             return str(strr)
@@ -49,4 +48,3 @@ def get_utf8_str(strr, encoding='utf-8'):
         return strr.decode('utf-8', errors).encode(encoding, errors)
     else:
         return strr
-

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/core/rest_resource.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/core/rest_resource.py b/ambari-client/python-client/src/main/python/ambari_client/core/rest_resource.py
old mode 100755
new mode 100644
index 532fc53..9e98178
--- a/ambari-client/python-client/src/main/python/ambari_client/core/rest_resource.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/core/rest_resource.py
@@ -6,9 +6,9 @@
 #  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.
@@ -16,9 +16,9 @@
 #  limitations under the License.
 
 try:
-  import json
+    import json
 except ImportError:
-  import simplejson as json
+    import simplejson as json
 import logging
 import posixpath
 
@@ -26,95 +26,111 @@ LOG = logging.getLogger(__name__)
 
 
 class RestResource(object):
-  """
-  RestResource wrapper.
-  """
-  def __init__(self, client, path=""):
-    """
-    @param client: A Client object.
-    @param path: The relative path of the resource.
-    """
-    self._client = client
-    self._path = path.strip('/')
-
-  @property
-  def host_url(self):
-    return self._client.host_url
-
-  def _join_uri(self, relpath):
-    if relpath is None:
-      return self._path
-    return self._path + posixpath.normpath('/' + relpath)
-  
-  def _set_headers(self, content_type=None):
-    if content_type:
-      return { 'Content-Type': content_type }
-    return None
-
-  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):
-    """
-    Invoke an API http_method.
-    """
-    path = self._join_uri(url_path)
-    resp , code , content = self._make_invoke(http_method, payload, headers, path)
-
-    LOG.debug ("RESPONSE from the REST request >>>>>>> \n" + str(resp))
-    LOG.debug ("\n===========================================================")
-    #take care of REST calls with no response
-
-    try:
-      isOK = (code == 200 or code == 201 or code == 202)
-        
-      if isOK and not resp:
-        json_dict = {"status":code}
-      else:
-        json_dict = json.loads(resp)
-          
-      return json_dict
-    except Exception, ex:
-      LOG.error("Command '%s %s' failed with error %s\n%s" % (http_method, path, code ,resp))
-      return {"status":code , "message":"Command '%s %s' failed with error %s" % (http_method, path, code)}
-
-
-  def get(self, path=None):
-    """
-    Invoke the GET method .
-    @param path: resource path
-    @return: A dictionary of the REST result.
-    """
-    return self.invoke("GET", path)
 
-
-  def put(self, path=None, payload=None, content_type=None):
-    """
-    Invoke the PUT method on a resource.
-    @param path: resource path
-    @param payload: Body of the request.
-    @param content_type: 
-    @return: A dictionary of the REST result.
-    """
-    return self.invoke("PUT", path, payload, self._set_headers(content_type))
-
-
-  def post(self, path=None, payload=None, content_type=None):
     """
-    Invoke the POST method on a resource.
-    @param path: resource path
-    @param payload: Body of the request.
-    @param content_type: 
-    @return: A dictionary of the REST result.
+    RestResource wrapper.
     """
-    return self.invoke("POST", path, payload, self._set_headers(content_type))
-
 
-  def delete(self, path=None, payload=None,):
-    """
-    Invoke the DELETE method on a resource.
-    @param path: resource path
-    @param payload: Body of the request.
-    @return: A dictionary of the REST result.
-    """
-    return self.invoke("DELETE", path, payload)
+    def __init__(self, client, path=""):
+        """
+        @param client: A Client object.
+        @param path: The relative path of the resource.
+        """
+        self._client = client
+        self._path = path.strip('/')
+
+    @property
+    def host_url(self):
+        return self._client.host_url
+
+    def _join_uri(self, relpath):
+        if relpath is None:
+            return self._path
+        return self._path + posixpath.normpath('/' + relpath)
+
+    def _set_headers(self, content_type=None):
+        if content_type:
+            return {'Content-Type': content_type}
+        return None
+
+    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):
+        """
+        Invoke an API http_method.
+        """
+        path = self._join_uri(url_path)
+        resp, code, content = self._make_invoke(
+            http_method, payload, headers, path)
+
+        LOG.debug("RESPONSE from the REST request >>>>>>> \n" + str(resp))
+        LOG.debug(
+            "\n===========================================================")
+        # take care of REST calls with no response
+
+        try:
+            isOK = (code == 200 or code == 201 or code == 202)
+
+            if isOK and not resp:
+                json_dict = {"status": code}
+            else:
+                json_dict = json.loads(resp)
+
+            return json_dict
+        except Exception as ex:
+            LOG.error(
+                "Command '%s %s' failed with error %s\n%s" %
+                (http_method, path, code, resp))
+            return {
+                "status": code, "message": "Command '%s %s' failed with error %s" %
+                (http_method, path, code)}
+
+    def get(self, path=None):
+        """
+        Invoke the GET method .
+        @param path: resource path
+        @return: A dictionary of the REST result.
+        """
+        return self.invoke("GET", path)
+
+    def put(self, path=None, payload=None, content_type=None):
+        """
+        Invoke the PUT method on a resource.
+        @param path: resource path
+        @param payload: Body of the request.
+        @param content_type:
+        @return: A dictionary of the REST result.
+        """
+        return self.invoke(
+            "PUT",
+            path,
+            payload,
+            self._set_headers(content_type))
+
+    def post(self, path=None, payload=None, content_type=None):
+        """
+        Invoke the POST method on a resource.
+        @param path: resource path
+        @param payload: Body of the request.
+        @param content_type:
+        @return: A dictionary of the REST result.
+        """
+        return self.invoke(
+            "POST",
+            path,
+            payload,
+            self._set_headers(content_type))
+
+    def delete(self, path=None, payload=None,):
+        """
+        Invoke the DELETE method on a resource.
+        @param path: resource path
+        @param payload: Body of the request.
+        @return: A dictionary of the REST result.
+        """
+        return self.invoke("DELETE", path, payload)

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

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/base_model.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/base_model.py b/ambari-client/python-client/src/main/python/ambari_client/model/base_model.py
old mode 100755
new mode 100644
index 79fd9ad..1d4fc15
--- a/ambari-client/python-client/src/main/python/ambari_client/model/base_model.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/base_model.py
@@ -6,9 +6,9 @@
 #  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.
@@ -18,7 +18,7 @@
 import sys
 import logging
 import time
-from  ambari_client.model.utils  import get_REF_object, get_unicode, getREF_var_name , LIST_KEY
+from ambari_client.model.utils import get_REF_object, get_unicode, getREF_var_name, LIST_KEY
 from operator import itemgetter, attrgetter
 
 __docformat__ = "epytext"
@@ -27,83 +27,83 @@ LOG = logging.getLogger(__name__)
 
 
 class BaseModel(object):
-  """
-  The BaseModel 
-
-  RW_ATTR - A list of mutable attributes
-  RO_ATTR - A list of immutable attributes
-  REF_ATTR - A REF attribute   
-
-  """
-  RO_ATTR = ()         
-  RW_ATTR = ()         
-  REF_ATTR = ()        
-  
-  def __init__(self, resource_root, **rw_attrs):
-    #print" ================== base_model\n"
-    #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" % 
-                         (k, self.__class__.__name__))
-      self._setattr(k, v)
-
-  def _get_resource_root(self):
-    return self._resource_root
-
-  def to_json_dict(self):
-    dic = { }
-    for attr in self.RW_ATTR:
-      value = getattr(self, attr)
-      try:
-        value = value.to_json_dict()
-      except Exception:
-        pass
-      dic[attr] = value
-    return dic
-
-  def _setattr(self, k, v):
-    """Set an attribute. """
-    value = v
-    if v and k.endswith("Ref"):
-      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))
-      v = get_unicode(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)
 
+    """
+    The BaseModel
+
+    RW_ATTR - A list of mutable attributes
+    RO_ATTR - A list of immutable attributes
+    REF_ATTR - A REF attribute
+
+    """
+    RO_ATTR = ()
+    RW_ATTR = ()
+    REF_ATTR = ()
+
+    def __init__(self, resource_root, **rw_attrs):
+        # print" ================== base_model\n"
+        # 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" %
+                                 (k, self.__class__.__name__))
+            self._setattr(k, v)
+
+    def _get_resource_root(self):
+        return self._resource_root
+
+    def to_json_dict(self):
+        dic = {}
+        for attr in self.RW_ATTR:
+            value = getattr(self, attr)
+            try:
+                value = value.to_json_dict()
+            except Exception:
+                pass
+            dic[attr] = value
+        return dic
+
+    def _setattr(self, k, v):
+        """Set an attribute. """
+        value = v
+        if v and k.endswith("Ref"):
+            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))
+            v = get_unicode(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"""
 
-  def __init__(self, objects):
-    self.objects = objects
+    """A list of Model objects"""
+
+    def __init__(self, objects):
+        self.objects = objects
 
-  def __str__(self):
-    return "<<ModelList>>[size = %d]) = [%s]" % (
-        len(self.objects),
-        ", ".join([str(item) for item in self.objects]))
+    def __str__(self):
+        return "<<ModelList>>[size = %d]) = [%s]" % (
+            len(self.objects),
+            ", ".join([str(item) for item in self.objects]))
 
-  def to_json_dict(self):
-    return { LIST_KEY :
-            [ x.to_json_dict() for x in self.objects ] }
+    def to_json_dict(self):
+        return {LIST_KEY:
+                [x.to_json_dict() for x in self.objects]}
 
-  def __len__(self):
-    return self.objects.__len__()
+    def __len__(self):
+        return self.objects.__len__()
 
-  def __iter__(self):
-    return self.objects.__iter__()
+    def __iter__(self):
+        return self.objects.__iter__()
 
-  def sort(self, sortkey):
-    self.objects = sorted(self.objects, key=sortkey ,reverse=True) 
-      
-  def __getitem__(self, i):
-    return self.objects.__getitem__(i)
+    def sort(self, sortkey):
+        self.objects = sorted(self.objects, key=sortkey, reverse=True)
 
+    def __getitem__(self, i):
+        return self.objects.__getitem__(i)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/blueprint.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/blueprint.py b/ambari-client/python-client/src/main/python/ambari_client/model/blueprint.py
new file mode 100644
index 0000000..8497dc6
--- /dev/null
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/blueprint.py
@@ -0,0 +1,125 @@
+#  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_blueprint(resource_root, blueprint_name):
+    """
+    Get all Blueprint
+    @param root_resource: The root Resource .
+    @param name: blueprint_name
+    @return: A list of BlueprintModel objects.
+    """
+    if not blueprint_name:
+        dic = resource_root.get(paths.BLUEPRINT_ALL_PATH)
+        return utils.ModelUtils.get_model_list(
+            ModelList,
+            BlueprintModel,
+            dic,
+            resource_root,
+            "Blueprints")
+    else:
+        dic = resource_root.get(paths.BLUEPRINT_PATH % blueprint_name)
+        return utils.ModelUtils.create_model(
+            BlueprintModel,
+            dic,
+            resource_root,
+            "Blueprints")
+
+
+def delete_blueprint(resource_root, blueprint_name):
+    """
+    Delete a blueprint by name
+    @param root_resource: The root Resource .
+    @param name: blueprint_name
+    """
+    resp = resource_root.delete(paths.BLUEPRINT_PATH % blueprint_name)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        resource_root,
+        "NO_KEY")
+
+
+def create_blueprint(resource_root, blueprint_name, json_data):
+    """
+    Create a blueprint
+    @param root_resource: The root Resource.
+    @param blueprint_name: blueprint_name
+    @param json_data: blueprint  json
+    @return: An ClusterModel object
+    """
+    path = paths.BLUEPRINT_PATH % blueprint_name
+    resp = resource_root.post(path=path, payload=json_data)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        resource_root,
+        "NO_KEY")
+
+
+class BlueprintModel(BaseModel):
+
+    """
+    The BlueprintModel class
+    """
+    RO_ATTR = ('stack_name', 'stack_version')
+    RW_ATTR = ('blueprint_name')
+    REF_ATTR = ('cluster_name',)
+
+    def __init__(self, resource_root, blueprint_name):
+        utils.retain_self_helper(BaseModel, **locals())
+
+    def __str__(self):
+        return "<<BlueprintModel>> blueprint_name = %s " % (
+            self.blueprint_name)
+
+
+class BlueprintConfigModel(BaseModel):
+
+    """
+    The BlueprintConfigModel class
+    """
+    RO_ATTR = ('stack_name', 'stack_version')
+    RW_ATTR = ('blueprint_name')
+    REF_ATTR = ('cluster_name',)
+
+    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 "<<BlueprintConfigModel>> property_name=%s; service_name= %s" % (
+            self.property_name, self.service_name)

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/cluster.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/cluster.py b/ambari-client/python-client/src/main/python/ambari_client/model/cluster.py
old mode 100755
new mode 100644
index 4a8cce6..87cd86e
--- a/ambari-client/python-client/src/main/python/ambari_client/model/cluster.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/cluster.py
@@ -6,9 +6,9 @@
 #  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.
@@ -17,315 +17,493 @@
 
 import logging
 import time
-from ambari_client.model.base_model import  BaseModel , ModelList
-from ambari_client.model import service , host , paths , status, configuration , utils
+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):
-  """
-  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" % (paths.CLUSTERS_PATH, cluster_name))
-  return utils.ModelUtils.create_model(ClusterModel , dic, resource_root, "Clusters")
+    """
+    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" % (paths.CLUSTERS_PATH, cluster_name))
+    return utils.ModelUtils.create_model(
+        ClusterModel,
+        dic,
+        resource_root,
+        "Clusters")
 
 
 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(paths.CLUSTERS_PATH)
-  return utils.ModelUtils.get_model_list(ModelList, ClusterModel, dic, root_resource , "Clusters")
-
-
-def _create_cluster(root_resource, cluster_name, version):
-  """
-  Create a cluster
-  @param root_resource: The root Resource.
-  @param cluster_name: Cluster cluster_name
-  @param version: HDP version
-  @return: An ClusterModel object
-  """
-  data = {"Clusters":{"version":str(version)}}
-  path = paths.CLUSTERS_PATH + "/%s" % (cluster_name)
-  resp = root_resource.post(path=path , payload=data)
-  return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
-
-
-def _delete_cluster(root_resource, cluster_name):
-  """
-  Delete a cluster by name
-  @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
-  """
-  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):
-    utils.retain_self_helper(BaseModel, **locals())
-
-  def __str__(self):
-    return "<<ClusterModel>> cluster_name = %s; version = %s" % (self.cluster_name, self.version)
-
-  def _path(self):
-    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 name
-    @return: A ServiceModel object
+    Get all clusters
+    @param root_resource: The root Resource .
+    @return: A list of ClusterModel objects.
     """
-    return service._get_service(self._get_resource_root(), service_name, self.cluster_name)
+    dic = root_resource.get(paths.CLUSTERS_PATH)
+    return utils.ModelUtils.get_model_list(
+        ModelList,
+        ClusterModel,
+        dic,
+        root_resource,
+        "Clusters")
 
-  def get_all_services(self, detail=None):
-    """
-    Get all services in this cluster.
-    @return: ModelList containing ServiceModel objects.
-    """
-    return service._get_all_services(self._get_resource_root(), self.cluster_name)
 
-  def get_all_hosts(self, detail=None):
+def _create_cluster(root_resource, cluster_name, version):
     """
-    Get all hosts in this cluster.
-    @return: ModelList containing HostModel objects.
+    Create a cluster
+    @param root_resource: The root Resource.
+    @param cluster_name: Cluster cluster_name
+    @param version: HDP version
+    @return: An ClusterModel object
     """
-    return host._get_all_cluster_hosts(self._get_resource_root(), self.cluster_name)
+    data = {"Clusters": {"version": str(version)}}
+    path = paths.CLUSTERS_PATH + "/%s" % (cluster_name)
+    resp = root_resource.post(path=path, payload=data)
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        root_resource,
+        "NO_KEY")
 
-  def get_host(self, hostname , detail=None):
-    """
-    Get a specific hosts in this cluster.
-    @return: A HostModel object.
-    """
-    return host._get_cluster_host(self._get_resource_root(), self.cluster_name, hostname)
 
-  def get_global_config(self, detail=None):
+def _delete_cluster(root_resource, cluster_name):
     """
-    Get global configuration of  cluster.
-    @return: A ConfigModel object.
+    Delete a cluster by name
+    @param root_resource: The root Resource .
+    @param name: Cluster name
     """
-    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "global")
+    resp = root_resource.delete("%s/%s" % (paths.CLUSTERS_PATH, cluster_name))
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        root_resource,
+        "NO_KEY")
 
-  def get_core_site_config(self, tag="version1" ,detail=None):
-    """
-    Get core-site configuration of  cluster.
-    @return: A ConfigModel object or ModelList<ConfiObject>
-    """
-    if(detail == utils.ALL):
-        return configuration._get_all_configuration(self._get_resource_root(), self.cluster_name, "core-site")
-    else:
-        return configuration._get_configuration(self._get_resource_root(), self.cluster_name,  "core-site" ,tag)
 
-  def get_hdfs_site_config(self, detail=None):
+def _install_all_services(root_resource, cluster_name):
     """
-    Get hdfs-site configuration of  cluster.
-    @return: A ConfigModel object.
+    Start all services
+    @param root_resource: The root Resource .
+    @param name: Cluster name
     """
-    return configuration._get_configuration(self._get_resource_root(), self.cluster_name, "hdfs-site")
+    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 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 , tag="version1" ,detail=None):
+def _stop_all_services(root_resource, cluster_name):
     """
-    Updates the  global configuration of  cluster.
-    @param config_model: The configModel object
-    @return: A ConfigModel object.
+    Start all services
+    @param root_resource: The root Resource .
+    @param name: Cluster name
     """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "global" , tag, config_model)
+    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 update_core_site_config(self, config_model , tag="version1" ,detail=None):
-    """
-    Updates the  core-site configuration of  cluster.
-    @param config_model: The configModel object
-    @return: A ConfigModel object.
-    """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "core-site", tag, config_model)
 
-  def update_hdfs_site_config(self, config_model , tag="version1" , detail=None):
+def _start_all_services(root_resource, cluster_name, run_smoke_test=False):
     """
-    Updates the  hdfs-site configuration of  cluster.
-    @param config_model: The configModel object
-    @return: A ConfigModel object.
+    Start all services
+    @param root_resource: The root Resource .
+    @param name: Cluster name
     """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "hdfs-site", tag, config_model)
+    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 "Requests" in resp:
+        resp = resp["Requests"]
+    return utils.ModelUtils.create_model(
+        status.StatusModel,
+        resp,
+        root_resource,
+        "NO_KEY")
 
-  def update_mapred_site_config(self, config_model ,tag="version1" , detail=None):
-    """
-    Updates the  mapred-site configuration of  cluster.
-    @param config_model: The configModel object
-    @return: A ConfigModel object.
-    """
-    return configuration._update_configuration(self._get_resource_root(), self.cluster_name, "mapred-site", tag, 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 _task_status(root_resource, cluster_name, requestid):
+    cpath = paths.TASKS_PATH % (cluster_name, requestid)
+    dic = root_resource.get(cpath)
+    return utils.ModelUtils.get_model_list(
+        ModelList,
+        TaskModel,
+        dic,
+        root_resource,
+        "Tasks")
 
-  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)
+class TaskModel(BaseModel):
 
-  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.
+    The ClusterModel class
     """
-    return service._create_service_component(self._get_resource_root(), self.cluster_name , version, service_name, component_name)
+    RW_ATTR = ('host_name', 'role', 'status')
 
-  def create_hosts(self, host_list , detail=None):
-    """
-    Creates hosts.
-    @param host_list: list of HostModel
-    @return: StatusModel.
-    """
-    return host._add_hosts(self._get_resource_root(), self.cluster_name , host_list)
+    def __init__(self, resource_root, host_name, role, status):
+        utils.retain_self_helper(BaseModel, **locals())
 
-  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 __str__(self):
+        return "<<TaskModel>> host_name = %s; status = %s" % (
+            self.host_name, self.status)
 
-  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)
+class ClusterModel(BaseModel):
 
-  def stop_all_services(self, detail=None):
     """
-    Stop all the services.
-    @return: StatusModel.
-    """
-    return _stop_all_services(self._get_resource_root(), self.cluster_name)
+    The ClusterModel class
+    """
+    RW_ATTR = ('cluster_name', 'version')
+
+    def __init__(self, resource_root, cluster_name, version):
+        utils.retain_self_helper(BaseModel, **locals())
+
+    def __str__(self):
+        return "<<ClusterModel>> cluster_name = %s; version = %s" % (
+            self.cluster_name, self.version)
+
+    def _path(self):
+        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 name
+        @return: A ServiceModel object
+        """
+        return service._get_service(
+            self._get_resource_root(),
+            service_name,
+            self.cluster_name)
+
+    def get_all_services(self, detail=None):
+        """
+        Get all services in this cluster.
+        @return: ModelList containing ServiceModel objects.
+        """
+        return service._get_all_services(
+            self._get_resource_root(),
+            self.cluster_name)
+
+    def get_all_hosts(self, detail=None):
+        """
+        Get all hosts in this cluster.
+        @return: ModelList containing HostModel objects.
+        """
+        return host._get_all_cluster_hosts(
+            self._get_resource_root(),
+            self.cluster_name)
+
+    def get_host(self, hostname, detail=None):
+        """
+        Get a specific hosts in this cluster.
+        @return: A HostModel object.
+        """
+        return host._get_cluster_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, tag="version1", detail=None):
+        """
+        Get core-site configuration of  cluster.
+        @return: A ConfigModel object or ModelList<ConfiObject>
+        """
+        if(detail == utils.ALL):
+            return configuration._get_all_configuration(
+                self._get_resource_root(),
+                self.cluster_name,
+                "core-site")
+        else:
+            return configuration._get_configuration(
+                self._get_resource_root(),
+                self.cluster_name,
+                "core-site",
+                tag)
+
+    def get_hdfs_site_config(self, detail=None):
+        """
+        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, tag="version1", detail=None):
+        """
+        Updates the  global configuration of  cluster.
+        @param config_model: The configModel object
+        @return: A ConfigModel object.
+        """
+        return configuration._update_configuration(
+            self._get_resource_root(),
+            self.cluster_name,
+            "global",
+            tag,
+            config_model)
+
+    def update_core_site_config(
+            self,
+            config_model,
+            tag="version1",
+            detail=None):
+        """
+        Updates the  core-site configuration of  cluster.
+        @param config_model: The configModel object
+        @return: A ConfigModel object.
+        """
+        return configuration._update_configuration(
+            self._get_resource_root(),
+            self.cluster_name,
+            "core-site",
+            tag,
+            config_model)
+
+    def update_hdfs_site_config(
+            self,
+            config_model,
+            tag="version1",
+            detail=None):
+        """
+        Updates the  hdfs-site configuration of  cluster.
+        @param config_model: The configModel object
+        @return: A ConfigModel object.
+        """
+        return configuration._update_configuration(
+            self._get_resource_root(),
+            self.cluster_name,
+            "hdfs-site",
+            tag,
+            config_model)
+
+    def update_mapred_site_config(
+            self,
+            config_model,
+            tag="version1",
+            detail=None):
+        """
+        Updates the  mapred-site configuration of  cluster.
+        @param config_model: The configModel object
+        @return: A ConfigModel object.
+        """
+        return configuration._update_configuration(
+            self._get_resource_root(),
+            self.cluster_name,
+            "mapred-site",
+            tag,
+            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 HostModel
+        @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)
 
-  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)   
+class ClusterModelRef(BaseModel):
 
-  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
+    The ClusterModelRef class
+      Some models need reference to cluster
     """
-    return configuration._create_config(self._get_resource_root(), self.cluster_name , type, tag , properties)   
+    RW_ATTR = ('cluster_name',)
 
-
-
-class ClusterModelRef(BaseModel):
-  """
-  The ClusterModelRef class
-    Some models need reference to cluster
-  """
-  RW_ATTR = ('cluster_name',)
-  def __init__(self, resource_root, cluster_name=None):
-    utils.retain_self_helper(BaseModel, **locals())
+    def __init__(self, resource_root, cluster_name=None):
+        utils.retain_self_helper(BaseModel, **locals())

http://git-wip-us.apache.org/repos/asf/ambari/blob/82ce9aeb/ambari-client/python-client/src/main/python/ambari_client/model/component.py
----------------------------------------------------------------------
diff --git a/ambari-client/python-client/src/main/python/ambari_client/model/component.py b/ambari-client/python-client/src/main/python/ambari_client/model/component.py
old mode 100755
new mode 100644
index 586f21a..5e04fc8
--- a/ambari-client/python-client/src/main/python/ambari_client/model/component.py
+++ b/ambari-client/python-client/src/main/python/ambari_client/model/component.py
@@ -6,9 +6,9 @@
 #  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.
@@ -16,82 +16,111 @@
 #  limitations under the License.
 
 import logging
-from ambari_client.model.base_model import  BaseModel , ModelList
-from ambari_client.model  import paths , utils , status
-
+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")
-
-
-
-
-
-
+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.
+    The ComponentModel class
     """
-    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
+    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