aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-21 11:32:27 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-05-21 11:32:27 +0300
commitf5f9ad5a144999f7c788119cc21d967734ae0dba (patch)
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.
-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
@@ -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.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).
.SH DESCRIPTION
.PP
.B Eclat
@@ -865,12 +865,54 @@ Defines the attribute to use for the return value.
.sp
This statement is mandatory.
.TP
\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).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
diff --git a/etc/eclat.cfin b/etc/eclat.cfin
index 755187a..dc49368 100644
--- a/etc/eclat.cfin
+++ b/etc/eclat.cfin
@@ -28,6 +28,45 @@ region sa-east-1 ec2.sa-east-1.amazonaws.com;
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
@@ -64,10 +64,10 @@ AM_LDFLAGS = $(CURL_LIBS)
AM_CPPFLAGS = -I$(top_srcdir)/grecs/src/ $(CURL_CFLAGS)
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
@@ -30,13 +30,13 @@ cb_submap(enum grecs_callback_command cmd,
grecs_locus_t *locus,
void *varptr,
grecs_value_t *value,
void *cb_data)
{
struct submap *submap = varptr;
- char *name, *q;
+ char *q;
int dir;
if (cmd != grecs_callback_set_value) {
grecs_error(locus, 0, "Unexpected block statement");
return 1;
}
diff --git a/lib/forlan.c b/lib/forlan.c
index ecdb7a3..d2f1c69 100644
--- a/lib/forlan.c
+++ b/lib/forlan.c
@@ -723,27 +723,30 @@ struct forlan_node_method {
void (*f_free)(union forlan_node *);
void (*f_dump)(FILE *fp, union forlan_node *node, int *num, int lev);
void (*f_eval)(forlan_eval_env_t, union forlan_node *node);
};
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
forlan_node_free(union forlan_node *p)
{
if (!p)
diff --git a/lib/forlangrm.y b/lib/forlangrm.y
index 689d0e2..64210a4 100644
--- a/lib/forlangrm.y
+++ b/lib/forlangrm.y
@@ -19,12 +19,13 @@
#include <grecs.h>
#include <grecs-locus.h>
#include "forlangrm.h"
#include "forlan.h"
#include <string.h>
+int yylex();
static int yyerror(char *);
union forlan_node *forlan_parse_tree;
size_t forlan_variable_count;
static struct grecs_symtab *forlan_symtab;
static size_t find_variable(const char *name);
diff --git a/lib/forlanlex.l b/lib/forlanlex.l
index 423372e..c1261e5 100644
--- a/lib/forlanlex.l
+++ b/lib/forlanlex.l
@@ -53,12 +53,14 @@ static size_t forlan_input_pos;
} while (0);
static int yywrap(void);
%}
+%option nounput
+
WS [ \t\f][ \t\f]*
IDC [a-zA-Z_0-9-]
%x COMMENT ML STR
%%
/* Comments */
"/*" BEGIN(COMMENT);
diff --git a/lib/libeclat.h b/lib/libeclat.h
index 733a46d..0e8868b 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -136,12 +136,13 @@ struct eclat_map_drv {
void (*map_free)(int, void *);
void (*map_confhelp)(void);
};
struct eclat_map {
char *name;
+ struct grecs_locus locus;
char *keytrans;
struct eclat_map_drv *drv;
void *data;
int flags;
};
diff --git a/lib/map.c b/lib/map.c
index c3c9c9f..725540b 100644
--- a/lib/map.c
+++ b/lib/map.c
@@ -132,14 +132,16 @@ eclat_map_config(struct grecs_node *node, struct eclat_map **return_map)
if (debug_level(map_dbg) > 1)
diag(&node->locus, "debug", "configuring map \"%s\"",
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;
}
if (eclat_get_string_node(node, "type", 0, &p))
return eclat_map_failure;
@@ -180,12 +182,15 @@ eclat_map_config(struct grecs_node *node, struct eclat_map **return_map)
return eclat_map_failure;
}
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;
return eclat_map_ok;
}
diff --git a/src/ec2map.c b/src/ec2map.c
index 6eb7e8b..7abecd2 100644
--- a/src/ec2map.c
+++ b/src/ec2map.c
@@ -139,13 +139,13 @@ ec2_map_get(int dbg, int dir, void *data, const char *key, char **return_value)
{
struct ec2_map *map = data;
struct ec2_query *q;
struct grecs_list_entry *ep;
struct wordsplit ws;
int wsflags;
- char *env[3];
+ char const *env[3];
struct grecs_node *tree, *node;
int rc;
q = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/");
eclat_query_add_param(q, "Action", map->action);

Return to:

Send suggestions and report system problems to the System administrator.