Esempio n. 1
0
def _update_hosts(server, remove, add, modify):
    """Update the hosts using the OMAPI."""
    omapi_client = OmapiClient(server.omapi_key, server.ipv6)
    try:
        for host in remove:
            omapi_client.del_host(host["mac"])
    except OmapiError as e:
        raise CannotRemoveHostMap(str(e))
    try:
        for host in add:
            omapi_client.add_host(host["mac"], host["ip"])
    except OmapiError as e:
        raise CannotCreateHostMap(str(e))
    try:
        for host in modify:
            omapi_client.update_host(host["mac"], host["ip"])
    except OmapiError as e:
        raise CannotModifyHostMap(str(e))
Esempio n. 2
0
 def test_add_host(self):
     cli = OmapiClient("shared-key")
     cli.add_host("aa:bb:cc:dd:ee:ff", "1.2.3.4")
     self.mock_omapi_cli.add_host_supersede.assert_called_once_with(
         "1.2.3.4", "aa:bb:cc:dd:ee:ff", b"aa-bb-cc-dd-ee-ff"
     )