| 1 |
from jnpr.junos.exception import RpcError |
| 2 |
|
| 3 |
|
| 4 |
def provides_facts(): |
| 5 |
""" |
| 6 |
Returns a dictionary keyed on the facts provided by this module. The value |
| 7 |
of each key is the doc string describing the fact. |
| 8 |
""" |
| 9 |
return { |
| 10 |
"_is_linux": "A boolean indicating if the device is running linux" "kernel.", |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
def get_facts(device): |
| 15 |
""" |
| 16 |
Gathers the _is_linux fact using the <file-show/> RPC on the EVO version file. |
| 17 |
""" |
| 18 |
|
| 19 |
# Temporary implementation until PR 1245634 is implemented. |
| 20 |
LINUX_VERSION_PATH = "/usr/share/cevo/cevo_version" |
| 21 |
|
| 22 |
is_linux = None |
| 23 |
|
| 24 |
try: |
| 25 |
rsp = device.rpc.file_show(normalize=True, filename=LINUX_VERSION_PATH) |
| 26 |
if rsp.tag == "file-content": |
| 27 |
is_linux = True |
| 28 |
else: |
| 29 |
is_linux = False |
| 30 |
except RpcError: |
| 31 |
is_linux = False |
| 32 |
return { |
| 33 |
"_is_linux": is_linux, |
| 34 |
} |