libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [libcloud] 15/21: Fix auto assigning of volume device in OpenStack
Date Sat, 04 Apr 2020 20:45:17 GMT
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch 2.8.x
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit cd263c67d58f6556738e311a93796cf60ce56189
Author: Joshua Hesketh <josh@nitrotech.org>
AuthorDate: Thu Mar 26 22:49:24 2020 +1100

    Fix auto assigning of volume device in OpenStack
    
    When trying to attach a volume to a node with the OpenStack driver, using the 'auto' device
name fails with:
    
    libcloud.common.exceptions.BaseHTTPError: 400 Bad Request Invalid input for field/attribute
device. Value: auto. u'auto' does not match '(^/dev/x{0,1}[a-z]{0,1}d{0,1})([a-z]+)[0-9]*$'
    
    OpenStack expects a device, or a null/None value[0]
    
    https://docs.openstack.org/api-ref/compute/?expanded=#attach-a-volume-to-an-instance
---
 libcloud/compute/drivers/openstack.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index e250b91..343fe50 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -321,6 +321,8 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
     def attach_volume(self, node, volume, device="auto"):
         # when "auto" or None is provided for device, openstack will let
         # the guest OS pick the next available device (fi. /dev/vdb)
+        if device == "auto":
+            device = None
         return self.connection.request(
             '/servers/%s/os-volume_attachments' % node.id,
             method='POST',


Mime
View raw message