Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #48 from johanpostema/add-search-feature
Browse files Browse the repository at this point in the history
add search_a_record and search_host_record
  • Loading branch information
xoanmi authored Feb 27, 2019
2 parents 880d3b2 + cbc7a00 commit 537c133
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions infoblox.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"create_network_container", "set_a_record", "set_name", "set_extattr", "update_a_record", "update_srv_record",
"update_ptr_record", "update_cname_record", "update_auth_zone", "update_forward_zone", "update_txt_record",
"update_network_container", "update_host_record", "delete_alias", "delete_cname", "delete_a_record", "delete_fixedaddress",
"delete_host", "delete_ptr_record", "delete_srv_record", "reserve_next_available_ip"]
"delete_host", "delete_ptr_record", "delete_srv_record", "reserve_next_available_ip, search_a_record, search_host_record"]
host:
description:
- Hostname variable to search, add or delete host object
Expand Down Expand Up @@ -525,6 +525,20 @@ def get_a_record(self, name):
_RETURN_FIELDS_PROPERTY: my_property}
return self.invoke("get", "record:a", params=params)

# ---------------------------------------------------------------------------
# seach_a_record()
# ---------------------------------------------------------------------------
def search_a_record(self, name):
params = {_NAME_PROPERTY + "~": name }
return self.invoke("get", "record:a", params=params)

# ---------------------------------------------------------------------------
# seach_host_record()
# ---------------------------------------------------------------------------
def search_host_record(self, name):
params = {_NAME_PROPERTY + "~": name }
return self.invoke("get", "record:host", params=params)

# ---------------------------------------------------------------------------
# create_a_record()
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1624,7 +1638,7 @@ def main():
"update_txt_record", "update_network_container", "update_host_record",
"delete_alias", "delete_cname", "delete_a_record", "delete_fixedaddress", "delete_host",
"delete_ptr_record", "delete_srv_record",
"reserve_next_available_ip"
"reserve_next_available_ip", "search_a_record", "search_host_record"
]),
host=dict(required=False),
network=dict(required=False),
Expand Down Expand Up @@ -2201,6 +2215,18 @@ def main():
module.exit_json(changed=True, result=result)
else:
raise Exception()
elif action == "search_a_record":
result = infoblox.search_a_record(name)
if result:
module.exit_json(changed=True, result=result)
else:
module.exit_json(changed=False, result=result)
elif action == "search_host_record":
result = infoblox.search_host_record(name)
if result:
module.exit_json(changed=True, result=result)
else:
module.exit_json(changed=False, result=result)


if __name__ == "__main__":
Expand Down

0 comments on commit 537c133

Please sign in to comment.