grokability / jamf2snipe

Import and sync assets from a JAMFPro instance to Snipe-IT asset management.
MIT License
108 stars 55 forks source link

Asset model number not created automatically in snipe-it #57

Closed robbo007 closed 2 years ago

robbo007 commented 3 years ago

Hi, I see if the modele number is not filled in or does not exist in the snipe-it database the plugin does not create the entry and fails. Is this suppose to happen or should it be creating the model number if it does not exist?

Traceback (most recent call last):
  File "jamf2snipe", line 623, in <module>
    create_snipe_model(newmodel)
  File "jamf2snipe", line 417, in create_snipe_model
    modelnumbers[jsonresponse['payload']['model_number']] = jsonresponse['payload']['id']
TypeError: 'NoneType' object is not subscriptable

Regards,

ParadoxGuitarist commented 3 years ago

Seems like it's actually failing trying to create the model. I think you're probably missing the Apple manufacturer ID in your config.

robbo007 commented 3 years ago

After fixing the manufacturing ID on the VM MacOS it now displays "INFO:root:Could not find a model ID in snipe for: MacBookAir9,1". This model number does not exits in Snipe.

ubuntu@1983network:~$ sudo -i root@1983network:~# cd jamf2snipe/ -bash: cd: jamf2snipe/: No such file or directory root@1983network:~# cd /opt/ root@1983network:/opt# cd jamf2snipe/ root@1983network:/opt/jamf2snipe# python3 jamf2snipe -v jamf2snipe:374: SyntaxWarning: "is not" with a literal. Did you mean "!="? if len(previous) is not 0: jamf2snipe:449: SyntaxWarning: "is" with a literal. Did you mean "=="? if payload[key] is '': jamf2snipe:517: SyntaxWarning: "is" with a literal. Did you mean "=="? SNIPE_UP = True if requests.get(snipe_base, verify=user_args.do_not_verify_ssl, hooks={'response': request_handler}).status_code is 200 else False jamf2snipe:552: SyntaxWarning: "is" with a literal. Did you mean "=="? if model['model_number'] is "": jamf2snipe:637: SyntaxWarning: "is" with a literal. Did you mean "=="? if snipe is 'NoMatch': jamf2snipe:640: SyntaxWarning: "is" with a literal. Did you mean "=="? if jamf['general']['asset_tag'] is '': jamf2snipe:649: SyntaxWarning: "is" with a literal. Did you mean "=="? if jamf_asset_tag is None or jamf_asset_tag is '': jamf2snipe:681: SyntaxWarning: "is" with a literal. Did you mean "=="? elif snipe is 'MultiMatch': jamf2snipe:683: SyntaxWarning: "is" with a literal. Did you mean "=="? elif snipe is 'ERROR': INFO:root:Searching for a valid settings.conf file. INFO:root:Great, we found a settings file. Let's get started by parsing all fo the settings. INFO:root:The configured JAMFPro base url is: https://mycompany.jamfcloud.com/ INFO:root:The configured JAMFPro username we'll be connecting with is: my.user INFO:root:The configured Snipe-IT base url is: https://mycompany.snipe-it.io INFO:root:The default status we'll be setting updated computer to is: 2 (I sure hope this is a number or something is probably wrong) INFO:root:The configured JAMFPro base url is: 5 (Pretty sure this needs to be a number too) INFO:root:Creating the headers we'll need for API calls INFO:root:Found subset general: Acceptable INFO:root:Found subset general: Acceptable INFO:root:SSL Verification is set to: True INFO:root:Running tests to see if hosts are up. INFO:root:We were able to get a good response from your Snipe-IT instance. INFO:root:We were able to get a good response from your JAMFPro instance. INFO:root:Finished running our tests. INFO:root:Getting a list of computer models that snipe knows about. INFO:root:Got a valid response that should have 27 models. INFO:root:Our list of models has 22 entries. INFO:root:Received a list of JAMF assets that had 1 entries. INFO:root:Starting to Update Inventory INFO:root:Processing entry 1 out of 1 - JAMFID: 7 - NAME: rcraig’s MacBook INFO:root:Could not find a model ID in snipe for: MacBookAir9,1 Traceback (most recent call last): File "jamf2snipe", line 623, in <module> create_snipe_model(newmodel) File "jamf2snipe", line 417, in create_snipe_model modelnumbers[jsonresponse['payload']['model_number']] = jsonresponse['payload']['id'] TypeError: 'NoneType' object is not subscriptable root@1983network:/opt/jamf2snipe#

