From d5e7606f4e2b4a944cae9d344f4cf850cca69356 Mon Sep 17 00:00:00 2001
From: Amey Bhide <abhide@vmware.com>
Date: Wed, 2 Dec 2015 22:30:23 -0800
Subject: [PATCH] Admin Utility: Fix output for missing edges and spoofguard
 policy

Change-Id: I00e74555ee42840b3f5ee9b704a7893fa293b516
---
 .../admin/plugins/nsxv/resources/edges.py                | 8 +++++++-
 .../admin/plugins/nsxv/resources/spoofguard_policy.py    | 9 +++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py b/tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py
index ae2db77822..0e0910bfbe 100644
--- a/tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py
+++ b/tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py
@@ -76,8 +76,14 @@ def nsx_list_orphaned_edges(resource, event, trigger, **kwargs):
     Orphaned edges are NSXv edges that exist on NSXv backend but
     don't have a corresponding binding in Neutron DB
     """
+    LOG.info(_LI("NSXv edges present on NSXv backend but not present "
+                 "in Neutron DB"))
     orphaned_edges = get_orphaned_edges()
-    LOG.info(orphaned_edges)
+    if not orphaned_edges:
+        LOG.info(_LI("\nNo orphaned edges found."
+                     "\nNeutron DB and NSXv backend are in sync\n"))
+    else:
+        LOG.info(orphaned_edges)
 
 
 @admin_utils.output_header
diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py b/tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py
index c70f642d5a..ba23a6d56a 100644
--- a/tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py
+++ b/tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py
@@ -78,9 +78,14 @@ def nsx_list_missing_spoofguard_policies(resource, event, trigger,
     Spoofguard policies that have a binding in Neutron Db but there is
     no policy on NSXv backend to back it.
     """
-    LOG.info(_LI("Spoofguard policies in Neutron Db but on present on NSXv"))
+    LOG.info(_LI("Spoofguard policies in Neutron Db but not present on NSXv"))
     missing_policies = get_missing_spoofguard_policy_mappings()
-    LOG.info(missing_policies)
+    if not missing_policies:
+        LOG.info(_LI("\nNo missing spoofguard policies found."
+                     "\nNeutron DB and NSXv backend are in sync\n"))
+    else:
+        LOG.info(formatters.output_formatter(
+            constants.SPOOFGUARD_POLICY, missing_policies, ['policy_id']))
 
 
 registry.subscribe(neutron_list_spoofguard_policy_mappings,