aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-02-02 14:53:19 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2015-02-02 15:12:25 +0200
commit4a72c67c34b1c5b348e61ab900fb0b64305b9f97 (patch)
treebd3c91c42a14ac50f2406ba8153b04d2099cd9ab /src
parentf9536d8285625d4263c5b2dd0ab2a6773dd2b618 (diff)
downloadeclat-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.am3
-rw-r--r--src/cmdline.opt16
-rw-r--r--src/eclat.c8
-rw-r--r--src/startstop.c14
-rw-r--r--src/stop-cl.opt33
5 files changed, 66 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1aa8703..7ec7c66 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -99,13 +99,14 @@ OPTFILES=\
mktags-cl.opt\
mkvol-cl.opt\
rmaddr-cl.opt\
rmsg-cl.opt\
sg-cl.opt\
setiattr-cl.opt\
- setaattr-cl.opt
+ setaattr-cl.opt\
+ stop-cl.opt
eclat_SOURCES += $(OPTFILES:.opt=.h)
BUILT_SOURCES=\
cmdline.h\
ispeek-cl.h\
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 6da23c2..8a707ec 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -256,12 +256,18 @@ OPTION(dry-run,n,,
BEGIN
dry_run_mode = 1;
parse_debug_level("main.1");
parse_debug_level("curl.1");
END
+OPTION(check-permissions,p,,
+ [<check if the requested action is permitted for current account>])
+BEGIN
+ ec2_param_list_append(&extra_param, "DryRun", "true");
+END
+
OPTION(dump-grammar-trace,,,
[<dump configuration grammar traces>])
BEGIN
grecs_gram_trace (1);
END
@@ -276,12 +282,22 @@ OPTION(debug,d,CAT[.LEVEL],
BEGIN
if (parse_debug_level(optarg)) {
die(EX_USAGE, "invalid debugging category or level");
}
END
+OPTION(add-parameter,A,NAME=VALUE,
+ [<pass additional parameter to the AWS request>])
+BEGIN
+ char *p = strchr(optarg, '=');
+ if (!p)
+ die(EX_USAGE, "malformed parameter: %s", optarg);
+ *p++ = 0;
+ ec2_param_list_append(&extra_param, optarg, p);
+END
+
GROUP([<Additional help>])
OPTION(config-help,,,
[<show configuration file summary>])
BEGIN
config_help();
exit(0);
diff --git a/src/eclat.c b/src/eclat.c
index 8cadebd..69efa8e 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -40,12 +40,14 @@ char *format_file_option;
char *format_name_option;
int sort_option;
char *format_file;
char *test_map_name;
enum eclat_confirm_mode confirm_mode;
int translate_option = -1;
+struct grecs_list *extra_param;
+
FILE *xml_dump_file;
static char *categories[] = {
"main",
@@ -563,15 +565,16 @@ find_format(const char *name)
forlan_eval_env_t env;
if (!format_table)
return NULL;
key.name = (char*) name;
defn = grecs_symtab_lookup_or_install(format_table, &key, NULL);
- if (!defn)
+ if (!defn) {
+ err("no such format: %s", name);
return NULL;
-
+ }
env = forlan_parse_buffer(defn->text, strlen(defn->text),
&defn->locus.beg);
return env;
}
static forlan_eval_env_t
@@ -653,12 +656,13 @@ eclat_do_command(eclat_command_env_t *env, struct eclat_command *command,
if (use_post)
flags |= EC2_RF_POST;
env->request = eclat_request_create(flags,
endpoint, "/",
region_name, access_key,
security_token);
+ eclat_request_add_param_list(env->request, extra_param);
}
if (command->tag)
eclat_request_add_param(env->request, "Action", command->tag);
rc = command->handler(env, argc, argv);
diff --git a/src/startstop.c b/src/startstop.c
index f5346c4..98f4e12 100644
--- a/src/startstop.c
+++ b/src/startstop.c
@@ -58,25 +58,29 @@ eclat_start_instance(eclat_command_env_t *env, int argc, char **argv)
argc, argv, &i);
debug(ECLAT_DEBCAT_MAIN, 1, ("starting instances"));
return start_stop_instance(env, argc - i, argv + i);
}
+
+static int force;
+
+#include "stop-cl.h"
+
int
eclat_stop_instance(eclat_command_env_t *env, int argc, char **argv)
{
int i;
- parse_options(env->cmd,
- "Stop named instances",
- argc, argv, &i);
-
+ parse_stop_options(env, argc, argv, &i);
debug(ECLAT_DEBCAT_MAIN, 1, ("stopping instances"));
+ if (force)
+ eclat_request_add_param(env->request, "Force", "1");
return start_stop_instance(env, argc - i, argv + i);
}
-
+
int
eclat_reboot_instance(eclat_command_env_t *env, int argc, char **argv)
{
int i;
parse_options(env->cmd,
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 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012-2015 Sergey Poznyakoff.
+
+ Eclat is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Eclat is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+ECLAT_CL_BEGIN([<Stop named instances>],
+ [<ID [ID...]>])
+
+
+OPTION(force,f,,
+ [<force stopping the instance>])
+BEGIN
+ force = 1;
+END
+
+ECLAT_CL_END
+
+ECLAT_CL_PARSER(parse_stop_options, [<int argc, char *argv[], int *index>], [<
+{
+ GETOPT(argc, argv, *index)
+}
+>]) \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.