def run(self, context): if not context.inventory_timer.is_it_time(): return log.info("Syncing the inventory...") inventory_data = inventory.aggregate( settings.PATHS.inventory_scripts, settings.PATHS.device_type, settings.PATHS.artifact_info, ) if inventory_data: log.debug(f"aggregated inventory data: {inventory_data}") if not client_inventory.request( context.config.ServerURL, context.JWT, inventory_data, context.config.ServerCertificate, method="PUT", ): log.info( "Falling back to to updating the inventory with PATCH") # Ignoring the returned error. It will only be logged if not client_inventory.request( context.config.ServerURL, context.JWT, inventory_data, context.config.ServerCertificate, method="PATCH", ): log.error("Failed to submit the inventory") return None else: log.info("No inventory data found") return None log.info("Inventory submitted successfully")
def run(self, context): log.info("Syncing the inventory...") inventory_data = inventory.aggregate( settings.PATHS.inventory_scripts, settings.PATHS.device_type, settings.PATHS.artifact_info, ) if inventory_data: log.debug(f"aggreated inventory data: {inventory_data}") client_inventory.request( context.config.ServerURL, context.JWT, inventory_data, context.config.ServerCertificate, ) else: log.info("No inventory data found") time.sleep(1)
def test_inventory_aggregator(self, data, expected, file_create_fixture): tpath = file_create_fixture(data) assert (inventory.aggregate(tpath, device_type_path="", artifact_info_path="") == expected)