From 59e766b3fd02f419af07a9ff85fcafbee1e6b9d5 Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Thu, 12 Dec 2019 15:09:46 +0000 Subject: [PATCH] Fix use of urlparse.urljoin This method only joins the first two parameters, the 3rd parameter is a bool "allow_fragments". Passing in "object_name" as the third param resulted in it getting lost. Use os.path.join instead. Change-Id: I49506b2671465bf43ae346225919d4a0e6767b20 --- ironic/drivers/modules/redfish/boot.py | 2 +- ironic/tests/unit/drivers/modules/redfish/test_boot.py | 4 ++-- releasenotes/notes/fix-path-a3a0cfd2c135ace9.yaml | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-path-a3a0cfd2c135ace9.yaml diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 608975ff87..726c213d4f 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -291,7 +291,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): shutil.copyfile(image_file, published_file) - image_url = urlparse.urljoin( + image_url = os.path.join( CONF.deploy.http_url, cls.IMAGE_SUBDIR, object_name) image_url = cls._append_filename_param( diff --git a/ironic/tests/unit/drivers/modules/redfish/test_boot.py b/ironic/tests/unit/drivers/modules/redfish/test_boot.py index 4b3cba2dad..4068e90e6f 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_boot.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_boot.py @@ -250,7 +250,7 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase): url = task.driver.boot._publish_image('file.iso', 'boot.iso') self.assertEqual( - 'http://localhost/redfish?filename=file.iso', url) + 'http://localhost/redfish/boot.iso?filename=file.iso', url) mock_mkdir.assert_called_once_with('/httpboot/redfish', 0x755) mock_link.assert_called_once_with( @@ -272,7 +272,7 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase): url = task.driver.boot._publish_image('file.iso', 'boot.iso') self.assertEqual( - 'http://localhost/redfish?filename=file.iso', url) + 'http://localhost/redfish/boot.iso?filename=file.iso', url) mock_mkdir.assert_called_once_with('/httpboot/redfish', 0x755) diff --git a/releasenotes/notes/fix-path-a3a0cfd2c135ace9.yaml b/releasenotes/notes/fix-path-a3a0cfd2c135ace9.yaml new file mode 100644 index 0000000000..1f524bca07 --- /dev/null +++ b/releasenotes/notes/fix-path-a3a0cfd2c135ace9.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix path used to virtual media iso, when served over + local HTTP server([redfish]use_swift=false).