def bulk_onboard_devices(jdevice_tree): success = True for devid in jdevice_tree.keys(): jnew_device = {'device_id': devid, 'relsen_list': jdevice_tree[devid]} if not onboard_device(jnew_device): success = False # even if one of them fails, return false eventually ###build_device_inventory() # update in-mem structures; TODO: revisit this. needs testing. will this call succeed, since they are disabled? build_active_device_inventory_route() # this initializes their status also return success
def onboard_device(jnew_device): dprint('\nOnboarding: ', jnew_device) if not insert_device(jnew_device['device_id']): return False for rsid in jnew_device['relsen_list']: if not insert_relsen(jnew_device['device_id'], rsid): return False ###build_device_inventory() # update in-mem structures; TODO: revisit this. needs testing. will this call succeed, since they are disabled? build_active_device_inventory_route() # this initializes their status also return True