Created
July 25, 2019 11:19
-
-
Save dLobatog/0ea95043431c0c38e223bbfb1cdfb860 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host.find_each(100).map do |host| | |
inventory_host = HostInventoryAPI.new( | |
host, | |
host.account, | |
Settings.host_inventory_url, | |
host.account.b64identity | |
).host_already_in_inventory | |
if inventory_host | |
old_id = host.id | |
host.update(id: inventory_host.id) | |
ProfileHost.where(host_id: old_id).update_all(host_id: inventory_host.id) | |
RuleResult.where(host_id: old_id).update_all(host_id: inventory_host.id) | |
else | |
# Host is not in the inventory? Do not destroy as API could be broken | |
host.not_found | |
end | |
end | |
class Host | |
def not_found | |
not_found_count += 1 | |
destroy if not_found > 3 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment