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: LIBCLOUD-505: Added four new calls to support pause/unpause and suspend/resume calls. These calls are supported in the v1.1 of OpenStack and are useful for situations such as performing system maintenance.
Date Sun, 02 Feb 2014 14:44:02 GMT
Updated Branches:
  refs/heads/trunk f7560b202 -> 8eb07e4a1


LIBCLOUD-505: Added four new calls to support pause/unpause and suspend/resume calls. These
calls are supported in the v1.1 of OpenStack and are useful for situations such as performing
system maintenance.

Closes #238.

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/32845769
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/32845769
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/32845769

Branch: refs/heads/trunk
Commit: 32845769c38559557537a27e869af800079c5975
Parents: f7560b2
Author: Chris DeRamus <chris@divvycloud.com>
Authored: Sun Feb 2 08:55:23 2014 -0500
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Sun Feb 2 15:43:26 2014 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py           | 24 ++++++++++
 .../fixtures/openstack_v1.1/_servers_pause.json |  3 ++
 .../openstack_v1.1/_servers_resume.json         |  3 ++
 .../openstack_v1.1/_servers_suspend.json        |  3 ++
 .../openstack_v1.1/_servers_unpause.json        |  3 ++
 libcloud/test/compute/test_openstack.py         | 50 ++++++++++++++++++++
 6 files changed, 86 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/32845769/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 781873c..137dc30 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -2092,6 +2092,30 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
         """
         return node.extra['metadata']
 
+    def ex_pause_node(self, node):
+        uri = '/servers/%s/action' % (node.id)
+        data = {'pause': None}
+        resp = self.connection.request(uri, method='POST', data=data)
+        return resp.status == httplib.ACCEPTED
+
+    def ex_unpause_node(self, node):
+        uri = '/servers/%s/action' % (node.id)
+        data = {'pause': None}
+        resp = self.connection.request(uri, method='POST', data=data)
+        return resp.status == httplib.ACCEPTED
+
+    def ex_suspend_node(self, node):
+        uri = '/servers/%s/action' % (node.id)
+        data = {'suspend': None}
+        resp = self.connection.request(uri, method='POST', data=data)
+        return resp.status == httplib.ACCEPTED
+
+    def ex_resume_node(self, node):
+        uri = '/servers/%s/action' % (node.id)
+        data = {'resume': None}
+        resp = self.connection.request(uri, method='POST', data=data)
+        return resp.status == httplib.ACCEPTED
+
 
 class OpenStack_1_1_FloatingIpPool(object):
     """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/32845769/libcloud/test/compute/fixtures/openstack_v1.1/_servers_pause.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_pause.json b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_pause.json
new file mode 100644
index 0000000..c44ca70
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_pause.json
@@ -0,0 +1,3 @@
+{
+    "pause": null
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/32845769/libcloud/test/compute/fixtures/openstack_v1.1/_servers_resume.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_resume.json b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_resume.json
new file mode 100644
index 0000000..008ff18
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_resume.json
@@ -0,0 +1,3 @@
+{
+    "resume": null
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/32845769/libcloud/test/compute/fixtures/openstack_v1.1/_servers_suspend.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_suspend.json b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_suspend.json
new file mode 100644
index 0000000..7bee702
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_suspend.json
@@ -0,0 +1,3 @@
+{
+    "suspend": null
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/32845769/libcloud/test/compute/fixtures/openstack_v1.1/_servers_unpause.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_unpause.json b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_unpause.json
new file mode 100644
index 0000000..fdc0c41
--- /dev/null
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_unpause.json
@@ -0,0 +1,3 @@
+{
+    "unpause": null
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/32845769/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index 4f59711..0df6dd3 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1492,6 +1492,38 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         self.assertEqual(metadata['My Server Name'], 'Apache1')
         self.assertEqual(len(metadata), 1)
 
+    def test_ex_pause_node(self):
+        node = Node(
+            id='12063', name=None, state=None,
+            public_ips=None, private_ips=None, driver=self.driver,
+        )
+        ret = self.driver.ex_pause_node(node)
+        self.assertTrue(ret is True)
+
+    def test_ex_unpause_node(self):
+        node = Node(
+            id='12063', name=None, state=None,
+            public_ips=None, private_ips=None, driver=self.driver,
+        )
+        ret = self.driver.ex_unpause_node(node)
+        self.assertTrue(ret is True)
+
+    def test_ex_suspend_node(self):
+        node = Node(
+            id='12063', name=None, state=None,
+            public_ips=None, private_ips=None, driver=self.driver,
+        )
+        ret = self.driver.ex_suspend_node(node)
+        self.assertTrue(ret is True)
+
+    def test_ex_resume_node(self):
+        node = Node(
+            id='12063', name=None, state=None,
+            public_ips=None, private_ips=None, driver=self.driver,
+        )
+        ret = self.driver.ex_resume_node(node)
+        self.assertTrue(ret is True)
+
 
 class OpenStack_1_1_FactoryMethodTests(OpenStack_1_1_Tests):
     should_list_locations = False
@@ -1812,6 +1844,24 @@ class OpenStack_1_1_MockHttp(MockHttpTestCase):
             return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])
         raise NotImplementedError()
 
+    def _v1_1_slug_servers_72258_action(self, method, url, body, headers):
+        if method == "POST":
+            body = self.fixtures.load('_servers_suspend.json')
+            return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])
+        else:
+            raise NotImplementedError()
+
+        return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
+
+    def _v1_1_slug_servers_12063_action(self, method, url, body, headers):
+        if method == "POST":
+            body = self.fixtures.load('_servers_unpause.json')
+            return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])
+        else:
+            raise NotImplementedError()
+
+        return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
+
 # This exists because the nova compute url in devstack has v2 in there but the v1.1 fixtures
 # work fine.
 


Mime
View raw message