Added Rules as a more fine grained inspections
This commit is contained in:
parent
b8426b0871
commit
e448620c77
@ -1,4 +1,7 @@
|
|||||||
import copy
|
import copy
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
from recordtype import recordtype
|
||||||
|
|
||||||
|
|
||||||
def find(l, predicate):
|
def find(l, predicate):
|
||||||
@ -24,7 +27,7 @@ def all_subclasses(klass):
|
|||||||
|
|
||||||
def path_relative_to(path, base_path):
|
def path_relative_to(path, base_path):
|
||||||
if not path.startswith('/'):
|
if not path.startswith('/'):
|
||||||
path = os.path.join(base_path, paste_config_path)
|
path = os.path.join(base_path, path)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@ -178,11 +181,21 @@ class MarkedIssue(Issue):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Rule = recordtype('Rule', ['name', 'description'])
|
||||||
|
|
||||||
|
|
||||||
class Inspection(object):
|
class Inspection(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def all_inspections(klass):
|
def all_inspections(klass):
|
||||||
return [c for c in all_subclasses(klass)]
|
return [c for c in all_subclasses(klass)]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def rules(klass):
|
||||||
|
if hasattr(klass, 'name') and hasattr(klass, 'description'):
|
||||||
|
return [Rule(klass.name, klass.description)]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
def inspect(self, openstack):
|
def inspect(self, openstack):
|
||||||
pass
|
pass
|
||||||
|
@ -1,15 +1,26 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import lettuce
|
import lettuce
|
||||||
|
import lettuce.fs
|
||||||
|
|
||||||
from ostack_validator.common import Inspection, Issue
|
from ostack_validator.common import Inspection, Rule, Issue
|
||||||
|
|
||||||
|
|
||||||
class LettuceRunnerInspection(Inspection):
|
class LettuceRunnerInspection(Inspection):
|
||||||
|
base_path = os.path.join(os.path.dirname(__file__), 'lettuce')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def rules(klass):
|
||||||
|
rules = []
|
||||||
|
|
||||||
|
loader = lettuce.fs.FeatureLoader(klass.base_path)
|
||||||
|
for path in loader.find_feature_files():
|
||||||
|
feature = lettuce.Feature.from_file(path)
|
||||||
|
for scenario in feature.scenarios:
|
||||||
|
rules.append(Rule(scenario.name,
|
||||||
|
"\n".join(scenario.remaining_lines)))
|
||||||
|
|
||||||
def inspect(self, openstack):
|
def inspect(self, openstack):
|
||||||
runner = lettuce.Runner(
|
runner = lettuce.Runner(base_path=self.base_path)
|
||||||
base_path=os.path.join(os.path.dirname(__file__), 'lettuce')
|
|
||||||
)
|
|
||||||
|
|
||||||
lettuce.world.openstack = openstack
|
lettuce.world.openstack = openstack
|
||||||
result = runner.run()
|
result = runner.run()
|
||||||
|
@ -10,3 +10,4 @@ honcho==0.4.2
|
|||||||
jinja2==2.7
|
jinja2==2.7
|
||||||
lettuce>=0.2.19
|
lettuce>=0.2.19
|
||||||
pymongo==2.6.1
|
pymongo==2.6.1
|
||||||
|
recordtype==1.1
|
||||||
|
47
webui.py
47
webui.py
@ -8,17 +8,16 @@ from wtforms import StringField, TextAreaField, SubmitField, SelectMultipleField
|
|||||||
from wtforms.validators import DataRequired
|
from wtforms.validators import DataRequired
|
||||||
import wtforms_json
|
import wtforms_json
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
from recordtype import recordtype
|
||||||
|
|
||||||
from ostack_validator.celery import app as celery, ostack_inspect_task, InspectionRequest
|
from ostack_validator.celery import app as celery, ostack_inspect_task, InspectionRequest
|
||||||
from ostack_validator.common import Issue, MarkedIssue
|
from ostack_validator.common import Inspection, Issue, MarkedIssue
|
||||||
from ostack_validator.model import Openstack
|
from ostack_validator.model import Openstack
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='config-validator-ui-concept', static_url_path='/static')
|
app = Flask(__name__,
|
||||||
|
static_folder='config-validator-ui-concept',
|
||||||
|
static_url_path='/static')
|
||||||
Bootstrap(app)
|
Bootstrap(app)
|
||||||
app.debug = True
|
|
||||||
app.config.update(
|
|
||||||
WTF_CSRF_SECRET_KEY='foo bar baz'
|
|
||||||
)
|
|
||||||
app.secret_key = 'A0Zr98j/3fooN]LWX/,?RT'
|
app.secret_key = 'A0Zr98j/3fooN]LWX/,?RT'
|
||||||
|
|
||||||
wtforms_json.init()
|
wtforms_json.init()
|
||||||
@ -160,6 +159,7 @@ def to_label(s):
|
|||||||
def index():
|
def index():
|
||||||
return send_file(os.path.join(app.static_folder, 'index.html'))
|
return send_file(os.path.join(app.static_folder, 'index.html'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/clusters')
|
@app.route('/clusters')
|
||||||
def get_clusters():
|
def get_clusters():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
@ -182,24 +182,27 @@ def add_cluster():
|
|||||||
|
|
||||||
@app.route('/rules')
|
@app.route('/rules')
|
||||||
def get_rules():
|
def get_rules():
|
||||||
db = get_db()
|
rules = []
|
||||||
rules = [Rule.from_doc(doc) for doc in db['rules'].find()]
|
for inspection in Inspection.all_inspections():
|
||||||
rules = [
|
rules.extend(inspection.rules())
|
||||||
Rule('rule1', RuleGroup.VALIDITY, 'Nova has proper Keystone host',
|
|
||||||
"""Given I use OpenStack Grizzly 2013.1
|
# rules = [Rule.from_doc(doc) for doc in db['rules'].find()]
|
||||||
And Nova has "auth_strategy" equal to "keystone"
|
# rules = [
|
||||||
And Keystone addresses are @X
|
# Rule(id='rule1', group=RuleGroup.VALIDITY,
|
||||||
Then Nova should have "keystone_authtoken.auth_host" in "$X" """
|
# name='Nova has proper Keystone host',
|
||||||
),
|
# description="""Given I use OpenStack Grizzly 2013.1
|
||||||
Rule('rule1', RuleGroup.VALIDITY, 'Nova has proper Keystone host',
|
# And Nova has "auth_strategy" equal to "keystone"
|
||||||
"""Given I use OpenStack Grizzly 2013.1
|
# And Keystone addresses are @X
|
||||||
And Nova has "auth_strategy" equal to "keystone"
|
# Then Nova should have "keystone_authtoken.auth_host" in "$X" """),
|
||||||
And Keystone addresses are @X
|
# Rule(id='rule1', group=RuleGroup.VALIDITY,
|
||||||
Then Nova should have "keystone_authtoken.auth_host" in "$X" """
|
# name='Nova has proper Keystone host',
|
||||||
)
|
# description="""Given I use OpenStack Grizzly 2013.1
|
||||||
]
|
# And Nova has "auth_strategy" equal to "keystone"
|
||||||
|
# And Keystone addresses are @X
|
||||||
|
# Then Nova should have "keystone_authtoken.auth_host" in "$X" """)]
|
||||||
return json.dumps(rules)
|
return json.dumps(rules)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/rules/<group>')
|
@app.route('/rules/<group>')
|
||||||
def get_rules_group(group):
|
def get_rules_group(group):
|
||||||
if not group in RuleGroup.all:
|
if not group in RuleGroup.all:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user