'Get hwtacacs server configure ipv4'

def get_hwtacacs_server_cfg_ipv4(self, **kwargs):

    module = kwargs['module']
    hwtacacs_template = module.params['hwtacacs_template']
    hwtacacs_server_ip = module.params['hwtacacs_server_ip']
    hwtacacs_server_type = module.params['hwtacacs_server_type']
    hwtacacs_is_secondary_server = module.params['hwtacacs_is_secondary_server']
    hwtacacs_vpn_name = module.params['hwtacacs_vpn_name']
    hwtacacs_is_public_net = module.params['hwtacacs_is_public_net']
    state = module.params['state']
    result = dict()
    result['hwtacacs_server_cfg_ipv4'] = []
    need_cfg = False
    conf_str = (CE_GET_HWTACACS_SERVER_CFG_IPV4 % hwtacacs_template)
    recv_xml = self.netconf_get_config(module=module, conf_str=conf_str)
    if ('<data/>' in recv_xml):
        if (state == 'present'):
            need_cfg = True
    else:
        xml_str = recv_xml.replace('\r', '').replace('\n', '').replace('xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"', '').replace('xmlns="http://www.huawei.com/netconf/vrp"', '')
        root = ElementTree.fromstring(xml_str)
        hwtacacs_server_cfg_ipv4 = root.findall('data/hwtacacs/hwTacTempCfgs/hwTacTempCfg/hwTacSrvCfgs/hwTacSrvCfg')
        if hwtacacs_server_cfg_ipv4:
            for tmp in hwtacacs_server_cfg_ipv4:
                tmp_dict = dict()
                for site in tmp:
                    if (site.tag in ['serverIpAddress', 'serverType', 'isSecondaryServer', 'isPublicNet', 'vpnName']):
                        tmp_dict[site.tag] = site.text
                result['hwtacacs_server_cfg_ipv4'].append(tmp_dict)
        if result['hwtacacs_server_cfg_ipv4']:
            for tmp in result['hwtacacs_server_cfg_ipv4']:
                if ('serverIpAddress' in tmp.keys()):
                    if (state == 'present'):
                        if (tmp['serverIpAddress'] != hwtacacs_server_ip):
                            need_cfg = True
                    elif (tmp['serverIpAddress'] == hwtacacs_server_ip):
                        need_cfg = True
                if ('serverType' in tmp.keys()):
                    if (state == 'present'):
                        if (tmp['serverType'] != hwtacacs_server_type):
                            need_cfg = True
                    elif (tmp['serverType'] == hwtacacs_server_type):
                        need_cfg = True
                if ('isSecondaryServer' in tmp.keys()):
                    if (state == 'present'):
                        if (tmp['isSecondaryServer'] != str(hwtacacs_is_secondary_server).lower()):
                            need_cfg = True
                    elif (tmp['isSecondaryServer'] == str(hwtacacs_is_secondary_server).lower()):
                        need_cfg = True
                if ('isPublicNet' in tmp.keys()):
                    if (state == 'present'):
                        if (tmp['isPublicNet'] != str(hwtacacs_is_public_net).lower()):
                            need_cfg = True
                    elif (tmp['isPublicNet'] == str(hwtacacs_is_public_net).lower()):
                        need_cfg = True
                if ('vpnName' in tmp.keys()):
                    if (state == 'present'):
                        if (tmp['vpnName'] != hwtacacs_vpn_name):
                            need_cfg = True
                    elif (tmp['vpnName'] == hwtacacs_vpn_name):
                        need_cfg = True
    result['need_cfg'] = need_cfg
    return result
