Add fallback ubuntu image location
This commit is contained in:
@@ -373,6 +373,10 @@ class TestOpenStackUtils(ut_utils.BaseTestCase):
|
||||
openstack_utils.find_ubuntu_image('bionic', 'aarch64'),
|
||||
('http://cloud-images.ubuntu.com/bionic/current/'
|
||||
'bionic-server-cloudimg-aarch64.img'))
|
||||
self.assertEqual(
|
||||
openstack_utils.find_ubuntu_image('jammy', 'amd64'),
|
||||
('http://cloud-images.ubuntu.com/jammy/current/'
|
||||
'jammy-server-cloudimg-amd64.img'))
|
||||
|
||||
def test_download_image(self):
|
||||
urllib_opener_mock = mock.MagicMock()
|
||||
|
||||
@@ -91,6 +91,8 @@ UBUNTU_IMAGE_URLS = {
|
||||
'{release}-server-cloudimg-{arch}.img'),
|
||||
'focal': ('http://cloud-images.ubuntu.com/{release}/current/'
|
||||
'{release}-server-cloudimg-{arch}.img'),
|
||||
'default': ('http://cloud-images.ubuntu.com/{release}/current/'
|
||||
'{release}-server-cloudimg-{arch}.img'),
|
||||
}
|
||||
|
||||
CHARM_TYPES = {
|
||||
@@ -2299,7 +2301,8 @@ def find_cirros_image(arch):
|
||||
|
||||
def find_ubuntu_image(release, arch):
|
||||
"""Return url for image."""
|
||||
return UBUNTU_IMAGE_URLS[release].format(release=release, arch=arch)
|
||||
loc_str = UBUNTU_IMAGE_URLS.get(release) or UBUNTU_IMAGE_URLS['default']
|
||||
return loc_str.format(release=release, arch=arch)
|
||||
|
||||
|
||||
def download_image(image_url, target_file):
|
||||
|
||||
Reference in New Issue
Block a user