diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-02-02 14:53:19 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-02-02 15:12:25 +0200 |
commit | 4a72c67c34b1c5b348e61ab900fb0b64305b9f97 (patch) | |
tree | bd3c91c42a14ac50f2406ba8153b04d2099cd9ab /src | |
parent | f9536d8285625d4263c5b2dd0ab2a6773dd2b618 (diff) | |
download | eclat-4a72c67c34b1c5b348e61ab900fb0b64305b9f97.tar.gz eclat-4a72c67c34b1c5b348e61ab900fb0b64305b9f97.tar.bz2 |
New options: --check-permissions and --add-parameter
* NEWS: Update.
* doc/eclat-stop.1: Update.
* doc/eclat.1man: Update.
* etc/default.fln: Special handling for DryRunOperation
and UnauthorizedOperation codes.
* lib/paramlist.c: New file.
* lib/Makefile.am (libeclat_a_SOURCES): Add paramlist.c
* lib/forlan.c: New function dequote.
* lib/libeclat.h (eclat_request_add_param0)
(ec2_param_free, ec2_param_list_create)
(ec2_param_list_append)
(eclat_request_add_param_list): New protos.
* lib/reqcreat.c (ec2_param_free): Remove static qualifier.
* src/stop-cl.opt: New file.
* src/Makefile.am (OPTFILES): Add stop-cl.opt
* src/cmdline.opt: New options: --check-permissions and --add-parameter.
* src/eclat.c (extra_param): New global.
(find_format): print error message if no such format is found.
* src/startstop.c (eclat_stop_instance): Use parse_stop_options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/cmdline.opt | 16 | ||||
-rw-r--r-- | src/eclat.c | 8 | ||||
-rw-r--r-- | src/startstop.c | 12 | ||||
-rw-r--r-- | src/stop-cl.opt | 33 |
5 files changed, 65 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 1aa8703..7ec7c66 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -102,7 +102,8 @@ OPTFILES=\ | |||
102 | rmsg-cl.opt\ | 102 | rmsg-cl.opt\ |
103 | sg-cl.opt\ | 103 | sg-cl.opt\ |
104 | setiattr-cl.opt\ | 104 | setiattr-cl.opt\ |
105 | setaattr-cl.opt | 105 | setaattr-cl.opt\ |
106 | stop-cl.opt | ||
106 | 107 | ||
107 | eclat_SOURCES += $(OPTFILES:.opt=.h) | 108 | eclat_SOURCES += $(OPTFILES:.opt=.h) |
108 | 109 | ||
diff --git a/src/cmdline.opt b/src/cmdline.opt index 6da23c2..8a707ec 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt | |||
@@ -259,6 +259,12 @@ BEGIN | |||
259 | parse_debug_level("curl.1"); | 259 | parse_debug_level("curl.1"); |
260 | END | 260 | END |
261 | 261 | ||
262 | OPTION(check-permissions,p,, | ||
263 | [<check if the requested action is permitted for current account>]) | ||
264 | BEGIN | ||
265 | ec2_param_list_append(&extra_param, "DryRun", "true"); | ||
266 | END | ||
267 | |||
262 | OPTION(dump-grammar-trace,,, | 268 | OPTION(dump-grammar-trace,,, |
263 | [<dump configuration grammar traces>]) | 269 | [<dump configuration grammar traces>]) |
264 | BEGIN | 270 | BEGIN |
@@ -279,6 +285,16 @@ BEGIN | |||
279 | } | 285 | } |
280 | END | 286 | END |
281 | 287 | ||
288 | OPTION(add-parameter,A,NAME=VALUE, | ||
289 | [<pass additional parameter to the AWS request>]) | ||
290 | BEGIN | ||
291 | char *p = strchr(optarg, '='); | ||
292 | if (!p) | ||
293 | die(EX_USAGE, "malformed parameter: %s", optarg); | ||
294 | *p++ = 0; | ||
295 | ec2_param_list_append(&extra_param, optarg, p); | ||
296 | END | ||
297 | |||
282 | GROUP([<Additional help>]) | 298 | GROUP([<Additional help>]) |
283 | OPTION(config-help,,, | 299 | OPTION(config-help,,, |
284 | [<show configuration file summary>]) | 300 | [<show configuration file summary>]) |
diff --git a/src/eclat.c b/src/eclat.c index 8cadebd..69efa8e 100644 --- a/src/eclat.c +++ b/src/eclat.c | |||
@@ -43,6 +43,8 @@ char *format_file; | |||
43 | char *test_map_name; | 43 | char *test_map_name; |
44 | enum eclat_confirm_mode confirm_mode; | 44 | enum eclat_confirm_mode confirm_mode; |
45 | int translate_option = -1; | 45 | int translate_option = -1; |
46 | struct grecs_list *extra_param; | ||
47 | |||
46 | 48 | ||
47 | FILE *xml_dump_file; | 49 | FILE *xml_dump_file; |
48 | 50 | ||
@@ -566,9 +568,10 @@ find_format(const char *name) | |||
566 | return NULL; | 568 | return NULL; |
567 | key.name = (char*) name; | 569 | key.name = (char*) name; |
568 | defn = grecs_symtab_lookup_or_install(format_table, &key, NULL); | 570 | defn = grecs_symtab_lookup_or_install(format_table, &key, NULL); |
569 | if (!defn) | 571 | if (!defn) { |
572 | err("no such format: %s", name); | ||
570 | return NULL; | 573 | return NULL; |
571 | 574 | } | |
572 | env = forlan_parse_buffer(defn->text, strlen(defn->text), | 575 | env = forlan_parse_buffer(defn->text, strlen(defn->text), |
573 | &defn->locus.beg); | 576 | &defn->locus.beg); |
574 | return env; | 577 | return env; |
@@ -656,6 +659,7 @@ eclat_do_command(eclat_command_env_t *env, struct eclat_command *command, | |||
656 | endpoint, "/", | 659 | endpoint, "/", |
657 | region_name, access_key, | 660 | region_name, access_key, |
658 | security_token); | 661 | security_token); |
662 | eclat_request_add_param_list(env->request, extra_param); | ||
659 | } | 663 | } |
660 | 664 | ||
661 | if (command->tag) | 665 | if (command->tag) |
diff --git a/src/startstop.c b/src/startstop.c index f5346c4..98f4e12 100644 --- a/src/startstop.c +++ b/src/startstop.c | |||
@@ -61,16 +61,20 @@ eclat_start_instance(eclat_command_env_t *env, int argc, char **argv) | |||
61 | return start_stop_instance(env, argc - i, argv + i); | 61 | return start_stop_instance(env, argc - i, argv + i); |
62 | } | 62 | } |
63 | 63 | ||
64 | |||
65 | static int force; | ||
66 | |||
67 | #include "stop-cl.h" | ||
68 | |||
64 | int | 69 | int |
65 | eclat_stop_instance(eclat_command_env_t *env, int argc, char **argv) | 70 | eclat_stop_instance(eclat_command_env_t *env, int argc, char **argv) |
66 | { | 71 | { |
67 | int i; | 72 | int i; |
68 | 73 | ||
69 | parse_options(env->cmd, | 74 | parse_stop_options(env, argc, argv, &i); |
70 | "Stop named instances", | ||
71 | argc, argv, &i); | ||
72 | |||
73 | debug(ECLAT_DEBCAT_MAIN, 1, ("stopping instances")); | 75 | debug(ECLAT_DEBCAT_MAIN, 1, ("stopping instances")); |
76 | if (force) | ||
77 | eclat_request_add_param(env->request, "Force", "1"); | ||
74 | return start_stop_instance(env, argc - i, argv + i); | 78 | return start_stop_instance(env, argc - i, argv + i); |
75 | } | 79 | } |
76 | 80 | ||
diff --git a/src/stop-cl.opt b/src/stop-cl.opt new file mode 100644 index 0000000..a2aae61 --- /dev/null +++ b/src/stop-cl.opt | |||
@@ -0,0 +1,33 @@ | |||
1 | /* This file is part of Eclat. | ||
2 | Copyright (C) 2012-2015 Sergey Poznyakoff. | ||
3 | |||
4 | Eclat is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | Eclat is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | ECLAT_CL_BEGIN([<Stop named instances>], | ||
18 | [<ID [ID...]>]) | ||
19 | |||
20 | |||
21 | OPTION(force,f,, | ||
22 | [<force stopping the instance>]) | ||
23 | BEGIN | ||
24 | force = 1; | ||
25 | END | ||
26 | |||
27 | ECLAT_CL_END | ||
28 | |||
29 | ECLAT_CL_PARSER(parse_stop_options, [<int argc, char *argv[], int *index>], [< | ||
30 | { | ||
31 | GETOPT(argc, argv, *index) | ||
32 | } | ||
33 | >]) \ No newline at end of file | ||