Stop falling back to image import
Import needs to always be explicit, because there are too many cases where it doens't work properly. Change-Id: I89dc48bdbb245d83a0c7d4f112f24728232e391c
This commit is contained in:
@@ -289,13 +289,8 @@ class Proxy(_base_proxy.BaseImageProxy):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if not use_import:
|
if not use_import:
|
||||||
try:
|
response = image.upload(self)
|
||||||
response = image.upload(self)
|
exceptions.raise_from_response(response)
|
||||||
exceptions.raise_from_response(response)
|
|
||||||
except Exception:
|
|
||||||
if not supports_import:
|
|
||||||
raise
|
|
||||||
use_import = True
|
|
||||||
if use_import:
|
if use_import:
|
||||||
image.stage(self)
|
image.stage(self)
|
||||||
image.import_image(self)
|
image.import_image(self)
|
||||||
|
@@ -533,89 +533,6 @@ class TestImage(BaseTestImage):
|
|||||||
self.assertEqual(self.adapter.request_history[7].text.read(),
|
self.assertEqual(self.adapter.request_history[7].text.read(),
|
||||||
self.output)
|
self.output)
|
||||||
|
|
||||||
def test_create_image_import_fallback(self):
|
|
||||||
self.cloud.image_api_use_tasks = False
|
|
||||||
|
|
||||||
self.register_uris([
|
|
||||||
dict(method='GET',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images', self.image_name],
|
|
||||||
base_url_append='v2'),
|
|
||||||
status_code=404),
|
|
||||||
dict(method='GET',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images'],
|
|
||||||
base_url_append='v2',
|
|
||||||
qs_elements=['name=' + self.image_name]),
|
|
||||||
validate=dict(),
|
|
||||||
json={'images': []}),
|
|
||||||
dict(method='GET',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images'],
|
|
||||||
base_url_append='v2',
|
|
||||||
qs_elements=['os_hidden=True']),
|
|
||||||
json={'images': []}),
|
|
||||||
dict(method='POST',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images'], base_url_append='v2'),
|
|
||||||
json=self.fake_image_dict,
|
|
||||||
headers={
|
|
||||||
'OpenStack-image-import-methods': IMPORT_METHODS,
|
|
||||||
},
|
|
||||||
validate=dict(
|
|
||||||
json={
|
|
||||||
u'container_format': u'bare',
|
|
||||||
u'disk_format': u'qcow2',
|
|
||||||
u'name': self.image_name,
|
|
||||||
u'owner_specified.openstack.md5':
|
|
||||||
self.fake_image_dict[
|
|
||||||
'owner_specified.openstack.md5'],
|
|
||||||
u'owner_specified.openstack.object': self.object_name,
|
|
||||||
u'owner_specified.openstack.sha256':
|
|
||||||
self.fake_image_dict[
|
|
||||||
'owner_specified.openstack.sha256'],
|
|
||||||
u'visibility': u'private',
|
|
||||||
u'tags': [u'tag1', u'tag2']})
|
|
||||||
),
|
|
||||||
dict(method='PUT',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images', self.image_id, 'file'],
|
|
||||||
base_url_append='v2'),
|
|
||||||
request_headers={'Content-Type': 'application/octet-stream'},
|
|
||||||
status_code=403),
|
|
||||||
dict(method='PUT',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images', self.image_id, 'stage'],
|
|
||||||
base_url_append='v2'),
|
|
||||||
request_headers={'Content-Type': 'application/octet-stream'}),
|
|
||||||
dict(method='POST',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images', self.image_id, 'import'],
|
|
||||||
base_url_append='v2'),
|
|
||||||
json={'method': {'name': 'glance-direct'}}),
|
|
||||||
dict(method='GET',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images', self.fake_image_dict['id']],
|
|
||||||
base_url_append='v2'
|
|
||||||
),
|
|
||||||
json=self.fake_image_dict),
|
|
||||||
dict(method='GET',
|
|
||||||
uri=self.get_mock_url(
|
|
||||||
'image', append=['images'], base_url_append='v2'),
|
|
||||||
complete_qs=True,
|
|
||||||
json=self.fake_search_return)
|
|
||||||
])
|
|
||||||
|
|
||||||
self.cloud.create_image(
|
|
||||||
self.image_name, self.imagefile.name, wait=True, timeout=1,
|
|
||||||
tags=['tag1', 'tag2'],
|
|
||||||
is_public=False, validate_checksum=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assert_calls()
|
|
||||||
self.assertEqual(self.adapter.request_history[7].text.read(),
|
|
||||||
self.output)
|
|
||||||
|
|
||||||
def test_create_image_task(self):
|
def test_create_image_task(self):
|
||||||
self.cloud.image_api_use_tasks = True
|
self.cloud.image_api_use_tasks = True
|
||||||
endpoint = self.cloud._object_store_client.get_endpoint()
|
endpoint = self.cloud._object_store_client.get_endpoint()
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
Image upload will no longer fall back to attempting to use
|
||||||
|
the import workflow if the initial upload does not work.
|
Reference in New Issue
Block a user