You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/08/03 15:30:55 UTC

git commit: Update base loadbalancer api to use sphinx style docs, add loadbalancer api sphinx docs.

Updated Branches:
  refs/heads/trunk e1d8dd992 -> efc6e9923


Update base loadbalancer api to use sphinx style docs, add loadbalancer api
sphinx docs.


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

Branch: refs/heads/trunk
Commit: efc6e9923ba17eb546f3eb29a45f07f56cf1e8bc
Parents: e1d8dd9
Author: Tomaz Muraus <to...@apache.org>
Authored: Sat Aug 3 15:30:10 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Aug 3 15:30:49 2013 +0200

----------------------------------------------------------------------
 docs/loadbalancers/api.rst    |   5 ++
 libcloud/loadbalancer/base.py | 131 ++++++++++++++++++++-----------------
 2 files changed, 75 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/efc6e992/docs/loadbalancers/api.rst
----------------------------------------------------------------------
diff --git a/docs/loadbalancers/api.rst b/docs/loadbalancers/api.rst
new file mode 100644
index 0000000..0be4329
--- /dev/null
+++ b/docs/loadbalancers/api.rst
@@ -0,0 +1,5 @@
+LoadBalancer Base API
+=====================
+
+.. autoclass:: libcloud.loadbalancer.base.Driver
+    :members:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/efc6e992/libcloud/loadbalancer/base.py
----------------------------------------------------------------------
diff --git a/libcloud/loadbalancer/base.py b/libcloud/loadbalancer/base.py
index ccc7fab..d7d8e7d 100644
--- a/libcloud/loadbalancer/base.py
+++ b/libcloud/loadbalancer/base.py
@@ -90,10 +90,9 @@ class LoadBalancer(object):
 
 class Driver(BaseDriver):
     """
-    A base LBDriver class to derive from
+    A base Driver class to derive from
 
     This class is always subclassed by a specific driver.
-
     """
 
     connectionCls = ConnectionKey
@@ -109,7 +108,7 @@ class Driver(BaseDriver):
         """
         Return a list of supported protocols.
 
-        @rtype: C{list} of C{str}
+        :rtype: ``list`` of ``str``
         """
         raise NotImplementedError(
             'list_protocols not implemented for this driver')
@@ -118,7 +117,7 @@ class Driver(BaseDriver):
         """
         List all loadbalancers
 
-        @rtype: C{list} of L{LoadBalancer}
+        :rtype: ``list`` of :class:`LoadBalancer`
         """
         raise NotImplementedError(
             'list_balancers not implemented for this driver')
@@ -127,34 +126,35 @@ class Driver(BaseDriver):
         """
         Create a new load balancer instance
 
-        @param name: Name of the new load balancer (required)
-        @type  name: C{str}
+        :param name: Name of the new load balancer (required)
+        :type  name: ``str``
 
-        @param port: Port the load balancer should listen on, defaults to 80
-        @type  port: C{str}
+        :param port: Port the load balancer should listen on, defaults to 80
+        :type  port: ``str``
 
-        @param protocol: Loadbalancer protocol, defaults to http.
-        @type  protocol: C{str}
+        :param protocol: Loadbalancer protocol, defaults to http.
+        :type  protocol: ``str``
 
-        @param members: list of Members to attach to balancer
-        @type  members: C{list} of L{Member}
+        :param members: list of Members to attach to balancer
+        :type  members: ``list`` of :class:`Member`
 
-        @param algorithm: Load balancing algorithm, defaults to ROUND_ROBIN
-        @type algorithm: L{Algorithm}
+        :param algorithm: Load balancing algorithm, defaults to ROUND_ROBIN.
+        :type algorithm: :class:`Algorithm`
 
-        @rtype: L{LoadBalancer}
+        :rtype: :class:`LoadBalancer`
         """
         raise NotImplementedError(
             'create_balancer not implemented for this driver')
 
     def destroy_balancer(self, balancer):
-        """Destroy a load balancer
+        """
+        Destroy a load balancer
 
-        @param balancer: LoadBalancer which should be used
-        @type  balancer: L{LoadBalancer}
+        :param balancer: LoadBalancer which should be used
+        :type  balancer: :class:`LoadBalancer`
 
-        @return: True if the destroy was successful, otherwise False
-        @rtype: C{bool}
+        :return: ``True`` if the destroy was successful, otherwise ``False``.
+        :rtype: ``bool``
         """
 
         raise NotImplementedError(
@@ -164,10 +164,10 @@ class Driver(BaseDriver):
         """
         Return a L{LoadBalancer} object.
 
-        @param balancer_id: id of a load balancer you want to fetch
-        @type  balancer_id: C{str}
+        :param balancer_id: id of a load balancer you want to fetch
+        :type  balancer_id: ``str``
 
-        @rtype: L{LoadBalancer}
+        :rtype: L{LoadBalancer}
         """
 
         raise NotImplementedError(
@@ -177,22 +177,22 @@ class Driver(BaseDriver):
         """
         Sets the name, algorithm, protocol, or port on a load balancer.
 
