Ensure a value is set in an OpenStack configuration file.

    filename
        The full path to the configuration file

    section
        The section in which the parameter will be set

    parameter (optional)
        The parameter to change.  If the parameter is not supplied, the name will be used as the parameter.

    value
        The value to set

def present(name, filename, section, value, parameter=None):
    '''
    Ensure a value is set in an OpenStack configuration file.

    filename
        The full path to the configuration file

    section
        The section in which the parameter will be set

    parameter (optional)
        The parameter to change.  If the parameter is not supplied, the name will be used as the parameter.

    value
        The value to set

    '''

    if parameter is None:
        parameter = name

    ret = {'name': name,
           'changes': {},
           'result': False,
           'comment': ''}

    try:
        old_value = __salt__['openstack_config.get'](filename=filename,
                                                     section=section,
                                                     parameter=parameter)

        if old_value == value:
            ret['result'] = True
            ret['comment'] = 'The value is already set to the correct value'
            return ret

        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = 'Value \'{0}\' is set to be changed to \'{1}\'.'.format(
                old_value,
                value
            )
            return ret

    except CommandExecutionError as err:
        if not six.text_type(err).lower().startswith('parameter not found:'):
            raise

    __salt__['openstack_config.set'](filename=filename,
                                     section=section,
                                     parameter=parameter,
                                     value=value)

    ret['changes'] = {'Value': 'Updated'}
    ret['result'] = True
    ret['comment'] = 'The value has been updated'

    return ret