feat(api): policy enforcement and api standard

- enhanced logging
- created base structure
- updated docs
- PasteDeploy auth
- Oslo Policy

Closes #107

Change-Id: I805863c57f17fcfb26dac5d03efb165e4be49a4e
This commit is contained in:
gardlt
2017-09-12 03:11:57 +00:00
parent d5f4378731
commit bb26131ce2
33 changed files with 883 additions and 365 deletions

View File

@@ -1,13 +0,0 @@
# Copyright 2017 The Armada Authors.
#
# 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.

View File

@@ -15,7 +15,6 @@
import difflib
import yaml
from oslo_config import cfg
from oslo_log import log as logging
from supermutes.dot import dotify
@@ -37,7 +36,6 @@ from ..const import KEYWORD_ARMADA, KEYWORD_GROUPS, KEYWORD_CHARTS,\
LOG = logging.getLogger(__name__)
DEFAULT_TIMEOUT = 3600
CONF = cfg.CONF
class Armada(object):
@@ -183,6 +181,12 @@ class Armada(object):
Syncronize Helm with the Armada Config(s)
'''
msg = {
'installed': [],
'upgraded': [],
'diff': []
}
# TODO: (gardlt) we need to break up this func into
# a more cleaner format
LOG.info("Performing Pre-Flight Operations")
@@ -268,9 +272,9 @@ class Armada(object):
# TODO(alanmeadows) account for .files differences
# once we support those
upgrade_diff = self.show_diff(chart, apply_chart,
apply_values,
chartbuilder.dump(), values)
upgrade_diff = self.show_diff(
chart, apply_chart, apply_values, chartbuilder.dump(),
values, msg)
if not upgrade_diff:
LOG.info("There are no updates found in this chart")
@@ -290,6 +294,8 @@ class Armada(object):
wait=chart_wait,
timeout=chart_timeout)
msg['upgraded'].append(prefix_chart)
# process install
else:
LOG.info("Installing release %s", chart.release)
@@ -301,6 +307,8 @@ class Armada(object):
wait=chart_wait,
timeout=chart_timeout)
msg['installed'].append(prefix_chart)
LOG.debug("Cleaning up chart source in %s",
chartbuilder.source_directory)
@@ -322,6 +330,8 @@ class Armada(object):
self.tiller.chart_cleanup(
prefix, self.config[KEYWORD_ARMADA][KEYWORD_GROUPS])
return msg
def post_flight_ops(self):
'''
Operations to run after deployment process has terminated
@@ -333,7 +343,7 @@ class Armada(object):
source.source_cleanup(ch.get('chart').get('source_dir')[0])
def show_diff(self, chart, installed_chart, installed_values, target_chart,
target_values):
target_values, msg):
'''
Produce a unified diff of the installed chart vs our intention
@@ -342,19 +352,32 @@ class Armada(object):
'''
chart_diff = list(
difflib.unified_diff(installed_chart.SerializeToString()
.split('\n'), target_chart.split('\n')))
difflib.unified_diff(
installed_chart.SerializeToString().split('\n'),
target_chart.split('\n')))
if len(chart_diff) > 0:
LOG.info("Chart Unified Diff (%s)", chart.release)
diff_msg = []
for line in chart_diff:
diff_msg.append(line)
LOG.debug(line)
msg['diff'].append({'chart': diff_msg})
values_diff = list(
difflib.unified_diff(
installed_values.split('\n'),
yaml.safe_dump(target_values).split('\n')))
if len(values_diff) > 0:
LOG.info("Values Unified Diff (%s)", chart.release)
diff_msg = []
for line in values_diff:
diff_msg.append(line)
LOG.debug(line)
msg['diff'].append({'values': diff_msg})
return (len(chart_diff) > 0) or (len(values_diff) > 0)
result = (len(chart_diff) > 0) or (len(values_diff) > 0)
return result