diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py index bf21705..86cc9b5 100644 --- a/fuel_agent/drivers/nailgun.py +++ b/fuel_agent/drivers/nailgun.py @@ -13,6 +13,7 @@ # limitations under the License. import math +import os from fuel_agent.drivers import ks_spaces_validator from fuel_agent import errors @@ -21,6 +22,8 @@ from fuel_agent.openstack.common import log as logging from fuel_agent.utils import hardware_utils as hu from fuel_agent.utils import utils +from six.moves.urllib.parse import urljoin +from six.moves.urllib.parse import urlparse import yaml LOG = logging.getLogger(__name__) @@ -363,8 +366,10 @@ class Nailgun(object): # Also, the initial data source should be set to sort out chicken/egg # problem. Command line option may be useful for such a case. # BUG: https://bugs.launchpad.net/fuel/+bug/1430418 - metadata_url = data['ks_meta']['image_data']['/']['uri'].\ - split('.')[0] + '.yaml' + root_uri = data['ks_meta']['image_data']['/']['uri'] + filename = os.path.basename(urlparse(root_uri).path).split('.')[0] + \ + '.yaml' + metadata_url = urljoin(root_uri, filename) image_meta = {} raw_image_meta = None try: diff --git a/fuel_agent/tests/test_nailgun.py b/fuel_agent/tests/test_nailgun.py index 6da5a6e..e1dc7f6 100644 --- a/fuel_agent/tests/test_nailgun.py +++ b/fuel_agent/tests/test_nailgun.py @@ -90,7 +90,7 @@ PROVISION_SAMPLE_DATA = { "gw": "10.20.0.1", "image_data": { "/": { - "uri": "http://fake_image_url", + "uri": "http://fake.host.org:123/imgs/fake_image.img.gz", "format": "ext4", "container": "gzip" } @@ -618,6 +618,8 @@ class TestNailgun(test_base.BaseTestCase): mock_lbd.return_value = LIST_BLOCK_DEVICES_SAMPLE p_scheme = self.drv.partition_scheme() i_scheme = self.drv.image_scheme(p_scheme) + mock_http_req.assert_called_once_with( + 'http://fake.host.org:123/imgs/fake_image.yaml') expected_images = [] for fs in p_scheme.fss: if fs.mount not in PROVISION_SAMPLE_DATA['ks_meta']['image_data']: