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 2019/10/12 19:48:27 UTC
[libcloud] 02/05: More async additions
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit b98cc6a99f344ff1bee7ece7ad5071320ae4c9ec
Author: Rob Zimmerman <ro...@thezims.net>
AuthorDate: Thu Oct 10 13:16:55 2019 -0400
More async additions
Adding async options for node start/stop operations.
---
libcloud/compute/drivers/gce.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index f2e9fd6..ec68303 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -6726,34 +6726,49 @@ class GCENodeDriver(NodeDriver):
self.connection.async_request(request, method='POST', data=body)
return True
- def ex_start_node(self, node):
+ def ex_start_node(self, node, sync=True):
"""
Start a node that is stopped and in TERMINATED state.
:param node: Node object to start
:type node: :class:`Node`
+ :keyword sync: If true, do not return until destroyed or timeout
+ :type sync: ``bool``
+
:return: True if successful
:rtype: ``bool``
"""
request = '/zones/%s/instances/%s/start' % (node.extra['zone'].name,
node.name)
- self.connection.async_request(request, method='POST')
+
+ if sync:
+ self.connection.async_request(request, method='POST')
+ else:
+ self.connection.request(request, method='POST')
+
return True
- def ex_stop_node(self, node):
+ def ex_stop_node(self, node, sync=True):
"""
Stop a running node.
:param node: Node object to stop
:type node: :class:`Node`
+ :keyword sync: If true, do not return until destroyed or timeout
+ :type sync: ``bool``
+
:return: True if successful
:rtype: ``bool``
"""
request = '/zones/%s/instances/%s/stop' % (node.extra['zone'].name,
node.name)
- self.connection.async_request(request, method='POST')
+ if sync:
+ self.connection.async_request(request, method='POST')
+ else:
+ self.connection.request(request, method='POST')
+
return True
def ex_destroy_instancegroupmanager(self, manager):