vppctl: Do not use sudo if already root

When using sudo, environment variable such as the PATH
are overwritten.
This patch just checks if user is already root and does
not use sudo in such situation.
This allows using approaches like:
sudo env PATH=path/to/vpp-binary/:$PATH vppctl

Not really important in production setups, but this is handy
for testing.

Change-Id: I079c104d026ae7d378468380b012279a6e5d765d
Signed-off-by: Pierre Pfister <ppfister@cisco.com>
diff --git a/vpp-api-test/scripts/vppctl b/vpp-api-test/scripts/vppctl
index 160bdf7..6dfa3b9 100755
--- a/vpp-api-test/scripts/vppctl
+++ b/vpp-api-test/scripts/vppctl
@@ -42,8 +42,12 @@
                 input_command = input_prefix + line
                 line_remove = '^load_one_plugin:'
                 s = '\n'
+                command = ['vpp_api_test']
 
-                vpp_process = subprocess.Popen(['sudo', 'vpp_api_test'],
+                if os.geteuid() != 0:
+                    command = ['sudo', 'vpp_api_test']
+
+                vpp_process = subprocess.Popen(command,
                         stderr=subprocess.PIPE,
                         stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE)