summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Warnicke <hagbard@gmail.com>2017-07-10 19:03:12 +0000
committerNeale Ranns <nranns@cisco.com>2017-07-11 08:03:16 +0000
commitd6a11c430b58e76acb7462190eed095820cae008 (patch)
tree6ddb6873fb71a3e3072a5afe66d5df56d1fb70d2
parentcdb8514ac0e70add06de9cd2cfe8628c5cf644ba (diff)
Fix vppctl error messages to handle lack off permissions
Change-Id: Ia35edcb14eb8d786065ee4ab394f4f1aa52e1625 Signed-off-by: Ed Warnicke <hagbard@gmail.com>
-rwxr-xr-xsrc/scripts/vppctl27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/scripts/vppctl b/src/scripts/vppctl
index a59b4b66872..1483685d1f5 100755
--- a/src/scripts/vppctl
+++ b/src/scripts/vppctl
@@ -21,6 +21,8 @@ import subprocess
import re
import sys
from optparse import OptionParser
+from errno import EACCES, EPERM, ENOENT
+
try:
import readline
@@ -43,6 +45,30 @@ class Vppctl(Cmd):
readline.set_history_length(persishist_size)
readline.write_history_file(persishist)
+ def print_file_error_message(self,e, file_name):
+ #PermissionError
+ if e.errno==EPERM or e.errno==EACCES:
+ print("PermissionError error({0}): {1} for:\n{2}".format(e.errno, e.strerror, file_name))
+ #FileNotFoundError
+ elif e.errno==ENOENT:
+ print("FileNotFoundError error({0}): {1} as:\n{2}".format(e.errno, e.strerror, file_name))
+ elif IOError:
+ print("I/O error({0}): {1} as:\n{2}".format(e.errno, e.strerror, file_name))
+ elif OSError:
+ print("OS error({0}): {1} as:\n{2}".format(e.errno, e.strerror, file_name))
+
+ def testPermissions(self):
+ if(self.api_prefix is None):
+ filename = "/dev/shm/vpe-api"
+ else:
+ filename = "/dev/shm/%s-vpe-api" % self.api_prefix
+ try:
+ file = open(filename)
+ file.close()
+ except (IOError, OSError) as e:
+ self.print_file_error_message(e,filename)
+ sys.exit()
+
def runVat(self, line):
input_prefix = "exec "
input_command = input_prefix + line
@@ -53,6 +79,7 @@ class Vppctl(Cmd):
else:
command = ['vpp_api_test',"chroot prefix %s " % self.api_prefix]
+ self.testPermissions()
vpp_process = subprocess.Popen(command,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,