'configures bfd session'

def config_session(self):

    xml_str = ''
    cmd_list = list()
    cmd_session = ''
    if (not self.session_name):
        return xml_str
    if (self.bfd_dict['global'].get('bfdEnable', 'false') != 'true'):
        self.module.fail_json(msg='Error:    Please    enable    BFD    globally    first.')
    if (not self.bfd_dict['session']):
        self.module.fail_json(msg='Error:    BFD    session    is    not    exist.')
    session = self.bfd_dict['session']
    xml_str = ('<sessName>%s</sessName>' % self.session_name)
    cmd_session = ('bfd    %s' % self.session_name)
    if (self.local_discr is not None):
        if ((self.state == 'present') and (str(self.local_discr) != session.get('localDiscr'))):
            xml_str += ('<localDiscr>%s</localDiscr>' % self.local_discr)
            cmd_list.append(('discriminator    local    %s' % self.local_discr))
        elif ((self.state == 'absent') and (str(self.local_discr) == session.get('localDiscr'))):
            xml_str += '<localDiscr/>'
            cmd_list.append('undo    discriminator    local')
    if (self.remote_discr is not None):
        if ((self.state == 'present') and (str(self.remote_discr) != session.get('remoteDiscr'))):
            xml_str += ('<remoteDiscr>%s</remoteDiscr>' % self.remote_discr)
            cmd_list.append(('discriminator    remote    %s' % self.remote_discr))
        elif ((self.state == 'absent') and (str(self.remote_discr) == session.get('remoteDiscr'))):
            xml_str += '<remoteDiscr/>'
            cmd_list.append('undo    discriminator    remote')
    if (self.min_tx_interval is not None):
        if ((self.state == 'present') and (str(self.min_tx_interval) != session.get('minTxInt'))):
            xml_str += ('<minTxInt>%s</minTxInt>' % self.min_tx_interval)
            cmd_list.append(('min-tx-interval    %s' % self.min_tx_interval))
        elif ((self.state == 'absent') and (str(self.min_tx_interval) == session.get('minTxInt'))):
            xml_str += '<minTxInt/>'
            cmd_list.append('undo    min-tx-interval')
    if (self.min_rx_interval is not None):
        if ((self.state == 'present') and (str(self.min_rx_interval) != session.get('minRxInt'))):
            xml_str += ('<minRxInt>%s</minRxInt>' % self.min_rx_interval)
            cmd_list.append(('min-rx-interval    %s' % self.min_rx_interval))
        elif ((self.state == 'absent') and (str(self.min_rx_interval) == session.get('minRxInt'))):
            xml_str += '<minRxInt/>'
            cmd_list.append('undo    min-rx-interval')
    if (self.detect_multi is not None):
        if ((self.state == 'present') and (str(self.detect_multi) != session.get('detectMulti'))):
            xml_str += ('    <detectMulti>%s</detectMulti>' % self.detect_multi)
            cmd_list.append(('detect-multiplier    %s' % self.detect_multi))
        elif ((self.state == 'absent') and (str(self.detect_multi) == session.get('detectMulti'))):
            xml_str += '    <detectMulti/>'
            cmd_list.append('undo    detect-multiplier')
    if (self.wtr_interval is not None):
        if ((self.state == 'present') and (str(self.wtr_interval) != session.get('wtrTimerInt'))):
            xml_str += ('    <wtrTimerInt>%s</wtrTimerInt>' % self.wtr_interval)
            cmd_list.append(('wtr    %s' % self.wtr_interval))
        elif ((self.state == 'absent') and (str(self.wtr_interval) == session.get('wtrTimerInt'))):
            xml_str += '    <wtrTimerInt/>'
            cmd_list.append('undo    wtr')
    if (self.tos_exp is not None):
        if ((self.state == 'present') and (str(self.tos_exp) != session.get('tosExp'))):
            xml_str += ('    <tosExp>%s</tosExp>' % self.tos_exp)
            cmd_list.append(('tos-exp    %s' % self.tos_exp))
        elif ((self.state == 'absent') and (str(self.tos_exp) == session.get('tosExp'))):
            xml_str += '    <tosExp/>'
            cmd_list.append('undo    tos-exp')
    if (self.admin_down and (session.get('adminDown', 'false') == 'false')):
        xml_str += '    <adminDown>true</adminDown>'
        cmd_list.append('shutdown')
    elif ((not self.admin_down) and (session.get('adminDown', 'false') == 'true')):
        xml_str += '    <adminDown>false</adminDown>'
        cmd_list.append('undo    shutdown')
    if self.description:
        if ((self.state == 'present') and (self.description != session.get('description'))):
            xml_str += ('<description>%s</description>' % self.description)
            cmd_list.append(('description    %s' % self.description))
        elif ((self.state == 'absent') and (self.description == session.get('description'))):
            xml_str += '<description/>'
            cmd_list.append('undo    description')
    if xml_str.endswith('</sessName>'):
        return ''
    else:
        cmd_list.insert(0, cmd_session)
        self.updates_cmd.extend(cmd_list)
        return (('<bfdCfgSessions><bfdCfgSession    operation="merge">' + xml_str) + '</bfdCfgSession></bfdCfgSessions>')
