summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-21 08:32:27 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-05-21 08:32:27 (GMT)
commitf5f9ad5a144999f7c788119cc21d967734ae0dba (patch) (side-by-side diff)
treec65c817e401c8264212e1b7abad9ac2fa18ece94
parentdc2eda2489f6f8e9bd699c3968edd0710b3adb73 (diff)
downloadeclat-f5f9ad5a144999f7c788119cc21d967734ae0dba.tar.gz
eclat-f5f9ad5a144999f7c788119cc21d967734ae0dba.tar.bz2
Various minor fixes.
* doc/eclat.conf.5: Document EC2 maps. * etc/eclat.cfin: Provide default maps. * lib/Makefile.am (AM_LFLAGS): Remove -v. * lib/bidimap.c (cb_submap): Remove unused variable. * lib/forlan.c: Minor change. * lib/forlangrm.y: Declare prototype for yylex. * lib/forlanlex.l: Add option nounput * lib/libeclat.h (eclat_map) <locus>: New member. * lib/map.c (eclat_map_config): Warn if attempting to redeclare an existing map. * src/ec2map.c (ec2_map_get): Minor change.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--doc/eclat.conf.544
-rw-r--r--etc/eclat.cfin39
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/bidimap.c2
-rw-r--r--lib/forlan.c33
-rw-r--r--lib/forlangrm.y1
-rw-r--r--lib/forlanlex.l2
-rw-r--r--lib/libeclat.h1
-rw-r--r--lib/map.c9
-rw-r--r--src/ec2map.c2
10 files changed, 114 insertions, 21 deletions
diff --git a/doc/eclat.conf.5 b/doc/eclat.conf.5
index 30b5b81..8905450 100644
--- a/doc/eclat.conf.5
+++ b/doc/eclat.conf.5
@@ -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.CONF 5 "April 26, 2013" "ECLAT" "Eclat User Reference"
+.TH ECLAT.CONF 5 "May 21, 2013" "ECLAT" "Eclat User Reference"
.SH NAME
eclat.conf \- configuration file for
.BR eclat (1).
@@ -868,6 +868,48 @@ This statement is mandatory.
\fBdebug\fR \fIn\fR
Sets the LDAP debug number. Refer to the OpenLDAP documentation for
the valid values of \fIn\fR and their meaning.
+.SS EC2 MAP
+This map makes it possible to use \fBEC2\fR services to translate
+identifiers. The idea is to query \fBEC2\fR using the symbolic ID and
+obtain the real resource ID from the request. The map is defined as
+follows:
+.sp
+.nf
+ map <name: string> {
+ type ec2;
+ key \fItrans\fR;
+ action \fIaction-name\fR;
+ arguments \fIarg-list\fR;
+ return \fIreturn-path\fR;
+ }
+.fi
+.sp
+.TP
+\fBaction\fR \fIaction-name\fR
+Defines the \fBEC2\fR action name to use. Refer to the Amazon API
+documentation for a list of action names.
+.TP
+\fBarguments\fR \fIarg-list\fR
+Defines the list of arguments to send with the request. Any
+occurrence of the \fB$key\fR variable within that list is replaced
+with the actual key value.
+.TP
+\fBreturn\fR \fIreturn-path\fR
+Defines the return value, using a path notation.
+.PP
+The example below illustrates the use of the \fBDescribeImages\fR
+action to implement the \fBImageId\fR map:
+.sp
+.nf
+ map "ImageId" {
+ type ec2;
+ action DescribeImages;
+ arguments ("Owner.1=self",
+ "Filter.1.Name=tag:Name",
+ "Filter.1.Value.1=${key}");
+ return ".DescribeImagesResponse.imagesSet.item.imageId";
+ }
+.fi
.SH "SEE ALSO"
.BR eclat (1),
.BR m4 (1).
diff --git a/etc/eclat.cfin b/etc/eclat.cfin
index 755187a..dc49368 100644
--- a/etc/eclat.cfin
+++ b/etc/eclat.cfin
@@ -31,3 +31,42 @@ format-file "FORMATDIR/FORMATNAME.forlan";
# Ask for confirmation before running a destructive command.
confirm tty destructive;
+# #####################################################################
+# Sample resource maps.
+#
+# These maps use the Describe* EC2 requests to translate symbolic
+# resource names to the corresponding IDs. The resource name should be
+# stored in the Name tag of the corresponding resource.
+# #####################################################################
+
+map "InstanceId" {
+ type ec2;
+ action DescribeInstances;
+ arguments ("Filter.1.Name=tag:Name", "Filter.1.Value.1=${key}");
+ return ".DescribeInstancesResponse.reservationSet.item.instancesSet.item.instanceId";
+}
+
+map "ImageId" {
+ type ec2;
+ action DescribeImages;
+ arguments ("Owner.1=self",
+ "Filter.1.Name=tag:Name",
+ "Filter.1.Value.1=${key}");
+ return ".DescribeImagesResponse.imagesSet.item.imageId";
+}
+
+map "VolumeId" {
+ type ec2;
+ action DescribeVolumes;
+ arguments ("Filter.1.Name=tag:Name", "Filter.1.Value.1=${key}");
+ return ".DescribeVolumesResponse.volumeSet.item.volumeId";
+}
+
+map "SnapshotId" {
+ type ec2;
+ action DescribeSnapshots;
+ arguments ("Owner.1=self",
+ "Filter.1.Name=tag:Name",
+ "Filter.1.Value.1=${key}");
+ return ".DescribeSnapshotsResponse.snapshotSet.snapshotId";
+}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d6eaa56..f669a4f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -67,7 +67,7 @@ forlanlex.c: forlangrm.h
forlangrm.c forlangrm.h: forlangrm.y
AM_YFLAGS=-tdv
-AM_LFLAGS=-dvp
+AM_LFLAGS=-dp
diff --git a/lib/bidimap.c b/lib/bidimap.c
index a095831..b3e7554 100644
--- a/lib/bidimap.c
+++ b/lib/bidimap.c
@@ -33,7 +33,7 @@ cb_submap(enum grecs_callback_command cmd,
void *cb_data)
{
struct submap *submap = varptr;
- char *name, *q;
+ char *q;
int dir;
if (cmd != grecs_callback_set_value) {
diff --git a/lib/forlan.c b/lib/forlan.c
index ecdb7a3..d2f1c69 100644
--- a/lib/forlan.c
+++ b/lib/forlan.c
@@ -726,21 +726,24 @@ struct forlan_node_method {
};
static struct forlan_node_method f_tab[] = {
- free_type_null, dump_null, eval_null, /* Unknown/unset type */
- free_type_comp, dump_comp, eval_comp, /* A path component */
- free_type_test, dump_test, eval_test, /* Value test (f[X]) */
- free_type_func, dump_func, eval_func, /* Function call */
- free_type_cond, dump_cond, eval_cond, /* Conditional */
- free_type_stmt, dump_stmt, eval_stmt, /* Statement */
- free_type_lit, dump_lit, eval_lit, /* Literal */
- free_type_expr, dump_expr, eval_expr, /* Boolean expression */
- free_type_last, dump_last, eval_last, /* "last" */
- free_type_asgn, dump_asgn, eval_asgn, /* Variable assignment */
- free_type_var, dump_var, eval_var, /* Variable reference */
- free_type_loop, dump_loop, eval_loop, /* Loop */
- NULL, dump_continue, eval_continue, /* continue statement */
- NULL, dump_break, eval_break, /* break statement */
- NULL, dump_stop, eval_stop, /* stop statement */
+ { free_type_null, dump_null, eval_null }, /* Unknown/unset type */
+ { free_type_comp, dump_comp, eval_comp }, /* A path component */
+ { free_type_test, dump_test, eval_test }, /* Value test (f[X]) */
+ { free_type_func, dump_func, eval_func }, /* Function call */
+ { free_type_cond, dump_cond, eval_cond }, /* Conditional */
+ { free_type_stmt, dump_stmt, eval_stmt }, /* Statement */
+ { free_type_lit, dump_lit, eval_lit }, /* Literal */
+ { free_type_expr, dump_expr, eval_expr }, /* Boolean expression */
+ { free_type_last, dump_last, eval_last }, /* "last" */
+ { free_type_asgn, dump_asgn, eval_asgn }, /* Variable assignment */
+ { free_type_var, dump_var, eval_var }, /* Variable reference */
+ { free_type_loop, dump_loop, eval_loop }, /* Loop */
+ { NULL, dump_continue, eval_continue }, /* continue
+ statement */
+ { NULL, dump_break, eval_break }, /* break
+ statement */
+ { NULL, dump_stop, eval_stop }, /* stop
+ statement */
};
void
diff --git a/lib/forlangrm.y b/lib/forlangrm.y
index 689d0e2..64210a4 100644
--- a/lib/forlangrm.y
+++ b/lib/forlangrm.y
@@ -22,6 +22,7 @@
#include "forlan.h"
#include <string.h>
+int yylex();
static int yyerror(char *);
union forlan_node *forlan_parse_tree;
size_t forlan_variable_count;
diff --git a/lib/forlanlex.l b/lib/forlanlex.l
index 423372e..c1261e5 100644
--- a/lib/forlanlex.l
+++ b/lib/forlanlex.l
@@ -56,6 +56,8 @@ static int yywrap(void);
%}
+%option nounput
+
WS [ \t\f][ \t\f]*
IDC [a-zA-Z_0-9-]
%x COMMENT ML STR
diff --git a/lib/libeclat.h b/lib/libeclat.h
index 733a46d..0e8868b 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -139,6 +139,7 @@ struct eclat_map_drv {
struct eclat_map {
char *name;
+ struct grecs_locus locus;
char *keytrans;
struct eclat_map_drv *drv;
void *data;
diff --git a/lib/map.c b/lib/map.c
index c3c9c9f..725540b 100644
--- a/lib/map.c
+++ b/lib/map.c
@@ -135,8 +135,10 @@ eclat_map_config(struct grecs_node *node, struct eclat_map **return_map)
mapname);
map = eclat_map_lookup(mapname);
if (map) {
- debug(map_dbg, 1,
- ("map \"%s\" already configured", mapname));
+ diag(&node->locus, "warning",
+ "map \"%s\" already declared", mapname);
+ diag(&map->locus, "warning",
+ "this is the location of the previous declaration");
*return_map = map;
return eclat_map_ok;
}
@@ -183,6 +185,9 @@ eclat_map_config(struct grecs_node *node, struct eclat_map **return_map)
if (eclat_get_string_node(node, "key", 1, &p) == 0)
map->keytrans = grecs_strdup(p->v.value->v.string);
+ /* FIXME: See eclat.c:708 */
+ map->locus = node->locus;
+
debug(map_dbg, 1, ("map \"%s\" configured", mapname));
*return_map = map;
diff --git a/src/ec2map.c b/src/ec2map.c
index 6eb7e8b..7abecd2 100644
--- a/src/ec2map.c
+++ b/src/ec2map.c
@@ -142,7 +142,7 @@ ec2_map_get(int dbg, int dir, void *data, const char *key, char **return_value)
struct grecs_list_entry *ep;
struct wordsplit ws;
int wsflags;
- char *env[3];
+ char const *env[3];
struct grecs_node *tree, *node;
int rc;

Return to:

Send suggestions and report system problems to the System administrator.