aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS20
-rw-r--r--doc/eclat-stop.18
-rw-r--r--doc/eclat.1man10
-rw-r--r--etc/default.fln11
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/forlan.c17
-rw-r--r--lib/libeclat.h9
-rw-r--r--lib/paramlist.c57
-rw-r--r--lib/reqcreat.c2
-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
14 files changed, 194 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index 781203c..ed97650 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
-Eclat NEWS -- history of user-visible changes. 2015-01-23
+Eclat NEWS -- history of user-visible changes. 2015-02-02
Copyright (C) 2012-2015 Sergey Poznyakoff
See the end of file for copying conditions.
Please send Eclat bug reports to <gray+eclat@gnu.org.ua>
@@ -9,12 +9,30 @@ Version 1.0.92, (Git)
* New commands:
lsaattr describe-image-attribute
setaattr modify-image-attribute
+* New options:
+
+ -A, --add-parameter=NAME=VALUE
+
+Adds parameter NAME with the given VALUE to the generated AWS request.
+This option is intended for testing new AWS functionality for which
+eclat does not yet provide native support.
+
+ -p, --check-permissions
+
+Checks if you have the required permissions for the action, without
+actually making the request.
+
+* forcibly stop the instance
+
+eclat stop now supports -f (--force) option, which stops the instance
+forcibly.
+
* Implement signature version 4 signing
The signature version 4 signing process is now the default. Version
2 can enabled by using the following statement in the eclat
configuration file:
diff --git a/doc/eclat-stop.1 b/doc/eclat-stop.1
index 5adbe61..a8f61a8 100644
--- a/doc/eclat-stop.1
+++ b/doc/eclat-stop.1
@@ -10,23 +10,27 @@
.\" 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/>.
-.TH ECLAT-STOP 1 "January 26, 2015" "ECLAT" "Eclat User Reference"
+.TH ECLAT-STOP 1 "February 2, 2015" "ECLAT" "Eclat User Reference"
.SH NAME
eclat-stop, eclat-stop-instances \- stop EC2 instances
.SH SYNOPSIS
-\fBeclat stop\fR \fIID\fR [\fIID\fR...]
+\fBeclat stop\fR [\fB\-f\fR] [\fB\-\-force\fR] \fIID\fR [\fIID\fR...]
.PP
\fBeclat stop\fR \fB\-\-help\fR
.SH DESCRIPTION
The command
.B stop
stops running Amazon EBS-backed instances.
+.SH OPTIONS
+.TP
+\fB\-f\fR, \fB\-\-force\fR
+Forcibly stop the instance.
.SH OUTPUT
The default output format lists on each line the instance ID, its
previous and current states, separated by single horizontal tab
characters.
.SH "SEE ALSO"
.BR eclat (1),
diff --git a/doc/eclat.1man b/doc/eclat.1man
index 50cc3e2..829bec6 100644
--- a/doc/eclat.1man
+++ b/doc/eclat.1man
@@ -10,13 +10,13 @@
.\" 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/>.
-.TH ECLAT 1 "January 21, 2015" "ECLAT" "Eclat User Reference"
+.TH ECLAT 1 "February 2, 2015" "ECLAT" "Eclat User Reference"
.SH NAME
eclat \- EC2 Command Line Administrator Tool
.SH SYNOPSIS
.B eclat
[\fIOPTIONS\fR]
.B command
@@ -463,12 +463,20 @@ Set debugging level.
.TP
\fB\-\-dump\-grammar\-trace\fR
Dump configuration grammar traces.
.TP
\fB\-\-dump\-lex\-trace\fR
Dump lexical analyzer traces.
+.TP
+\fB\-p\fR, \fB\-\-check\-permissions\fR
+Check if you have the required permissions for the action, without
+actually making the request. This is equivalent to
+\fB\-\-add\-parameter=DryRun=true\fR.
+.TP
+\fB\-A\fR, \fB\-\-add\-parameter=\fINAME\fB=\fIVALUE\fR
+Add parameter to the AWS request.
.SS Help and additional information
.TP
\fB\-\-config\-help
Show configuration file summary.
.TP
\fB\-V\fR, \fB\-\-version\fR
diff --git a/etc/default.fln b/etc/default.fln
index 178af18..d3da5eb 100644
--- a/etc/default.fln
+++ b/etc/default.fln
@@ -12,13 +12,20 @@
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/>. */
if (.Response.Errors) {
- error("Error: ",.Response.Errors.Error.Message,"\n");
- exit(1);
+ if (.Response.Errors.Error.Code[DryRunOperation]) {
+ print(dequote(.Response.Errors.Error.Message),"\n");
+ } else if (.Response.Errors.Error.Code[UnauthorizedOperation]) {
+ error(dequote(.Response.Errors.Error.Message),"\n");
+ exit(1);
+ } else {
+ error("Error: ",dequote(.Response.Errors.Error.Message),"\n");
+ exit(1);
+ }
} else {
error("Unrecognized response:\n");
dump(.);
exit(2);
}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5cfa67a..711bc98 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -50,12 +50,13 @@ libeclat_a_SOURCES=\
getans.c\
getyn.c\
hmac_sha1.c\
hmac_sha256.c\
libeclat.h\
map.c\
+ paramlist.c\
path.c\
req2url.c\
reqaddparm.c\
reqcreat.c\
reqencode.c\
reqfree.c\
diff --git a/lib/forlan.c b/lib/forlan.c
index 2275bc7..977271d 100644
--- a/lib/forlan.c
+++ b/lib/forlan.c
@@ -1046,12 +1046,28 @@ func_decode(forlan_eval_env_t env, struct grecs_list *list)
grecs_txtacc_grow_char(acc, 0);
env->retval.v.string = grecs_txtacc_finish(acc, 1);
grecs_txtacc_free(acc);
}
static void
+func_dequote(forlan_eval_env_t env, struct grecs_list *list)
+{
+ struct forlan_value *val = list->head->data;
+ char *s = val->v.string;
+ size_t l = strlen(s);
+
+ if (l >= 2 && s[0] == '"' && s[l-1] == '"') {
+ s++;
+ l -= 2;
+ }
+ env->retval.v.string = grecs_malloc(l + 1);
+ memcpy(env->retval.v.string, s, l);
+ env->retval.v.string[l] = 0;
+}
+
+static void
func_exit(forlan_eval_env_t env, struct grecs_list *list)
{
struct forlan_value *val = list->head->data;
unsigned long code;
char *p;
@@ -1124,12 +1140,13 @@ static struct forlan_function functab[] = {
{ "dump", forlan_value_void, "n", 1, 1, func_dump },
{ "print", forlan_value_void, "", 1, -1, func_print },
{ "error", forlan_value_void, "", 1, -1, func_error },
{ "parent", forlan_value_node, "n", 1, 1, func_parent },
{ "sort", forlan_value_void, "nss", 1, 3, func_sort },
{ "decode", forlan_value_literal, "s", 1, 1, func_decode },
+ { "dequote", forlan_value_literal, "s", 1, 1, func_dequote },
{ "exit", forlan_value_void, "s", 1, 1, func_exit },
{ "empty", forlan_value_boolean, "n", 1, 1, func_empty },
{ "timestamp", forlan_value_literal, "s", 1, 1, func_timestamp },
{ "lookup", forlan_value_literal, "ss", 2, 2, func_lookup },
{ "has_map",forlan_value_boolean, "s", 1, 1, func_has_map },
{ NULL }
diff --git a/lib/libeclat.h b/lib/libeclat.h
index b33f0a2..770fb7d 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -102,12 +102,14 @@ struct ec2_request {
};
struct ec2_request *eclat_request_create(int flags, const char *endpoint,
const char *uri, char const *region,
char const *access_key, char const *token);
void eclat_request_free(struct ec2_request *);
+void eclat_request_add_param0(struct ec2_request *req, const char *name,
+ const char *value, int encoded);
void eclat_request_add_param(struct ec2_request *req, const char *name,
const char *value);
void eclat_request_add_param_encoded(struct ec2_request *req, const char *name,
const char *value);
void eclat_request_add_header(struct ec2_request *req, const char *name,
const char *value);
@@ -116,12 +118,19 @@ void eclat_request_sign(struct ec2_request *req, char *secret, char *version);
char *eclat_request_to_url(struct ec2_request *req);
void eclat_request_encode(struct ec2_request *req);
void eclat_request_finalize(struct ec2_request *req);
+void ec2_param_free(void *ptr);
+
+struct grecs_list *ec2_param_list_create(void);
+void ec2_param_list_append(struct grecs_list **lp, char const *name,
+ char const *val);
+void eclat_request_add_param_list(struct ec2_request *req,
+ struct grecs_list *lp);
typedef struct eclat_partial_tree *eclat_partial_tree_t;
eclat_partial_tree_t eclat_partial_tree_create(void);
void eclat_partial_tree_destroy(eclat_partial_tree_t);
struct grecs_node *eclat_partial_tree_finish(eclat_partial_tree_t);
diff --git a/lib/paramlist.c b/lib/paramlist.c
new file mode 100644
index 0000000..6d6c40a
--- /dev/null
+++ b/lib/paramlist.c
@@ -0,0 +1,57 @@
+/* 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/>. */
+
+#include <config.h>
+#include <string.h>
+#include "libeclat.h"
+#include "grecs.h"
+
+struct grecs_list *
+ec2_param_list_create()
+{
+ struct grecs_list *lp = grecs_list_create();
+ lp->free_entry = ec2_param_free;
+ return lp;
+}
+
+void
+ec2_param_list_append(struct grecs_list **lpp, char const *name,
+ char const *val)
+{
+ struct ec2_param *p;
+ if (!*lpp)
+ *lpp = ec2_param_list_create();
+ p = grecs_zalloc(sizeof(*p));
+ p->name = grecs_strdup(name);
+ p->value = grecs_strdup(val);
+ p->encoded = 0;
+ grecs_list_append(*lpp, p);
+}
+
+void
+eclat_request_add_param_list(struct ec2_request *req, struct grecs_list *lp)
+{
+ struct grecs_list_entry *ep;
+
+ if (!lp)
+ return;
+ for (ep = lp->head; ep; ep = ep->next) {
+ struct ec2_param *param = ep->data;
+ eclat_request_add_param0(req,
+ param->name, param->value,
+ param->encoded);
+ }
+}
diff --git a/lib/reqcreat.c b/lib/reqcreat.c
index 65f7880..58d7829 100644
--- a/lib/reqcreat.c
+++ b/lib/reqcreat.c
@@ -15,13 +15,13 @@
along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "libeclat.h"
#include "grecs.h"
-static void
+void
ec2_param_free(void *ptr)
{
struct ec2_param *p = ptr;
free(p->name);
free(p->value);
free(p);
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.