libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbe...@apache.org
Subject svn commit: r1238107 - in /libcloud/trunk: CHANGES libcloud/compute/drivers/opennebula.py test/compute/fixtures/opennebula_3_2/compute_5.xml test/compute/test_opennebula.py
Date Tue, 31 Jan 2012 00:28:01 GMT
Author: hbetts
Date: Tue Jan 31 00:28:00 2012
New Revision: 1238107

URL: http://svn.apache.org/viewvc?rev=1238107&view=rev
Log:
Added reboot_node to the OpenNebula v3.2 compute driver.

Added:
    libcloud/trunk/test/compute/fixtures/opennebula_3_2/compute_5.xml
Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/compute/drivers/opennebula.py
    libcloud/trunk/test/compute/test_opennebula.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1238107&r1=1238106&r2=1238107&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Tue Jan 31 00:28:00 2012
@@ -38,6 +38,9 @@ Changes with Apache Libcloud in developm
        ; LIBCLOUD-138
        [Shawn Smith]
 
+     - Enable reboot_node method in the OpenNebula 3.2 driver.
+       [Hutson Betts]
+
   *) Storage:
 
     - Propagate extra keyword arguments passed to the Rackspace driver

Modified: libcloud/trunk/libcloud/compute/drivers/opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/opennebula.py?rev=1238107&r1=1238106&r2=1238107&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/opennebula.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/opennebula.py Tue Jan 31 00:28:00 2012
@@ -55,33 +55,62 @@ DEFAULT_API_VERSION = '3.2'
 
 
 class ACTION(object):
-    # The VM is stopped, and its memory state stored to a checkpoint file.
-    # VM state, and disk image, has been transferred back to the front-end.
-    # Resuming the VM requires the VM instance to be re-scheduled.
+    """
+    All actions, except RESUME, only apply when the VM is in the "Running"
+    state.
+    """
+
     STOP = 'STOPPED'
+    """
+    The VM is stopped, and its memory state stored to a checkpoint file. VM
+    state, and disk image, are transferred back to the front-end. Resuming
+    the VM requires the VM instance to be re-scheduled.
+    """
 
-    # The VM is stopped, and its memory state stored to a checkpoint file.
-    # The VM state, and disk image, are left on the host to later resume the
-    # VM there. Resuming the VM does not require the VM to be re-scheduled.
-    # Rather, after suspending, the VM resources are reserved for later
-    # resuming.
     SUSPEND = 'SUSPENDED'
+    """
+    The VM is stopped, and its memory state stored to a checkpoint file. The VM
+    state, and disk image, are left on the host to be resumed later. Resuming
+    the VM does not require the VM to be re-scheduled. Rather, after
+    suspending, the VM resources are reserved for later resuming.
+    """
 
-    # The VM is resumed using the saved memory state from the checkpoint file,
-    # and the VM's disk image. The VM is either started immediately, or
-    # re-scheduled depending on how it was suspended.
     RESUME = 'RESUME'
+    """
+    The VM is resumed using the saved memory state from the checkpoint file,
+    and the VM's disk image. The VM is either started immediately, or
+    re-scheduled depending on how it was suspended.
+    """
 
-    # The VM is forcibly shutdown, its memory state and disk image are deleted.
     CANCEL = 'CANCEL'
+    """
+    The VM is forcibly shutdown, its memory state is deleted. If a persistent
+    disk image was used, that disk image is transferred back to the front-end.
+    Any non-persistent disk images are deleted.
+    """
 
-    # The VM is gracefully shutdown by sending the ACPI signal. If the VM does
-    # not shutdown, then it is considered to still be running. If successfully,
-    # shutdown, its memory state and disk image are deleted.
     SHUTDOWN = 'SHUTDOWN'
+    """
+    The VM is gracefully shutdown by sending the ACPI signal. If the VM does
+    not shutdown, then it is considered to still be running. If successfully,
+    shutdown, its memory state is deleted. If a persistent disk image was used,
+    that disk image is transferred back to the front-end. Any non-persistent
+    disk images are deleted.
+    """
+
+    REBOOT = 'REBOOT'
+    """
+    Introduced in OpenNebula v3.2.
+
+    The VM is gracefully restarted by sending the ACPI signal.
+    """
 
