f3749ca3f9
Adds the functionality to redeploy a server in an unguarded fashion, meaning that the server will not be pre-validated to be in a state that workloads have been removed. This is the first targeted action for Shipyard, so a refactoring of the validators to support more flexibility has been done. Also adds RBAC controls for specific actions being created, rather than a binary create action privilege. Change-Id: I39e3dab6595c5187affb9f2b6edadd0f5f925b0c
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
|
|
#
|
|
# 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.
|
|
import logging
|
|
|
|
import falcon
|
|
|
|
from shipyard_airflow.errors import ApiError
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class ValidateIntermediateCommit:
|
|
"""Validtor to ensure that intermediate commits are not present
|
|
|
|
If allow_intermediate_commits is set on the action, this validator will
|
|
not check.
|
|
"""
|
|
def __init__(self, action, configdocs_helper):
|
|
self.action = action
|
|
self.configdocs_helper = configdocs_helper
|
|
|
|
def validate(self):
|
|
if self.action.get('allow_intermediate_commits'):
|
|
LOG.debug("Intermediate commit check skipped due to user input")
|
|
else:
|
|
intermediate_commits = (
|
|
self.configdocs_helper.check_intermediate_commit())
|
|
if intermediate_commits:
|
|
raise ApiError(
|
|
title='Intermediate commit detected',
|
|
description=(
|
|
'The current committed revision of documents has '
|
|
'other prior commits that have not been used as '
|
|
'part of a site action, e.g. update_site. If you '
|
|
'are aware and these other commits are intended, '
|
|
'please rerun this action with the option '
|
|
'`allow-intermediate-commits=True`'),
|
|
status=falcon.HTTP_409,
|
|
retry=False
|
|
)
|