Example #1
0
def sync_inventory(client_name, worker_id):
    for client in clients:
        if client.name == client_name:
            break
    else:
        return
    while True:
        pk = uuid.uuid4()
        for index, (machine_snapshot, diff) in enumerate(client.sync()):
            if machine_snapshot.machine and machine_snapshot.machine.serial_number:
                try:
                    post_inventory_event(machine_snapshot.machine.serial_number, diff, pk, index)
                except TemporaryQueueError:
                    logger.exception('Could not post inventory event')
            else:
                logger.error('Machine w/o serial number')
        push_inventory_metrics()
        time.sleep(SLEEP)
Example #2
0
def sync_inventory():
    pk = uuid.uuid4()
    for index, (machine_d, payload) in enumerate(inventory.sync()):
        post_inventory_event(machine_d["serial_number"], payload, pk, index)