-        @param   balancer: LoadBalancer which should be used
-        @type    balancer: L{LoadBalancer}
+        :param   balancer: LoadBalancer which should be used
+        :type    balancer: :class:`LoadBalancer`
 
-        @keyword name: New load balancer name
-        @type    name: C{str}
+        :param name: New load balancer name
+        :type    name: ``str``
 
-        @keyword algorithm: New load balancer algorithm
-        @type    algorithm: L{Algorithm}
+        :param algorithm: New load balancer algorithm
+        :type    algorithm: :class:`Algorithm`
 
-        @keyword protocol: New load balancer protocol
-        @type    protocol: C{str}
+        :param protocol: New load balancer protocol
+        :type    protocol: ``str``
 
-        @keyword port: New load balancer port
-        @type    port: C{int}
+        :param port: New load balancer port
+        :type    port: ``int``
 
-        @rtype: L{LoadBalancer}
+        :rtype: :class:`LoadBalancer`
         """
         raise NotImplementedError(
             'update_balancer not implemented for this driver')
@@ -201,32 +201,31 @@ class Driver(BaseDriver):
         """
         Attach a compute node as a member to the load balancer.
 
-        @param balancer: LoadBalancer which should be used
-        @type  balancer: L{LoadBalancer}
+        :param balancer: LoadBalancer which should be used
+        :type  balancer: :class:`LoadBalancer`
 
-        @param node: Node to join to the balancer
-        @type  node: L{Node}
+        :param node: Node to join to the balancer
+        :type  node: :class:`Node`
 
-        @return: Member after joining the balancer.
-        @rtype: L{Member}
+        :return: Member after joining the balancer.
+        :rtype: :class:`Member`
         """
 
-        return self.balancer_attach_member(balancer, Member(id=None,
-                                                            ip=node.public_ips[0],
-                                                            port=balancer.port))
+        member = Member(id=None, ip=node.public_ips[0], port=balancer.port)
+        return self.balancer_attach_member(balancer, member)
 
     def balancer_attach_member(self, balancer, member):
         """
         Attach a member to balancer
 
-        @param balancer: LoadBalancer which should be used
-        @type  balancer: L{LoadBalancer}
+        :param balancer: LoadBalancer which should be used
+        :type  balancer: :class:`LoadBalancer`
 
-        @param member: Member to join to the balancer
-        @type member: L{Member}
+        :param member: Member to join to the balancer
+        :type member: :class:`Member`
 
-        @return: Member after joining the balancer.
-        @rtype: L{Member}
+        :return: Member after joining the balancer.
+        :rtype: :class:`Member`
         """
 
         raise NotImplementedError(
@@ -236,14 +235,14 @@ class Driver(BaseDriver):
         """
         Detach member from balancer
 
-        @param balancer: LoadBalancer which should be used
-        @type  balancer: L{LoadBalancer}
+        :param balancer: LoadBalancer which should be used
+        :type  balancer: :class:`LoadBalancer`
 
-        @param member: Member which should be used
-        @type member: L{Member}
+        :param member: Member which should be used
+        :type member: :class:`Member`
 
-        @return: True if member detach was successful, otherwise False
-        @rtype: C{bool}
+        :return: ``True`` if member detach was successful, otherwise ``False``.
+        :rtype: ``bool``
         """
 
         raise NotImplementedError(
@@ -253,10 +252,10 @@ class Driver(BaseDriver):
         """
         Return list of members attached to balancer
 
-        @param balancer: LoadBalancer which should be used
-        @type  balancer: L{LoadBalancer}
+        :param balancer: LoadBalancer which should be used
+        :type  balancer: :class:`LoadBalancer`
 
-        @rtype: C{list} of L{Member}
+        :rtype: ``list`` of :class:`Member`
         """
 
         raise NotImplementedError(
@@ -264,7 +263,12 @@ class Driver(BaseDriver):
 
     def _value_to_algorithm(self, value):
         """
-        Return C{LBAlgorithm} based on the value.
+        Return :class`Algorithm` based on the value.
+
+        :param value: Algorithm name (e.g. http, tcp, ...).
+        :type  value: ``str``
+
+        @rype :class:`Algorithm`
         """
         try:
             return self._VALUE_TO_ALGORITHM_MAP[value]
@@ -274,7 +278,12 @@ class Driver(BaseDriver):
 
     def _algorithm_to_value(self, algorithm):
         """
-        Return value based in the algorithm (C{LBAlgorithm}).
+        Return string value for the provided algorithm.
+
+        :param value: Algorithm enum.
+        :type  value: :class:`Algorithm`
+
+        @rype ``str``
         """
         try:
             return self._ALGORITHM_TO_VALUE_MAP[algorithm]
@@ -286,6 +295,6 @@ class Driver(BaseDriver):
         """
         Return algorithms supported by this driver.
 
-        @rtype: C{list} of C{str}
+        :rtype: ``list`` of ``str``
         """
         return list(self._ALGORITHM_TO_VALUE_MAP.keys())