Skip to content

Commit

Permalink
check_feature_template: allow relaxed check of template existence
Browse files Browse the repository at this point in the history
When config option relaxed_feature_template_check is true
(default: false), only display a warning if the template existence
cannot be assessed rather than raising an exception. This allows
to support direct use of features defined in the plenary templates
(e.g. features from the template library).

Contributes to quattor#111

Change-Id: I0b3319cd39a2c962da0464c511a2c42de2595407
  • Loading branch information
jouvin authored and Aquilon main user committed Nov 2, 2018
1 parent 3b3d87a commit 1c54b7e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions etc/aqd.conf.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ gzip_output = false
transparent_gzip = true
template_extension = .tpl
object_declarations_template = false
# When true, only display a warning if a feature template doesn't
# exist in a domain Git repository
relaxed_feature_template_check = False

[tool_timeout]
# If set to True, timeout will be set to 'default_value' for any tools run via subprocess
Expand Down
2 changes: 1 addition & 1 deletion lib/aquilon/worker/commands/bind_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def do_link(self, session, logger, dbfeature, params):
q = q.filter(or_(*filters))

for dbdomain in q:
check_feature_template(self.config, dbarchetype, dbfeature,
check_feature_template(self.config, logger, dbarchetype, dbfeature,
dbdomain)

add_link(session, logger, dbfeature, params)
2 changes: 1 addition & 1 deletion lib/aquilon/worker/commands/manage_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def render(self, session, logger, plenaries, domain, sandbox, force,

for dbarch, featureset in features.items():
for dbfeature in featureset:
check_feature_template(self.config, dbarch, dbfeature,
check_feature_template(self.config, logger, dbarch, dbfeature,
dbbranch)

for dbobj in objects:
Expand Down
11 changes: 7 additions & 4 deletions lib/aquilon/worker/dbwrappers/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from aquilon.worker.templates import PlenaryHost, PlenaryPersonality
from aquilon.worker.templates.domain import template_branch_basedir


def add_link(session, logger, dbfeature, params):
FeatureLink.get_unique(session, feature=dbfeature, preclude=True,
**params)
Expand Down Expand Up @@ -59,7 +58,7 @@ def add_link(session, logger, dbfeature, params):
dbfeature.links.append(FeatureLink(**params))


def check_feature_template(config, dbarchetype, dbfeature, dbdomain):
def check_feature_template(config, logger, dbarchetype, dbfeature, dbdomain):
basedir = template_branch_basedir(config, dbdomain)
# Features can be defined either in the archetype directory or as
# features shared by all the archetypes if they are defined in basedir
Expand All @@ -73,8 +72,12 @@ def check_feature_template(config, dbarchetype, dbfeature, dbdomain):
if os.path.exists("{}/config.{}" .format(feature_dir, ext)):
return

raise ArgumentError("{0} does not have templates present in {1:l} "
"for {2:l}.".format(dbfeature, dbdomain, dbarchetype))
if config.getboolean("panc", "relaxed_feature_template_check"):
logger.client_info("WARNING: {0} templates not present in {1:l} for {2:l} "
"(assumed to be present in plenary templates).".format(dbfeature, dbdomain, dbarchetype))
else:
raise ArgumentError("{0} does not have templates present in {1:l} "
"for {2:l}.".format(dbfeature, dbdomain, dbarchetype))


def get_affected_plenaries(session, dbfeature, plenaries,
Expand Down
2 changes: 1 addition & 1 deletion lib/aquilon/worker/dbwrappers/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_host(session, logger, config, dbhw, dbarchetype, domain=None,
pre, post = host_features(dbstage)
hw_features = hardware_features(dbstage, dbhw.model)
for dbfeature in pre | post | hw_features:
check_feature_template(config, dbarchetype, dbfeature, dbbranch)
check_feature_template(config, logger, dbarchetype, dbfeature, dbbranch)

if not osname:
if config.has_option(section, "default_osname"):
Expand Down

0 comments on commit 1c54b7e

Please sign in to comment.