Cleanup basic import tasks

Fix inconsistency in the way parameters were being passed
around the tasks.  It was preventing them from working
reliably.

Co-authored-by: Abhishek Kekane <akekane@redhat.com>
Co-authored-by: Brian Rosmaita <rosmaita.fossdev@gmail.com>

Closes-bug: #1749461
Change-Id: I05b5fe8d99cc0f8edd89c707fd030f5bf762fe06
This commit is contained in:
Abhishek Kekane 2018-02-14 08:09:57 +00:00 committed by Brian Rosmaita
parent 418488ff2d
commit 0b22c77ab3
4 changed files with 10 additions and 5 deletions

View File

@ -22,9 +22,9 @@ CONF = cfg.CONF
def get_import_plugin(**kwargs):
method_list = CONF.enabled_import_methods
import_method = kwargs.get('import_req')['method']['name'].replace("-",
"_")
import_method = kwargs.get('import_req')['method']['name']
if import_method in method_list:
import_method = import_method.replace("-", "_")
task_list = [import_method]
# TODO(jokke): Implement error handling of non-listed methods.
extensions = named.NamedExtensionManager(

View File

@ -33,10 +33,10 @@ class _WebDownload(task.Task):
default_provides = 'file_uri'
def __init__(self, task_id, task_type, task_repo, image_id, uri):
def __init__(self, task_id, task_type, image_repo, image_id, uri):
self.task_id = task_id
self.task_type = task_type
self.task_repo = task_repo
self.image_repo = image_repo
self.image_id = image_id
self.uri = uri
super(_WebDownload, self).__init__(

View File

@ -371,11 +371,15 @@ def get_flow(**kwargs):
flow = lf.Flow(task_type, retry=retry.AlwaysRevert())
if uri.startswith("http") and import_method == 'web-download':
if import_method == 'web-download':
downloadToStaging = internal_plugins.get_import_plugin(**kwargs)
flow.add(downloadToStaging)
if not CONF.node_staging_uri.endswith('/'):
separator = '/'
file_uri = separator.join((CONF.node_staging_uri, str(image_id)))
else:
file_uri = uri
flow.add(_VerifyStaging(task_id, task_type, task_repo, file_uri))
for plugin in import_plugins.get_import_plugins(**kwargs):

View File

@ -128,6 +128,7 @@ class TaskExecutor(glance.async.TaskExecutor):
kwds['uri'] = uri
if task.type == 'api_image_import':
kwds['image_id'] = task_input['image_id']
kwds['import_req'] = task_input['import_req']
return driver.DriverManager('glance.flows', task.type,
invoke_on_load=True,
invoke_kwds=kwds).driver