Fix various issues with large Snipe-IT (50k+ assets, 50k+ users) and JAMF installations (5k+ assets)#119
Fix various issues with large Snipe-IT (50k+ assets, 50k+ users) and JAMF installations (5k+ assets)#119guruevi wants to merge 1 commit into
Conversation
Fix issues with Snipe-IT installs that have more than 500 models Fix issues with Snipe-IT installs that have many users (20k+), fetching them all is costly. Fix various code cleanliness and logic errors that crashed the program due to the weirdness in return values in large (and old) JAMF installations
| value = value[key] | ||
| except (KeyError, IndexError): | ||
| logging.info(f"{key} does not exist") | ||
| logging.debug(f"Ansible value: {value}") |
There was a problem hiding this comment.
Ansible? assuming this line was copied from elsewhere? ;)
| if jamf['general']['serial_number'] == 'Not Available': | ||
| if not jamf['general']['serial_number']: |
There was a problem hiding this comment.
iirc This evaluates a literal string for "Not Available" that sometimes occurs for devices that are in Jamf via MDM but haven't checked in yet. Jamf didn't leave the it as null, but returned a valid string instead. That might have changed, but this would probably cause a regression as is.
There was a problem hiding this comment.
In my current JAMF instance, a system that is missing info may return null or an empty string ('') which would fail this check - however that fact doesn't seem to be consistent, sometimes it is null, sometimes it is an empty string, hence why I made the modification. I have not ran across the "Not Available" string, this may be an artifact from the old API?
There was a problem hiding this comment.
It could also be a school.apple.com thing. I'd recommend altering the line to check for both so if it's either that literal string or null we're covered.
Fix issues with Snipe-IT installs that have more than 500 models
Fix issues with Snipe-IT installs that have many users, fetching them all is costly, query individuals and use a local cache instead
Fix various code cleanliness and logic errors that crashed the program due to the weirdness in return values in large (and old) JAMF installations