Skip to content

Commit

Permalink
Move add_host function to other add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusb committed Feb 11, 2019
1 parent 3686ec9 commit 3ef8ad1
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions pypureomapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,25 +1072,6 @@ def initialize_authenticator(self, authenticator):
self.protocol.defauth = authid
logger.debug("successfully initialized default authid %d", authid)

def add_host(self, ip, mac):
"""Create a host object with given ip address and and mac address.
@type ip: str
@type mac: str
@raises ValueError:
@raises OmapiError:
@raises socket.error:
"""
msg = OmapiMessage.open(b"host")
msg.message.append((b"create", struct.pack("!I", 1)))
msg.message.append((b"exclusive", struct.pack("!I", 1)))
msg.obj.append((b"hardware-address", pack_mac(mac)))
msg.obj.append((b"hardware-type", struct.pack("!I", 1)))
msg.obj.append((b"ip-address", pack_ip(ip)))
response = self.query_server(msg)
if response.opcode != OMAPI_OP_UPDATE:
raise OmapiError("add failed")

def del_host(self, mac):
"""Delete a host object with with given mac address.
Expand Down Expand Up @@ -1265,6 +1246,25 @@ def __lookup(self, ltype, **kwargs):
res[_k] = v
return res

def add_host(self, ip, mac):
"""Create a host object with given ip address and and mac address.
@type ip: str
@type mac: str
@raises ValueError:
@raises OmapiError:
@raises socket.error:
"""
msg = OmapiMessage.open(b"host")
msg.message.append((b"create", struct.pack("!I", 1)))
msg.message.append((b"exclusive", struct.pack("!I", 1)))
msg.obj.append((b"hardware-address", pack_mac(mac)))
msg.obj.append((b"hardware-type", struct.pack("!I", 1)))
msg.obj.append((b"ip-address", pack_ip(ip)))
response = self.query_server(msg)
if response.opcode != OMAPI_OP_UPDATE:
raise OmapiError("add failed")

def add_host_supersede_name(self, ip, mac, name): # pylint:disable=E0213
"""Add a host with a fixed-address and override its hostname with the given name.
@type self: Omapi
Expand Down

0 comments on commit 3ef8ad1

Please sign in to comment.