IBP: fix image metadata uri guessing

By default, fuel-agent tries to guess image metadata uri from root
image uri by substituting its file extension with '.yaml'

Eg.:
if root uri is:
 http://10.20.0.2:8080/targetimages/env_2_ubuntu_1404_amd64.img.gz
so, the guessed metadata uri will be:
 http://10.20.0.2:8080/targetimages/env_2_ubuntu_1404_amd64.yaml

Change-Id: I2ed8a0d7c8585573fd5f5d89093b56173e34829a
Closes-Bug: #1434499
This commit is contained in:
Alexander Gordeev 2015-03-20 14:54:04 +03:00
parent bb88701347
commit bbbcf035ec
2 changed files with 10 additions and 3 deletions

View File

@ -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:

View File

@ -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']: