napalm-automation-community / napalm-ros

MikroTik RouterOS NAPALM driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_ntp_servers method returns an empty dict

EugeneDimitrov opened this issue · comments

Description of Issue/Question

Got empty dict after get_ntp_server method execution, although on the device I have two ntp servers configured.

Setup

I use napalm-os library with ansible napalm plugin. Here it is playbook that I'm using:

---
- name: Get facts
  hosts: routeros

  tasks:
  - napalm_get_facts:
      hostname={{ ansible_host }}
      username={{ ansible_user }}
      dev_os=ros
      password={{ ansible_ssh_pass }}
      filter='facts,ntp_servers'
    register: facts

  - debug:
      var: facts

napalm-ros version

napalm-ros==0.4.1

ROS version

 #   NAME                                                              VERSION                                                              SCHEDULED              
 0   routeros-x86                                                      6.45.6                                                                                      
 1   system                                                            6.45.6                                                                                      
 2 X ipv6                                                              6.45.6                                                                                      
 3   ups                                                               6.45.6                                                                                      
 4   wireless                                                          6.45.6                                                                                      
 5   hotspot                                                           6.45.6                                                                                      
 6   mpls                                                              6.45.6                                                                                      
 7   routing                                                           6.45.6                                                                                      
 8   ppp                                                               6.45.6                                                                                      
 9   dhcp                                                              6.45.6                                                                                      
10   security                                                          6.45.6                                                                                      
11   advanced-tools                                                    6.45.6                                                                                      
12   dude                                                              6.45.6                                                                                      

Steps to Reproduce the Issue

On mikrotik device:

[admin@spoke3-r1] > system ntp export 
/system ntp client
set enabled=yes primary-ntp=172.16.0.1 secondary-ntp=172.16.0.2

result of ansible-playbook get-facts.yml below:

ok: [spoke3-r1] => {
    "facts": {
        "ansible_facts": {
            "napalm_facts": {
                "fqdn": "",
                "hostname": "spoke3-r1",
                "interface_list": [
                    "Loopback0",
                    "Tunnel102",
                    "Tunnel202",
                    "ether1",
                    "ether2",
                    "ether2.112",
                    "ether3",
                    "ether4"
                ],
                "model": "CHR",
                "os_version": "6.45.6 (stable)",
                "serial_number": "",
                "uptime": 4982,
                "vendor": "MikroTik"
            },
            "napalm_fqdn": "",
            "napalm_hostname": "spoke3-r1",
            "napalm_interface_list": [
                "Loopback0",
                "Tunnel102",
                "Tunnel202",
                "ether1",
                "ether2",
                "ether2.112",
                "ether3",
                "ether4"
            ],
            "napalm_model": "CHR",
            "napalm_ntp_servers": {
                "": {}
            },
            "napalm_os_version": "6.45.6 (stable)",
            "napalm_serial_number": "",
            "napalm_uptime": 4982,
            "napalm_vendor": "MikroTik"
        },
        "changed": false,
        "failed": false
    }
}

Error Traceback

Napalm returns an empty data:

            "napalm_ntp_servers": {
                "": {}
            },

Hi.

Thx for this report. It is caused by getting ntp servers from server-dns-names field without primary-ntp, secondary-ntp. This needs to be fixed.