Skip to content

Commit

Permalink
Add function for lookups host by ip
Browse files Browse the repository at this point in the history
Add function for lookups host by ip
  • Loading branch information
Vatson112 authored Oct 22, 2021
1 parent 03b27e9 commit 5af9a6b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pypureomapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,25 @@ def lookup_host(self, name):
return dict(ip=res["ip-address"], mac=res["hardware-address"], hostname=res["name"].decode('utf-8'))
except KeyError:
raise OmapiErrorAttributeNotFound()

def lookup_host_by_ip(self, ip):
"""Look for a host object with given ip address and return the
name, mac, and ip address
@type ip: str
@rtype: dict or None
@raises ValueError:
@raises OmapiError:
@raises OmapiErrorNotFound: if no host object with the given name could be found
@raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks ip, mac or name
@raises socket.error:
"""
res = self.lookup_by_host(ip=ip)
try:
return dict(ip=res["ip-address"], mac=res["hardware-address"], hostname=res["name"].decode('utf-8'))
except KeyError:
raise OmapiErrorAttributeNotFound()

def lookup_host_host(self, mac):
"""Look for a host object with given mac address and return the
name, mac, and ip address
Expand Down

0 comments on commit 5af9a6b

Please sign in to comment.