diff --git a/src/ralph/export_to_ng/management/commands/sync_to_ralph3.py b/src/ralph/export_to_ng/management/commands/sync_to_ralph3.py index d0958e54f5..5ad979f34a 100644 --- a/src/ralph/export_to_ng/management/commands/sync_to_ralph3.py +++ b/src/ralph/export_to_ng/management/commands/sync_to_ralph3.py @@ -119,7 +119,13 @@ def venture_role_sync(model, **options): def _device_partial_sync(fields, **options): - for obj in Device.objects.exclude(deleted=True)[:10]: + for obj in Device.objects.exclude(deleted=True): + if ( + options.get('device_with_asset_only') and + not obj.get_asset(manager='admin_objects') + ): + logger.info('Skipping {} - it does not have asset'.format(obj)) + continue post_save.send( sender=Device, instance=obj, @@ -165,6 +171,10 @@ class Command(BaseCommand): '--skip-empty', action="store_true", ), + make_option( + '--device-with-asset-only', + action="store_true", + ), make_option( '--sleep', type=int,