From 786286f8931c56aa4e98b2f5c4d2913d0349d526 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Fri, 20 Aug 2021 00:11:24 -0700 Subject: [PATCH] [Admin Util] Do not write edge mapp file if no mappings found The NSX-T Json schema validator requires mappings to be present with at least one item. If no mappings are present therefore the JSON file should not be presented at all. Cherry-picked from commit: e7a21d276b29c3ebe0e4488b6099916b447c2972 Change-Id: I8c5721212291262e647202edb1c0bddb9efdf8ef --- vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py index 9e441678a4..3c7bed8c46 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py @@ -683,6 +683,10 @@ def build_edge_mapping_file(resource, event, trigger, **kwargs): mappings.append( {'v_edges': [edge_id], 'policy_gateway_name': router['id']}) + if not mappings: + LOG.info("No edge mapping available. Not producing output file") + return + data = [{'name': 'dlr_edges_to_migrate', 'v_edges_to_policy_gateways_mappings': mappings}] LOG.info(formatters.output_formatter(