libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/2] git commit: Add `ex_set_volume_auto_delete` to the GCE driver.
Date Fri, 21 Mar 2014 09:15:13 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 0117a3d93 -> 428e14823


Add `ex_set_volume_auto_delete` to the GCE driver.

Sets the auto-delete flag for a volume attached to a node.

Signed-off-by: Tomaz Muraus <tomaz@apache.org>


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

Branch: refs/heads/trunk
Commit: 55ee06248481ed0304881747009172913a001f63
Parents: 0117a3d
Author: Franck Cuny <franck.cuny@gmail.com>
Authored: Thu Mar 13 21:36:58 2014 -0700
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Fri Mar 21 10:08:33 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/gce.py                 | 27 ++++++++++++++++++++
 ...a_instances_node_name_setDiskAutoDelete.json | 16 ++++++++++++
 ...operations_operation_volume_auto_delete.json | 16 ++++++++++++
 libcloud/test/compute/test_gce.py               | 19 ++++++++++++++
 4 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/55ee0624/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index c3c00d4..abe264e 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -1868,6 +1868,33 @@ class GCENodeDriver(NodeDriver):
                                       data='ignored')
         return True
 
+    def ex_set_volume_auto_delete(self, volume, node, auto_delete=True):
+        """
+        Sets the auto-delete flag for a volume attached to a node.
+
+        :param  volume: Volume object to auto-delete
+        :type   volume: :class:`StorageVolume`
+
+        :param   ex_node: Node object to auto-delete volume from
+        :type    ex_node: :class:`Node`
+
+        :keyword auto_delete: Flag to set for the auto-delete value
+        :type    auto_delete: ``bool`` (default True)
+
+        :return:  True if successfull
+        :rtype:   ``bool``
+        """
+        request = '/zones/%s/instances/%s/setDiskAutoDelete' % (
+            node.extra['zone'].name, node.name
+        )
+        delete_params = {
+            'deviceName': volume,
+            'autoDelete': auto_delete,
+        }
+        self.connection.async_request(request, method='POST',
+                                      params=delete_params)
+        return True
+
     def ex_destroy_address(self, address):
         """
         Destroy a static address.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/55ee0624/libcloud/test/compute/fixtures/gce/zones_us_central1_a_instances_node_name_setDiskAutoDelete.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/zones_us_central1_a_instances_node_name_setDiskAutoDelete.json
b/libcloud/test/compute/fixtures/gce/zones_us_central1_a_instances_node_name_setDiskAutoDelete.json
new file mode 100644
index 0000000..4087a42
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/zones_us_central1_a_instances_node_name_setDiskAutoDelete.json
@@ -0,0 +1,16 @@
+{
+ "kind": "compute#operation",
+ "id": "14265294323024381703",
+ "name": "operation-volume-auto-delete",
+ "zone": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a",
+ "operationType": "setDiskAutoDelete",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/instances/dev-test",
+ "targetId": "4313186599918690450",
+ "status": "PENDING",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 0,
+ "insertTime": "2014-03-13T21:50:57.612-07:00",
+ "startTime": "2014-03-13T21:50:57.717-07:00",
+ "endTime": "2014-03-13T21:50:58.047-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/operations/operation-volume-auto-delete"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/55ee0624/libcloud/test/compute/fixtures/gce/zones_us_central1_a_operations_operation_volume_auto_delete.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/zones_us_central1_a_operations_operation_volume_auto_delete.json
b/libcloud/test/compute/fixtures/gce/zones_us_central1_a_operations_operation_volume_auto_delete.json
new file mode 100644
index 0000000..dc8231c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/zones_us_central1_a_operations_operation_volume_auto_delete.json
@@ -0,0 +1,16 @@
+{
+ "kind": "compute#operation",
+ "id": "14265294323024381703",
+ "name": "operation-volume-auto-delete",
+ "zone": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a",
+ "operationType": "setDiskAutoDelete",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/instances/dev-test",
+ "targetId": "4313186599918690450",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2014-03-13T21:50:57.612-07:00",
+ "startTime": "2014-03-13T21:50:57.717-07:00",
+ "endTime": "2014-03-13T21:50:58.047-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/operations/operation-volume-auto-delete"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/55ee0624/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index a24be1d..91fd9d7 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -464,6 +464,13 @@ class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
         destroyed = disk.destroy()
         self.assertTrue(destroyed)
 
+    def test_ex_set_volume_auto_delete(self):
+        node = self.driver.ex_get_node('node-name')
+        volume = node.extra['boot_disk']
+        auto_delete = self.driver.ex_set_volume_auto_delete(
+            volume, node)
+        self.assertTrue(auto_delete)
+
     def test_destroy_volume_snapshot(self):
         snapshot = self.driver.ex_get_snapshot('lcsnapshot')
         destroyed = snapshot.destroy()
@@ -876,6 +883,18 @@ class GCEMockHttp(MockHttpTestCase):
             'operations_operation_zones_us-central1-a_disks_lcdisk_delete.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _zones_us_central1_a_instances_node_name_setDiskAutoDelete(
+            self, method, url, body, headers):
+        body = self.fixtures.load(
+            'zones_us_central1_a_instances_node_name_setDiskAutoDelete.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
+    def _zones_us_central1_a_operations_operation_volume_auto_delete(
+            self, method, url, body, headers):
+        body = self.fixtures.load(
+            'zones_us_central1_a_operations_operation_volume_auto_delete.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _zones_us_central1_a_operations_operation_zones_us_central1_a_disks_lcdisk_createSnapshot_post(
             self, method, url, body, headers):
         body = self.fixtures.load(


Mime
View raw message