ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject [3/3] git commit: AMBARI-6316 Python client improvements(subin)
Date Mon, 30 Jun 2014 14:12:59 GMT
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 <subin@apache.org>
Authored: Mon Jun 30 19:40:40 2014 +0530
Committer: Subin <subin@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


Mime
View raw message