|
30 | 30 | # _snipeit_custom_name_1234567890 = subset jamf_key |
31 | 31 | # |
32 | 32 | # A list of valid subsets are: |
33 | | -version = "1.0.2" |
| 33 | +version = "1.0.3" |
34 | 34 |
|
35 | 35 | validsubset = [ |
36 | 36 | "general", |
@@ -159,6 +159,13 @@ if not 'user-mapping' in config and (user_args.users or user_args.users_force or |
159 | 159 | logging.error("""You've chosen to check out assets to users in some capacity using a cmdline switch, but not specified how you want to |
160 | 160 | search Snipe IT for the users from Jamf. Make sure you have a 'user-mapping' section in your settings.conf file.""") |
161 | 161 | SETTINGS_CORRECT = False |
| 162 | +if snipe_base.endswith("/"): |
| 163 | + logging.error("""You have a trailing forward slash in the snipe url. Please remove it.""") |
| 164 | + SETTINGS_CORRECT = False |
| 165 | +if jamfpro_base.endswith("/"): |
| 166 | + logging.error("""You have a trailing forward slash in the JamfPro url. Please remove it.""") |
| 167 | + SETTINGS_CORRECT = False |
| 168 | + |
162 | 169 |
|
163 | 170 | if not SETTINGS_CORRECT: |
164 | 171 | raise SystemExit |
@@ -845,6 +852,12 @@ for jamf_type in jamf_types: |
845 | 852 | if new_snipe_asset[0] != "AssetCreated": |
846 | 853 | continue |
847 | 854 | if user_args.users or user_args.users_force or user_args.users_inverse: |
| 855 | + jamfsplit = config['user-mapping']['jamf_api_field'].split() |
| 856 | + if jamfsplit[1] not in jamf[jamfsplit[0]]: |
| 857 | + logging.info("Couldn't find {} for this device in {}, not checking it out.".format(jamfsplit[1], jamfsplit[0])) |
| 858 | + continue |
| 859 | + logging.info('Checking out new item {} to user {}'.format(jamf['general']['name'], jamf['{}'.format(jamfsplit[0])]['{}'.format(jamfsplit[1])])) |
| 860 | + checkout_snipe_asset(jamf['{}'.format(jamfsplit[0])]['{}'.format(jamfsplit[1])],new_snipe_asset[1].json()['payload']['id'], "NewAsset") |
848 | 861 | # Log an error if there's an issue, or more than once match. |
849 | 862 | elif snipe == 'MultiMatch': |
850 | 863 | logging.warning("WARN: You need to resolve multiple assets with the same serial number in your inventory. If you can't find them in your inventory, you might need to purge your deleted records. You can find that in the Snipe Admin settings. Skipping serial number {} for now.".format(jamf['general']['serial_number'])) |
|
0 commit comments