-    # The VM is forcibly shutdown, its memory state and disk image are deleted.
     DONE = 'DONE'
+    """
+    The VM is forcibly shutdown, its memory state is deleted. If a persistent
+    disk image was used, that disk image is transferred back to the front-end.
+    Any non-persistent disk images are deleted.
+    """
 
 
 class OpenNebulaResponse(XmlResponse):
@@ -960,6 +989,9 @@ class OpenNebula_3_2_NodeDriver(OpenNebu
     OpenNebula.org node driver for OpenNebula.org v3.2.
     """
 
+    def reboot_node(self, node):
+        return self.ex_node_action(node, ACTION.REBOOT)
+
     def list_sizes(self, location=None):
         """
         Return list of sizes on a provider.

Added: libcloud/trunk/test/compute/fixtures/opennebula_3_2/compute_5.xml
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/fixtures/opennebula_3_2/compute_5.xml?rev=1238107&view=auto
==============================================================================
--- libcloud/trunk/test/compute/fixtures/opennebula_3_2/compute_5.xml (added)
+++ libcloud/trunk/test/compute/fixtures/opennebula_3_2/compute_5.xml Tue Jan 31 00:28:00
2012
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<COMPUTE href='http://www.opennebula.org/compute/5'>
+    <ID>5</ID>
+    <NAME>Compute 5</NAME>
+    <INSTANCE_TYPE>small</INSTANCE_TYPE>
+    <STATE>RUNNING</STATE>
+    <DISK>
+        <STORAGE href='http://www.opennebula.org/storage/5' name='Ubuntu 9.04 LAMP'/>
+        <TYPE>DISK</TYPE>
+        <TARGET>hda</TARGET>
+    </DISK>
+    <NIC>
+        <NETWORK href='http://www.opennebula.org/network/5' name='Network 5'/>
+        <IP>192.168.0.1</IP>
+        <MAC>02:00:c0:a8:00:01</MAC>
+    </NIC>
+    <NIC>
+        <NETWORK href='http://www.opennebula.org/network/15' name='Network 15'/>
+        <IP>192.168.1.1</IP>
+        <MAC>02:00:c0:a8:01:01</MAC>
+    </NIC>
+    <CONTEXT>
+        <HOSTNAME>compute-5</HOSTNAME>
+    </CONTEXT>
+</COMPUTE>

Modified: libcloud/trunk/test/compute/test_opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_opennebula.py?rev=1238107&r1=1238106&r2=1238107&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_opennebula.py (original)
+++ libcloud/trunk/test/compute/test_opennebula.py Tue Jan 31 00:28:00 2012
@@ -566,6 +566,15 @@ class OpenNebula_3_2_Tests(unittest.Test
             OpenNebula_3_2_MockHttp, OpenNebula_3_2_MockHttp)
         self.driver = OpenNebulaNodeDriver(*OPENNEBULA_PARAMS + ('3.2',))
 
+    def test_reboot_node(self):
+        """
+        Test reboot_node functionality.
+        """
+        image = NodeImage(id=5, name='Ubuntu 9.04 LAMP', driver=self.driver)
+        node = Node(5, None, None, None, None, self.driver, image=image)
+        ret = self.driver.reboot_node(node)
+        self.assertTrue(ret)
+
     def test_list_sizes(self):
         """
         Test ex_list_networks functionality.
@@ -951,6 +960,24 @@ class OpenNebula_3_2_MockHttp(OpenNebula
 
     fixtures_3_2 = ComputeFileFixtures('opennebula_3_2')
 
+    def _compute_5(self, method, url, body, headers):
+        """
+        Compute entry resource.
+        """
+        if method == 'GET':
+            body = self.fixtures.load('compute_5.xml')
+            return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+        if method == 'PUT':
+            body = ""
+            return (httplib.ACCEPTED, body, {},
+                    httplib.responses[httplib.ACCEPTED])
+
+        if method == 'DELETE':
+            body = ""
+            return (httplib.NO_CONTENT, body, {},
+                    httplib.responses[httplib.NO_CONTENT])
+
     def _instance_type(self, method, url, body, headers):
         """
         Instance type pool.



Mime
View raw message