| 1 |
def provides_facts(): |
| 2 |
""" |
| 3 |
Returns a dictionary keyed on the facts provided by this module. The value |
| 4 |
of each key is the doc string describing the fact. |
| 5 |
""" |
| 6 |
return { |
| 7 |
"HOME": "A string indicating the home directory of the current " "user.", |
| 8 |
} |
| 9 |
|
| 10 |
|
| 11 |
def get_facts(device): |
| 12 |
""" |
| 13 |
Gathers facts from the <file-list/> RPC. |
| 14 |
""" |
| 15 |
home = None |
| 16 |
rsp = device.rpc.file_list(normalize=True, path="~") |
| 17 |
if rsp.tag == "directory-list": |
| 18 |
dir_list_element = rsp |
| 19 |
else: |
| 20 |
dir_list_element = rsp.find(".//directory-list") |
| 21 |
if dir_list_element is not None: |
| 22 |
home = dir_list_element.get("root-path") |
| 23 |
if home is not None: |
| 24 |
home = home.rstrip("/") |
| 25 |
return { |
| 26 |
"HOME": home, |
| 27 |
} |