diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce0fff..8fc8477 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ Infoblox Python API CHANGELOG ============================= +1.4.? +----- + +* [Wei Lei] - Fixed 'lease2fixed' in 'hlinfobolx.py' 1.4.0 ----- diff --git a/infoblox/hlinfoblox.py b/infoblox/hlinfoblox.py index 3ee58ea..114708a 100644 --- a/infoblox/hlinfoblox.py +++ b/infoblox/hlinfoblox.py @@ -5,7 +5,7 @@ # License stuff # -from .infoblox import Infoblox, InfobloxGeneralException +from .infoblox import Infoblox, InfobloxGeneralException, Util # import more stuff @@ -79,28 +79,33 @@ def convert_lease_to_fixed_address(self, address, fqdn=None, if not names: self._create_host_record(address, fqdn, mac) - + + print("this-is-fqdn [%s]" % fqdn) + print("this-is-names [%s]" % names) # If we found names associated with the address then # we can use those names to find record:host objects # and convert them to fixed. for name in names: print("Host Name [%s]" % (name)) host_record = self.api.get_host(name, notFoundFail=False) - if host_record is None: - print(" Cannot find record:host for [%s]" % (name)) - self._create_host_record(address, fqdn, mac) + a_record = self.api.get_a_record_by_ip(address) + print("Host Record [%s]" % (host_record)) + print("A record [%s]" % (a_record)) + if host_record is None and a_record is None: + print(" Cannot find record:host or a:record for [%s], exit" % (name)) + # self._create_host_record(address, fqdn, mac) else: - print(" HOST Record [%s]" % (host_record)) print(" Converting lease to fixedaddress") - for host_host_ipv4addr in host_record['ipv4addrs']: - fields = { - 'configure_for_dhcp': True, - 'match_client': 'MAC_ADDRESS', - 'mac': mac - } - self.api.update_record(host_record, - fields=fields, - confirm=confirm) + payload = { + 'name': fqdn, + 'ipv4addrs' : [{'ipv4addr': address, + 'configure_for_dhcp': True, + 'mac': mac}] + } + uri = 'record:host' + fields='' + status_code = self.api.util.post(uri, payload, fields) + break def _create_host_record(self, address, fqdn, mac): if fqdn is None: