self.lctl = 'lctl'
else:
raise CommandError('lctl', "unable to find lctl binary.")
-
+
def run(self, cmds):
"""
run lctl
out = p.fromchild.readlines()
err = p.childerr.readlines()
ret = p.wait()
- if ret or len(err):
- raise CommandError(self.lctl, err, ret)
- return ret, out
+ if os.WIFEXITED(ret):
+ rc = os.WEXITSTATUS(ret)
+ else:
+ rc = 0
+ if rc or len(err):
+ raise CommandError(self.lctl, err, rc)
+ return rc, out
def network(self, net, nid):
# add a route to a range
def del_route(self, net, gw, lo, hi):
cmds = """
+ ignore_errors
network %s
del_route %s
quit """ % (net, lo)
# add a route to a range
def del_route_host(self, net, uuid, gw, tgt):
cmds = """
+ ignore_errors
network %s
del_uuid %s
del_route %s
# disconnect one connection
def disconnect(self, net, nid, port, servuuid):
cmds = """
+ ignore_errors
network %s
disconnect %s
del_uuid %s
# disconnect all
def disconnectAll(self, net):
cmds = """
+ ignore_errors
network %s
del_uuid self
disconnect
# cleanup a device
def cleanup(self, name, uuid):
cmds = """
+ ignore_errors
device $%s
cleanup
detach
quit""" % (mdsuuid, uuid, stripe_cnt, stripe_sz, stripe_off, pattern, devlist)
self.run(cmds)
- # cleanup a device
+ # dump the log file
def dump(self, dump_file):
cmds = """
debug_kernel %s 1
if first_cleanup_error:
sys.exit(first_cleanup_error)
-2
+
return 0;
}
+static int jt_opt_ignore_errors(int argc, char **argv) {
+ Parser_ignore_errors(1);
+ return 0;
+}
+
command_t cmdlist[] = {
/* Metacommands */
{"--device", jt_opt_device, 0,
{"--threads", jt_opt_threads, 0,
"run <threads> separate instances of <command> on device <devno>\n"
"--threads <threads> <verbose> <devno> <command [args ...]>"},
+ {"--ignore_errors", jt_opt_ignore_errors, 0,
+ "ignore errors that occur during script processing\n"
+ "--ignore_errors"},
+ {"ignore_errors", jt_opt_ignore_errors, 0,
+ "ignore errors that occur during script processing\n"
+ "ignore_errors"},
/* Network configuration commands */
{"==== network config ====", jt_noop, 0, "network config"},
* InitParser */
static char * parser_prompt = NULL;/* Parser prompt, set by InitParser */
static int done; /* Set to 1 if user types exit or quit */
+static int ignore_errors; /* Normally, the parser will quit when
+ an error occurs in non-interacive
+ mode. Setting this to non-zero will
+ force it to keep buggering on. */
/* static functions */
return NULL;
}
+void Parser_ignore_errors(int ignore)
+{
+ ignore_errors = ignore;
+}
+
int Parser_execarg(int argc, char **argv, command_t cmds[])
{
command_t *cmd;
int Parser_commands(void)
{
char *line, *s;
- int rc = 0;
+ int rc = 0, save_error = 0;
int interactive;
interactive = init_input();
rc = execute_line(s);
}
/* stop on error if not-interactive */
- if (rc != 0 && !interactive)
- done = 1;
+ if (rc != 0 && !interactive) {
+ if (save_error == 0)
+ save_error = rc;
+ if (!ignore_errors)
+ done = 1;
+ }
free(line);
}
+ if (save_error)
+ rc = save_error;
return rc;
}
int Parser_commands(void); /* Start the command parser */
void Parser_qhelp(int, char **); /* Quick help routine */
int Parser_help(int, char **); /* Detailed help routine */
+void Parser_ignore_errors(int ignore); /* Set the ignore errors flag */
void Parser_printhelp(char *); /* Detailed help routine */
void Parser_exit(int, char **); /* Shuts down command parser */
int Parser_execarg(int argc, char **argv, command_t cmds[]);