Return first ip on an interface
(device)
| 156 | |
| 157 | |
| 158 | def get_ip(device): |
| 159 | """ Return first ip on an interface """ |
| 160 | cmd = "ip addr show dev %s" % device |
| 161 | for i in execute(cmd): |
| 162 | vals = i.lstrip().split() |
| 163 | if (vals[0] == 'inet'): |
| 164 | return vals[1] |
| 165 | return "" |
| 166 | |
| 167 | |
| 168 | def definedinfile(filename, val): |