Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various issues with large Snipe-IT (50k+ assets, 50k+ users) and JAMF installations (5k+ assets) #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

guruevi
Copy link

@guruevi guruevi commented Oct 8, 2023

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

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}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ansible? assuming this line was copied from elsewhere? ;)

Comment on lines -766 to +778
if jamf['general']['serial_number'] == 'Not Available':
if not jamf['general']['serial_number']:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator

@ParadoxGuitarist ParadoxGuitarist Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants