Add validation on role names

Also, fixes role templates that weren't passing this new validation.

Closes-bug: #1756346

Change-Id: I387386a0d7cf47fe11f24a68b9f2bb2ee2f0b7bd
This commit is contained in:
Dan Prince 2018-03-16 10:12:48 -04:00 committed by Emilien Macchi
parent 1bec57e977
commit 3b56c9e501
3 changed files with 16 additions and 4 deletions

View File

@ -1,7 +1,7 @@
###############################################################################
# Role: Controller #
# Role: ControllerStorageNfs #
###############################################################################
- name: Controller
- name: ControllerStorageNfs
description: |
Controller role that has all the controler services loaded and handles
Database, Messaging and Network functions.

View File

@ -1,7 +1,7 @@
###############################################################################
# Role: Undercloud #
# Role: UndercloudLight #
###############################################################################
- name: Undercloud
- name: UndercloudLight
description: |
EXPERIMENTAL. A role to deploy the minimal undercloud for pre-provisioned
deployed servers via heat using the 'openstack undercloud deploy' command.

View File

@ -245,6 +245,15 @@ def validate_endpoint_map(base_map, env_map):
return sorted(base_map.keys()) == sorted(env_map.keys())
def validate_role_name(filename):
role_data = yaml.load(open(filename).read())[0]
if role_data['name'] != os.path.basename(filename).split('.')[0]:
print('ERROR: role name should match file name for role : %s.'
% filename)
return 1
return 0
def validate_hci_compute_services_default(env_filename, env_tpl):
env_services_list = env_tpl['parameter_defaults']['ComputeServices']
env_services_list.remove('OS::TripleO::Services::CephOSD')
@ -931,6 +940,9 @@ def validate(filename, param_map):
if filename.endswith('hyperconverged-ceph.yaml'):
retval |= validate_hci_compute_services_default(filename, tpl)
if filename.startswith('./roles/'):
retval = validate_role_name(filename)
if filename.startswith('./roles/ComputeHCI.yaml'):
retval |= validate_hci_computehci_role(filename, tpl)