summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-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,4 +1,4 @@
-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.
@@ -12,6 +12,24 @@ Version 1.0.92, (Git)
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
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
@@ -13,17 +13,21 @@
.\"
.\" 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
diff --git a/doc/eclat.1man b/doc/eclat.1man
index 50cc3e2..829bec6 100644
--- a/doc/eclat.1man
+++ b/doc/eclat.1man
@@ -13,7 +13,7 @@
.\"
.\" 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
@@ -466,6 +466,14 @@ 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
diff --git a/etc/default.fln b/etc/default.fln
index 178af18..d3da5eb 100644
--- a/etc/default.fln
+++ b/etc/default.fln
@@ -15,8 +15,15 @@
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(.);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5cfa67a..711bc98 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -53,6 +53,7 @@ libeclat_a_SOURCES=\
hmac_sha256.c\
libeclat.h\
map.c\
+ paramlist.c\
path.c\
req2url.c\
reqaddparm.c\
diff --git a/lib/forlan.c b/lib/forlan.c
index 2275bc7..977271d 100644
--- a/lib/forlan.c
+++ b/lib/forlan.c
@@ -1049,6 +1049,22 @@ func_decode(forlan_eval_env_t env, struct grecs_list *list)
}
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;
@@ -1127,6 +1143,7 @@ static struct forlan_function functab[] = {
{ "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 },
diff --git a/lib/libeclat.h b/lib/libeclat.h
index b33f0a2..770fb7d 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -105,6 +105,8 @@ 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,
@@ -119,6 +121,13 @@ 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;
diff --git a/lib/paramlist.c b/lib/paramlist.c
new file mode 100644
index 0000000..6d6c40a
--- a/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
@@ -18,7 +18,7 @@
#include "libeclat.h"
#include "grecs.h"
-static void
+void
ec2_param_free(void *ptr)
{
struct ec2_param *p = ptr;
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=\
rmsg-cl.opt\
sg-cl.opt\
setiattr-cl.opt\
- setaattr-cl.opt
+ setaattr-cl.opt\
+ stop-cl.opt
eclat_SOURCES += $(OPTFILES:.opt=.h)
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
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
@@ -279,6 +285,16 @@ BEGIN
}
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>])
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;
char *test_map_name;
enum eclat_confirm_mode confirm_mode;
int translate_option = -1;
+struct grecs_list *extra_param;
+
FILE *xml_dump_file;
@@ -566,9 +568,10 @@ find_format(const char *name)
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;
@@ -656,6 +659,7 @@ eclat_do_command(eclat_command_env_t *env, struct eclat_command *command,
endpoint, "/",
region_name, access_key,
security_token);
+ eclat_request_add_param_list(env->request, extra_param);
}
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,19 +61,23 @@ eclat_start_instance(eclat_command_env_t *env, int argc, char **argv)
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)
{
diff --git a/src/stop-cl.opt b/src/stop-cl.opt
new file mode 100644
index 0000000..a2aae61
--- a/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.