Repository: apache/libcloud (language: python)

Issue:
KeyError in OVH driver
Using latest libcloud 3.3.1 on Centos 8.3

While resizing an OVH instance I ran **wait_until_running** and gave a **KeyError** for key **RESIZE**

  File "/usr/local/lib/python3.8/site-packages/libcloud/compute/base.py", line 1679, in wait_until_running
    all_nodes = self.list_nodes(**ex_list_nodes_kwargs)
  File "/usr/local/lib/python3.8/site-packages/libcloud/compute/drivers/ovh.py", line 98, in list_nodes
    return self._to_nodes(response.object)
  File "/usr/local/lib/python3.8/site-packages/libcloud/compute/drivers/ovh.py", line 506, in _to_nodes
    return [self._to_node(obj) for obj in objs]
  File "/usr/local/lib/python3.8/site-packages/libcloud/compute/drivers/ovh.py", line 506, in <listcomp>
    return [self._to_node(obj) for obj in objs]
  File "/usr/local/lib/python3.8/site-packages/libcloud/compute/drivers/ovh.py", line 501, in _to_node
    state=self.NODE_STATE_MAP[obj['status']],
KeyError: 'RESIZE'


Discussion / hints:
@robjuffermans Thanks for reporting this.

Please feel free to open a PR with the fix - should be straight forward, just need to update state map + add test for it.

Fix patch:
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 9e5505c4cc..2ab51d947a 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -120,6 +120,7 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
         'PASSWORD': NodeState.PENDING,
         'RESCUE': NodeState.PENDING,
         'REBOOT': NodeState.REBOOTING,
+        'RESIZE': NodeState.MIGRATING,
         'HARD_REBOOT': NodeState.REBOOTING,
         'SHARE_IP': NodeState.PENDING,
         'SHARE_IP_NO_CONFIG': NodeState.PENDING,


Test patch:
diff --git a/libcloud/test/compute/test_ovh.py b/libcloud/test/compute/test_ovh.py
index f79c2b79d8..c8b7eae9e1 100644
--- a/libcloud/test/compute/test_ovh.py
+++ b/libcloud/test/compute/test_ovh.py
@@ -231,6 +231,9 @@ def test_create_node(self):
                                        location=location)
         self.assertEqual(node.name, 'test_vm')
 
+    def test_resizing_node(self):
+        assert self.driver.NODE_STATE_MAP['RESIZE']
+
     def test_destroy_node(self):
         node = self.driver.list_nodes()[0]
         self.driver.destroy_node(node)