Fix the anaconda deploy for the ISO mounted

Fix the anaconda deploy for the ISO mounted
on a webserver.

Story: 2010322
Task: 46429
Change-Id: I2860faa7322116ffef1255709fe12f806257b069
This commit is contained in:
Nisha Agarwal 2022-09-27 12:04:55 +00:00
parent bb6662f1ef
commit ca54c4df26
3 changed files with 22 additions and 12 deletions

View File

@ -657,10 +657,24 @@ def is_source_a_path(ctx, image_source):
# NOTE(TheJulia): I don't really like this pattern, *but*
# the wholedisk image support is similar.
return
# NOTE(TheJulia): Files should have been caught almost exclusively
# before with the Content-Length check.
# When the ISO is mounted and the webserver mount point url is
# checked here, it has both 'Content-Length' and 'Content-Type'
# due to which it always returns False. Hence switched the conditions.
if ('Content-Type' in headers
and str(headers['Content-Type']).startswith('text/html')):
LOG.debug('Evaluated %(url)s to determine if it is a URL to a path '
'or a file. A Content-Type header was returned with a text '
'content, which suggests a file list was returned.',
{'url': image_source})
return True
# When issuing a head request, folders have no length
# A list can be generated by the server.. This is a solid
# hint.
if 'Content-Length' in headers:
if ('Content-Type' in headers
and (str(headers['Content-Type']) != 'text/html')
and 'Content-Length' in headers):
LOG.debug('Evaluated %(url)s to determine if it is a URL to a path '
'or a file. A Content-Length header was returned '
'suggesting file.',
@ -668,16 +682,6 @@ def is_source_a_path(ctx, image_source):
# NOTE(TheJulia): Files on a webserver have a length which is returned
# when headres are queried.
return False
if ('Content-Type' in headers
and str(headers['Content-Type']).startswith('text')
and 'Content-Length' not in headers):
LOG.debug('Evaluated %(url)s to determine if it is a URL to a path '
'or a file. A Content-Type header was returned with a text '
'content, which suggests a file list was returned.',
{'url': image_source})
return True
# NOTE(TheJulia): Files should have been caught almost exclusively
# before with the Content-Length check.
if image_source.endswith('/'):
# If all else fails, looks like a URL, and the server didn't give
# us any hints.

View File

@ -318,7 +318,8 @@ class IronicImagesTestCase(base.TestCase):
autospec=True)
def test_is_source_a_path_content_length(self, validate_mock):
mock_response = mock.Mock()
mock_response.headers = {'Content-Length': 1}
mock_response.headers = {'Content-Length': 1,
'Content-Type': 'text/plain'}
validate_mock.return_value = mock_response
self.assertFalse(images.is_source_a_path('context', 'http://foo/bar/'))
validate_mock.assert_called_once_with(mock.ANY, 'http://foo/bar/')

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes the URL based anaconda deployment for parsing the given ``image_source``
url.