Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D23D0200D2F for ; Wed, 27 Sep 2017 05:12:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D11371609EA; Wed, 27 Sep 2017 03:12:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 20C701609EC for ; Wed, 27 Sep 2017 05:12:50 +0200 (CEST) Received: (qmail 47892 invoked by uid 500); 27 Sep 2017 03:12:50 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 47446 invoked by uid 500); 27 Sep 2017 03:12:46 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 47435 invoked by uid 99); 27 Sep 2017 03:12:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Sep 2017 03:12:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 90179F5B60; Wed, 27 Sep 2017 03:12:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: quentinp@apache.org To: commits@libcloud.apache.org Date: Wed, 27 Sep 2017 03:12:50 -0000 Message-Id: <85b672f020d548a1a2efd5e836510c36@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/14] libcloud git commit: Docstrings added for public classes archived-at: Wed, 27 Sep 2017 03:12:52 -0000 Docstrings added for public classes Signed-off-by: Quentin Pradet Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/82b5c3cc Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/82b5c3cc Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/82b5c3cc Branch: refs/heads/trunk Commit: 82b5c3cc63e28d7a540974f7bfeb832e4c68d16c Parents: d238e93 Author: Mika Lackman Authored: Sun Sep 24 16:08:31 2017 +0300 Committer: Quentin Pradet Committed: Wed Sep 27 07:04:33 2017 +0400 ---------------------------------------------------------------------- libcloud/common/upcloud.py | 67 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/82b5c3cc/libcloud/common/upcloud.py ---------------------------------------------------------------------- diff --git a/libcloud/common/upcloud.py b/libcloud/common/upcloud.py index cbb2904..a63be08 100644 --- a/libcloud/common/upcloud.py +++ b/libcloud/common/upcloud.py @@ -27,6 +27,27 @@ class UpcloudCreateNodeRequestBody(object): Body of the create_node request Takes the create_node arguments (**kwargs) and constructs the request body + + :param user_id: required for authentication (required) + :type user_id: ``str`` + + :param name: Name of the created server (required) + :type name: ``str`` + + :param size: The size of resources allocated to this node. + :type size: :class:`.NodeSize` + + :param image: OS Image to boot on node. + :type image: :class:`.NodeImage` + + :param location: Which data center to create a node in. If empty, + undefined behavior will be selected. (optional) + :type location: :class:`.NodeLocation` + + :param auth: Initial authentication information for the node + (optional) + :type auth: :class:`.NodeAuthSSHKey` + """ def __init__(self, user_id, name, size, image, location, auth=None): @@ -44,15 +65,26 @@ class UpcloudCreateNodeRequestBody(object): def to_json(self): """ Serializes the body to json + + :return: JSON string + :rtype: ``str`` """ return json.dumps(self.body) class UpcloudNodeDestroyer(object): """ - Destroyes the node. + Helper class for destroying node. Node must be first stopped and then it can be destroyed + + :param upcloud_node_operations: UpcloudNodeOperations instance + :type upcloud_node_operations: :class:`.UpcloudNodeOperations` + + :param sleep_func: Callable function, which sleeps. + Takes int argument to sleep in seconds (optional) + :type sleep_func: ``function`` + """ WAIT_AMOUNT = 2 @@ -64,6 +96,12 @@ class UpcloudNodeDestroyer(object): self._sleep_count = 0 def destroy_node(self, node_id): + """ + Destroys the given node. + + :param node_id: Id of the Node. + :type node_id: ``int`` + """ self._stop_called = False self._sleep_count = 0 return self._do_destroy_node(node_id) @@ -99,11 +137,23 @@ class UpcloudNodeDestroyer(object): class UpcloudNodeOperations(object): + """ + Helper class to start and stop node. + + :param conneciton: Connection instance + :type connection: :class:`.UpcloudConnection` + """ def __init__(self, connection): self.connection = connection def stop_node(self, node_id): + """ + Stops the node + + :param node_id: Id of the Node + :type node_id: ``int`` + """ body = { 'stop_server': { 'stop_type': 'hard' @@ -114,6 +164,15 @@ class UpcloudNodeOperations(object): data=json.dumps(body)) def node_state(self, node_id): + """ + Get the state of the node. + + :param node_id: Id of the Node + :type node_id: ``int`` + + :rtype: ``str`` + """ + action = '1.2/server/{0}'.format(node_id) try: response = self.connection.request(action) @@ -124,6 +183,12 @@ class UpcloudNodeOperations(object): raise def destroy_node(self, node_id): + """ + Destroys the node. + + :param node_id: Id of the Node + :type node_id: ``int`` + """ self.connection.request('1.2/server/{0}'.format(node_id), method='DELETE')