diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-03-07 10:22:42 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-04-15 15:42:27 +0800 |
commit | dbf139003bd6c8c6ca03ae7f533aa74afd8060c6 (patch) | |
tree | 7613e9e0eeb314aadbef3aa341643db8c360c8f1 /discover | |
parent | c62667e5c78ea212e5ac49244e9792954a1d8f71 (diff) | |
download | talos-petitboot-dbf139003bd6c8c6ca03ae7f533aa74afd8060c6.tar.gz talos-petitboot-dbf139003bd6c8c6ca03ae7f533aa74afd8060c6.zip |
Move --dry-run option to discover server
Now that the server does the booting, we should move the --dry-run
argument to the server.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r-- | discover/device-handler.c | 7 | ||||
-rw-r--r-- | discover/device-handler.h | 3 | ||||
-rw-r--r-- | discover/pb-discover.c | 10 |
3 files changed, 15 insertions, 5 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c index 6a27f15..12bd5ae 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -23,6 +23,7 @@ struct device_handler { struct discover_server *server; + int dry_run; struct device **devices; unsigned int n_devices; @@ -407,7 +408,8 @@ int device_handler_event(struct device_handler *handler, return handlers[event->type][event->action](handler, event); } -struct device_handler *device_handler_init(struct discover_server *server) +struct device_handler *device_handler_init(struct discover_server *server, + int dry_run) { struct device_handler *handler; @@ -415,6 +417,7 @@ struct device_handler *device_handler_init(struct discover_server *server) handler->devices = NULL; handler->n_devices = 0; handler->server = server; + handler->dry_run = dry_run; list_init(&handler->contexts); @@ -455,5 +458,5 @@ void device_handler_boot(struct device_handler *handler, opt = find_boot_option_by_id(handler, cmd->option_id); - boot(handler, opt, cmd, 0); + boot(handler, opt, cmd, handler->dry_run); } diff --git a/discover/device-handler.h b/discover/device-handler.h index 7207f8d..4cf7d7d 100644 --- a/discover/device-handler.h +++ b/discover/device-handler.h @@ -21,7 +21,8 @@ struct discover_context { struct list_item list; }; -struct device_handler *device_handler_init(struct discover_server *server); +struct device_handler *device_handler_init(struct discover_server *server, + int dry_run); void device_handler_destroy(struct device_handler *devices); diff --git a/discover/pb-discover.c b/discover/pb-discover.c index 536f6e6..c83b574 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -43,6 +43,7 @@ struct opts { enum opt_value show_help; const char *log_file; enum opt_value show_version; + enum opt_value dry_run; }; /** @@ -54,12 +55,14 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) static const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"log", required_argument, NULL, 'l'}, + {"dry-run", no_argument, NULL, 'n'}, {"version", no_argument, NULL, 'V'}, { NULL, 0, NULL, 0}, }; - static const char short_options[] = "hl:V"; + static const char short_options[] = "hl:nV"; static const struct opts default_values = { .log_file = "/var/log/petitboot/pb-discover.log", + .dry_run = opt_no, }; *opts = default_values; @@ -78,6 +81,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) case 'l': opts->log_file = optarg; break; + case 'n': + opts->dry_run = opt_yes; + break; case 'V': opts->show_version = opt_yes; break; @@ -145,7 +151,7 @@ int main(int argc, char *argv[]) if (!server) return EXIT_FAILURE; - handler = device_handler_init(server); + handler = device_handler_init(server, opts.dry_run == opt_yes); if (!handler) return EXIT_FAILURE; |