Merge "Added option to disable sahara db for storing job binaries."

This commit is contained in:
Jenkins 2016-08-31 15:14:47 +00:00 committed by Gerrit Code Review
commit 5ac3e876c8
3 changed files with 24 additions and 1 deletions

View File

@ -51,7 +51,10 @@ edp_opts = [
default=300,
help='Timeout for canceling job execution (in seconds). '
'Sahara will try to cancel job execution during '
'this time.')
'this time.'),
cfg.BoolOpt('edp_internal_db_enabled',
default=True,
help='Use Sahara internal db to store job binaries.')
]
db_opts = [

View File

@ -14,12 +14,16 @@
# limitations under the License.
from oslo_config import cfg
from oslo_log import log as logging
import sahara.exceptions as e
from sahara.i18n import _LW
import sahara.service.validations.edp.base as b
import sahara.service.validations.edp.job_binary_internal as j_b_i
from sahara.swift import utils as su
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
def check_job_binary(data, **kwargs):
@ -28,6 +32,9 @@ def check_job_binary(data, **kwargs):
if job_binary_url:
if job_binary_url.startswith("internal-db"):
if not j_b_i.is_internal_db_enabled():
LOG.warning(_LW(
'Sahara inernal db is disabled for storing job binaries.'))
internal_uid = job_binary_url.replace(
"internal-db://", '')
b.check_job_binary_internal_exists(internal_uid)

View File

@ -13,12 +13,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_config import cfg
import sahara.exceptions as e
from sahara.i18n import _
from sahara.utils import api_validator as a
CONF = cfg.CONF
def is_internal_db_enabled():
if not CONF.edp_internal_db_enabled:
return False
return True
def check_job_binary_internal(data, **kwargs):
if not is_internal_db_enabled():
raise e.BadJobBinaryInternalException(
_("Sahara internal db is disabled for storing job binaries."))
if not (type(data) is str and len(data) > 0):
raise e.BadJobBinaryInternalException()
if "name" in kwargs: