def take_action(self, parsed_args): self.log.debug('take_action({})'.format(parsed_args)) self.log.warning('This command is deprecated. Please use "openstack ' 'overcloud roles show" instead.') roles_path = os.path.realpath(parsed_args.roles_path) role_name = parsed_args.role file_path = os.path.join(roles_path, '{}.yaml'.format(role_name)) try: with open(file_path, 'r') as f: role = rolesutils.validate_role_yaml(f) except IOError: raise NotFound("Role '{}' not found. Use 'openstack overcloud " "roles list' to see the available roles.". format(parsed_args.role)) if 'name' in role: print('#' * 79) print("# Role Data for '{}'".format(role['name'])) print('#' * 79) for key in sorted(role.keys()): print("{}:".format(key), end='') value = role[key] if isinstance(value, (list, tuple)): print('') print('\n'.join([' * {0}'.format(v) for v in value])) else: print(" '{}'".format(value))
def check_role_exists(available_roles, requested_roles): """Performs a check on the requested roles to ensure they exist :param available_roles list of available role names :param requested_roles list of requested role names :exception NotFound if a role in the requested list is not available """ unique_roles = list(set([r.split(':')[0] for r in requested_roles])) role_check = set(unique_roles) - set(available_roles) if len(role_check) > 0: msg = "Invalid roles requested: {}\nValid Roles:\n{}".format( ','.join(role_check), '\n'.join(available_roles)) raise NotFound(msg)