IF I create the model number in Snipe I get: root@1983network:/opt/jamf2snipe# python3 jamf2snipe -v jamf2snipe:374: SyntaxWarning: "is not" with a literal. Did you mean "!="? if len(previous) is not 0: jamf2snipe:449: SyntaxWarning: "is" with a literal. Did you mean "=="? if payload[key] is '': jamf2snipe:517: SyntaxWarning: "is" with a literal. Did you mean "=="? SNIPE_UP = True if requests.get(snipe_base, verify=user_args.do_not_verify_ssl, hooks={'response': request_handler}).status_code is 200 else False jamf2snipe:552: SyntaxWarning: "is" with a literal. Did you mean "=="? if model['model_number'] is "": jamf2snipe:637: SyntaxWarning: "is" with a literal. Did you mean "=="? if snipe is 'NoMatch': jamf2snipe:640: SyntaxWarning: "is" with a literal. Did you mean "=="? if jamf['general']['asset_tag'] is '': jamf2snipe:649: SyntaxWarning: "is" with a literal. Did you mean "=="? if jamf_asset_tag is None or jamf_asset_tag is '': jamf2snipe:681: SyntaxWarning: "is" with a literal. Did you mean "=="? elif snipe is 'MultiMatch': jamf2snipe:683: SyntaxWarning: "is" with a literal. Did you mean "=="? elif snipe is 'ERROR': INFO:root:Searching for a valid settings.conf file. INFO:root:Great, we found a settings file. Let's get started by parsing all fo the settings. INFO:root:The configured JAMFPro base url is: https://mycompany.jamfcould/ INFO:root:The configured JAMFPro username we'll be connecting with is: my.user INFO:root:The configured Snipe-IT base url is: https://mysnipe-it.io INFO:root:The default status we'll be setting updated computer to is: 2 (I sure hope this is a number or something is probably wrong) INFO:root:The configured JAMFPro base url is: 5 (Pretty sure this needs to be a number too) INFO:root:Creating the headers we'll need for API calls INFO:root:Found subset general: Acceptable INFO:root:Found subset general: Acceptable INFO:root:SSL Verification is set to: True INFO:root:Running tests to see if hosts are up. INFO:root:We were able to get a good response from your Snipe-IT instance. INFO:root:We were able to get a good response from your JAMFPro instance. INFO:root:Finished running our tests. INFO:root:Getting a list of computer models that snipe knows about. INFO:root:Got a valid response that should have 27 models. INFO:root:Our list of models has 22 entries. INFO:root:Received a list of JAMF assets that had 1 entries. INFO:root:Starting to Update Inventory INFO:root:Processing entry 1 out of 1 - JAMFID: 7 - NAME: rcraig’s MacBook root@1983network:/opt/jamf2snipe# Saying that I have deleted before from both jamf and snipe this computer. I've re-enroled it and run the plugin and it keeps updating the deleted entry in snipe. Even though it says "INFO:root:Received a list of JAMF assets that had 1 entries. INFO:root:Starting to Update Inventory INFO:root:Processing entry 1 out of 1 - JAMFID: 7 - NAME: rcraig’s MacBook"

🤯 Questions: Why is it updating the deleted record and not creating a new one for the MacBookAir9,1? Do I need to create a model number for all the MACS? Why is it failing to create it if it does not exist in Snipe? Thanks :)

robbo007 commented 3 years ago

Any ideas about my questions? Why is it updating the deleted record and not creating a new one for the MacBookAir9,1? Do I need to create a model number for all the MACS? Why is it failing to create it if it does not exist in Snipe?

dstocking commented 3 years ago

What fixed this for me wasn't manufacturer id, it was making sure i had the correct category ids in my conf file:

computer_model_category_id = (id number for the computer category) mobile_model_category_id = (id for the mobile device category)