Returns the device which has a specific ip If the ip is not found returns an empty string
(ip)
| 144 | |
| 145 | |
| 146 | def get_device(ip): |
| 147 | """ Returns the device which has a specific ip |
| 148 | If the ip is not found returns an empty string |
| 149 | """ |
| 150 | for i in execute("ip addr show"): |
| 151 | vals = i.strip().lstrip().rstrip().split() |
| 152 | if vals[0] == "inet": |
| 153 | if vals[1].split('/')[0] == ip: |
| 154 | return vals[-1] |
| 155 | return "" |
| 156 | |
| 157 | |
| 158 | def get_ip(device): |