Merge pull request #428 from yarda/syspurpose-fix
recommend: do not ignore syspurpose_role if there is no syspurpose
This commit is contained in:
commit
70732a5796
1 changed files with 8 additions and 5 deletions
|
|
@ -56,6 +56,7 @@ class ProfileRecommender:
|
|||
|
||||
def process_config(self, fname, has_root=True):
|
||||
matching_profile = None
|
||||
syspurpose_error_logged = False
|
||||
try:
|
||||
if not os.path.isfile(fname):
|
||||
return None
|
||||
|
|
@ -97,11 +98,11 @@ class ProfileRecommender:
|
|||
if not re.match(value, chassis_type, re.IGNORECASE):
|
||||
match = False
|
||||
elif option == "syspurpose_role":
|
||||
role = ""
|
||||
if have_syspurpose:
|
||||
s = syspurpose.files.SyspurposeStore(
|
||||
syspurpose.files.USER_SYSPURPOSE,
|
||||
raise_on_error = True)
|
||||
role = ""
|
||||
try:
|
||||
s.read_file()
|
||||
role = s.contents["role"]
|
||||
|
|
@ -109,11 +110,13 @@ class ProfileRecommender:
|
|||
if hasattr(e, "errno") and e.errno != errno.ENOENT:
|
||||
log.error("Failed to load the syspurpose\
|
||||
file: %s" % e)
|
||||
if re.match(value, role, re.IGNORECASE) is None:
|
||||
match = False
|
||||
else:
|
||||
log.error("Failed to process 'syspurpose_role' in '%s'\
|
||||
, the syspurpose module is not available" % fname)
|
||||
if not syspurpose_error_logged:
|
||||
log.error("Failed to process 'syspurpose_role' in '%s'\
|
||||
, the syspurpose module is not available" % fname)
|
||||
syspurpose_error_logged = True
|
||||
if re.match(value, role, re.IGNORECASE) is None:
|
||||
match = False
|
||||
|
||||
if match:
|
||||
# remove the ",.*" suffix
|
||||
|
|
|
|||
Loading…
Reference in a new issue