8007c2abeb
This change is needed to fix an issue with using proxy domains and downloading job binaries through the ".../data" endpoint. A new function is added to retrieve binaries from swift using the context credentials. The raw data retrievers for swift have been refactored to allow a more modular approach. Changes * adding an option to the raw binary dispatch routine to allow requesting of context authentication * adding a new swift client method to create a connection with an auth token * adding a new binary retriever function to use the context auth token * refactoring the internal swift retrievers module to be more modular * adding tests for all internal swift retrievers * adding a new test suite for binary dispatch Change-Id: I5e3ce1c9b61d4e2043a15702cbcc9225f9924d44 Closes-Bug: 1384889
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
# Copyright (c) 2013 Mirantis Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from sahara import context
|
|
from sahara.service.edp.binary_retrievers import internal_swift as i_swift
|
|
from sahara.service.edp.binary_retrievers import sahara_db as db
|
|
from sahara.swift import utils as su
|
|
|
|
|
|
def get_raw_binary(job_binary, proxy_configs=None, with_context=False):
|
|
'''Get the raw data for a job binary
|
|
|
|
This will retrieve the raw data for a job binary from it's source. In the
|
|
case of Swift based binaries there is a precedence of credentials for
|
|
authenticating the client. Requesting a context based authentication takes
|
|
precendence over proxy user which takes precendence over embedded
|
|
credentials.
|
|
|
|
:param job_binary: The job binary to retrieve
|
|
:param proxy_configs: Proxy user configuration to use as credentials
|
|
:param with_context: Use the current context as credentials
|
|
:returns: The raw data from a job binary
|
|
|
|
'''
|
|
url = job_binary.url
|
|
if url.startswith("internal-db://"):
|
|
res = db.get_raw_data(context.ctx(), job_binary)
|
|
|
|
if url.startswith(su.SWIFT_INTERNAL_PREFIX):
|
|
if with_context:
|
|
res = i_swift.get_raw_data_with_context(job_binary)
|
|
else:
|
|
res = i_swift.get_raw_data(job_binary, proxy_configs)
|
|
|
|
return res
|