You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2021/05/09 17:37:00 UTC

[GitHub] [libcloud] dimgal1 commented on a change in pull request #1558: Updates on CloudSigma driver

dimgal1 commented on a change in pull request #1558:
URL: https://github.com/apache/libcloud/pull/1558#discussion_r628920686



##########
File path: libcloud/compute/drivers/cloudsigma.py
##########
@@ -1194,19 +1207,55 @@ def create_node(self, name, size, image, ex_metadata=None,
 
         return node
 
-    def destroy_node(self, node):
+    def destroy_node(self, node, delete_drives=False):
         """
         Destroy the node and all the associated drives.
 
         :return: ``True`` on success, ``False`` otherwise.
         :rtype: ``bool``
         """
         action = '/servers/%s/' % (node.id)
-        params = {'recurse': 'all_drives'}
+        if delete_drives is True:
+            params = {'recurse': 'all_drives'}
+        else:
+            params = None
         response = self.connection.request(action=action, method='DELETE',
                                            params=params)
         return response.status == httplib.NO_CONTENT
 
+    def reboot_node(self, node):
+        """
+        Reboot a node.
+
+        Because Cloudsigma API does not provide native reboot call,
+        it's emulated using stop and start.
+
+        :param node: Node to reboot.
+        :type node: :class:`libcloud.compute.base.Node`
+        """
+        state = node.state
+
+        if state == NodeState.RUNNING:
+            stopped = self.stop_node(node)
+        else:
+            stopped = True
+
+        if not stopped:
+            raise CloudSigmaException(

Review comment:
       I wasn't sure about this one, I used the return value only because the base `NodeDriver` returns a boolean so I handled the case of False.
   Practically `stopped` was never False, CloudSigma returns 403 status code if the action cannot be done, so an exception is raised or the action is completed and True is returned
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org