summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-28 08:23:09 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2012-09-28 08:32:04 (GMT)
commitac1d6cbbcf5323d5db59886b98a24c45bafa64b8 (patch) (side-by-side diff)
treef2a77092e072faa680b47d9d6d960e7214e46876
parentd902742081bc31a6eda274268da0178107e4abb4 (diff)
downloadeclat-ac1d6cbbcf5323d5db59886b98a24c45bafa64b8.tar.gz
eclat-ac1d6cbbcf5323d5db59886b98a24c45bafa64b8.tar.bz2
Improve testsuite. Reorganize directory structure.
* Makefile.am (SUBDIRS): Add etc (distuninstallcheck_listfiles): Ignore *.forlan files. * configure.ac: New options --split-format and --format-dir * etc/Makefile.am: New file. * etc/default.fln: New file. * etc/describe-instance-status.fln: New file. * etc/describe-instances.fln: New file. * etc/describe-tags.fln: New file. * etc/eclat.cfin: New file. * etc/flncat.c: New file. * etc/start-instances.fln: New file. * etc/stop-instances.fln: New file. * src/Makefile.am: Remove eclat.conf. It is built in /etc now. * src/eclat.conf: Remove. * src/cmdline.opt: Update. * src/config.c: New configuration statement "format-file". * src/eclat.c (format_file_option): New global. (main): Read format from format-file, if supplied. Expand keywords in its argument. * src/eclat.h (format_file_option): New extern. * tests/.gitignore: Update. * tests/Makefile.am: Add new files. * tests/describe-instance-status.at: New test case. * tests/describe-instances.at: New test case. * tests/describe-tags.at: New test case. * tests/dscrinststat.at: New test case. * tests/start-instances.at: New test case. * tests/stop-instances.at: New test case. * tests/testsuite.at (ECLAT_TEST_FORMAT): New macro. Include new test cases. * tests/trws.c: New file.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac26
-rw-r--r--etc/.gitignore3
-rw-r--r--etc/Makefile.am60
-rw-r--r--etc/default.fln22
-rw-r--r--etc/describe-instance-status.fln36
-rw-r--r--etc/describe-instances.fln69
-rw-r--r--etc/describe-tags.fln24
-rw-r--r--etc/eclat.cfin32
-rw-r--r--etc/flncat.c94
-rw-r--r--etc/start-instances.fln23
-rw-r--r--etc/stop-instances.fln23
-rw-r--r--src/Makefile.am8
-rw-r--r--src/cmdline.opt2
-rw-r--r--src/config.c4
-rw-r--r--src/eclat.c72
-rw-r--r--src/eclat.conf165
-rw-r--r--src/eclat.h1
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/describe-instance-status.at154
-rw-r--r--tests/describe-instances.at274
-rw-r--r--tests/describe-tags.at68
-rw-r--r--tests/dscrinststat.at128
-rw-r--r--tests/start-instances.at38
-rw-r--r--tests/stop-instances.at39
-rw-r--r--tests/testsuite.at17
-rw-r--r--tests/trws.c46
28 files changed, 1245 insertions, 194 deletions
diff --git a/Makefile.am b/Makefile.am
index 171250b..d78d1f6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,7 @@
ACLOCAL_AMFLAGS = -I grecs/am
-SUBDIRS = grecs lib src tests
+SUBDIRS = grecs lib src etc tests
.PHONY: ChangeLog
ChangeLog:
@@ -25,4 +25,4 @@ ChangeLog:
awk -f $(top_srcdir)/grecs/build-aux/git2chg.awk > ChangeLog; \
fi
-distuninstallcheck_listfiles = find . -type f -not -name 'eclat.conf' -print
+distuninstallcheck_listfiles = find . -type f -not -name 'eclat.conf' -not -name '*.forlan' -print
diff --git a/configure.ac b/configure.ac
index 8f8ccfc..7c744ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,29 @@ AC_CHECK_LIB([expat], [XML_Parse],[],
GRECS_SETUP([grecs],[tests getopt git2chg])
+#
+AC_SUBST(FORMATDIR)
+AC_ARG_ENABLE([split-format],
+ [AC_HELP_STRING([--enable-split-format],
+ [build split format files])],
+ [split_fmt=$enableval],
+ [split_fmt=no])
+
+if test $split_fmt = yes; then
+ FORMATDIR="\$(sysconfdir)/\$(PACKAGE)"
+else
+ FORMATDIR="\$(sysconfdir)"
+fi
+AM_CONDITIONAL([SPLIT_FORMATS],[test $split_fmt = yes])
+
+AC_ARG_WITH([format-dir],
+ [AC_HELP_STRING([--format-dir=DIR],
+ [install format files to that directory])],
+ [case $withval in
+ /*) FORMATDIR=$withval;;
+ *) FORMATDIR='$(prefix)/'$withval
+ esac])
+
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
@@ -70,7 +93,8 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_CONFIG_FILES([Makefile
lib/Makefile
- src/Makefile])
+ src/Makefile
+ etc/Makefile])
AC_OUTPUT
diff --git a/etc/.gitignore b/etc/.gitignore
new file mode 100644
index 0000000..b22bf5d
--- a/dev/null
+++ b/etc/.gitignore
@@ -0,0 +1,3 @@
+*.forlan
+eclat.conf
+flncat
diff --git a/etc/Makefile.am b/etc/Makefile.am
new file mode 100644
index 0000000..5eec565
--- a/dev/null
+++ b/etc/Makefile.am
@@ -0,0 +1,60 @@
+# This file is part of Eclat
+# Copyright (C) 2012 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/>.
+
+noinst_PROGRAMS = flncat
+
+FLNFILES=\
+ describe-instance-status.fln\
+ describe-instances.fln\
+ describe-tags.fln\
+ start-instances.fln\
+ stop-instances.fln
+
+EXTRA_DIST=$(FLNFILES) default.fln eclat.cfin
+
+noinst_SCRIPTS=eclat.conf
+CLEANFILES=eclat.conf
+SUFFIXES=.cfin .conf
+
+if SPLIT_FORMATS
+SUFFIXES += .forlan .fln
+.fln.forlan:
+ $(AM_V_GEN)$(abs_builddir)/flncat $< default.fln > $@
+formatdir = @FORMATDIR@
+noinst_SCRIPTS += $(FLNFILES:.fln=.forlan)
+CLEANFILES += $(FLNFILES:.fln=.forlan)
+FORMATNAME = $${command}
+else
+formatdir = @FORMATDIR@
+noinst_SCRIPTS += eclat.forlan
+CLEANFILES += eclat.forlan
+eclat.forlan: $(FLNFILES) default.fln
+ $(AM_V_GEN)(cd $(srcdir); $(abs_builddir)/flncat $(FLNFILES) default.fln) > eclat.forlan
+FORMATNAME = eclat
+endif
+
+.cfin.conf:
+ $(AM_V_GEN)sed 's^FORMATDIR^$(formatdir)^;s^FORMATNAME^$(FORMATNAME)^' $< > $@
+
+install-data-local:
+ @test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
+ @if [ -r $(DESTDIR)$(sysconfdir)/eclat.conf ]; then :; \
+ else ${INSTALL} -m 644 $(top_srcdir)/src/eclat.conf \
+ $(DESTDIR)$(sysconfdir)/eclat.conf; \
+ for file in $(noinst_SCRIPTS); do \
+ ${INSTALL} -m 644 $$file $(DESTDIR)$(formatdir)/$$file; \
+ done; \
+ fi
diff --git a/etc/default.fln b/etc/default.fln
new file mode 100644
index 0000000..2e2f690
--- a/dev/null
+++ b/etc/default.fln
@@ -0,0 +1,22 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+if (.Response.Errors)
+ error("Error: ",.Response.Errors.Error.Message,"\n");
+else {
+ error("Unrecognized response:\n");
+ dump(.);
+}
diff --git a/etc/describe-instance-status.fln b/etc/describe-instance-status.fln
new file mode 100644
index 0000000..85b88b3
--- a/dev/null
+++ b/etc/describe-instance-status.fln
@@ -0,0 +1,36 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+if (.DescribeInstanceStatusResponse.instanceStatusSet) {
+ for (var in .DescribeInstanceStatusResponse.instanceStatusSet.item) {
+ print(var.instanceId,"\t",
+ var.availabilityZone,"\t",
+ var.instanceState.name);
+ if (var.instanceState.name[running]) {
+ print("\t",var.systemStatus.status);
+ for (detail in var.systemStatus.details.item) {
+ print("\tSys.",detail.name,"=",detail.status);
+ }
+ for (detail in var.instanceStatus.details.item) {
+ print("\tInst.",detail.name,"=",detail.status);
+ }
+ }
+ print("\n");
+ for (event in var.eventsSet.item) {
+ error(var.instanceId,"\t","Event: ", event.description,"\n");
+ }
+ }
+}
diff --git a/etc/describe-instances.fln b/etc/describe-instances.fln
new file mode 100644
index 0000000..538aa5c
--- a/dev/null
+++ b/etc/describe-instances.fln
@@ -0,0 +1,69 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+if (.DescribeInstancesResponse.reservationSet) {
+ for (var in .DescribeInstancesResponse.reservationSet.item) {
+ print("Reservation ID: ", var.reservationId, "\n");
+ print("Owner ID: ", var.ownerId, "\n");
+ if (var.groupSet) {
+ print("Groups:\n");
+ for (grp in var.groupSet.item)
+ print("\t", grp.groupId,"\t", grp.groupName, "\n");
+ }
+ if (var.instancesSet) {
+ // print("Instances:\n");
+ for (inst in var.instancesSet.item) {
+ print("\nInstance: ", inst.instanceId, "\n");
+ print("\tImage ID: ", inst.imageId, "\n");
+ print("\tState: ", inst.instanceState.name, "\n");
+ print("\tKernel ID: ", inst.kernelId, "\n");
+ print("\tArchitecture: ", inst.architecture, "\n");
+ print("\tPrivate DNS: ", inst.privateDnsName, "\n");
+ print("\tPublic DNS: ", inst.dnsName, "\n");
+ print("\tKey: ", inst.keyName, "\n");
+ print("\tType: ", inst.instanceType, "\n");
+ print("\tLaunch Time: ", inst.launchTime, "\n");
+ print("\tAvailability Zone: ", inst.placement.availabilityZone, "\n");
+ print("\tGroup Name: ", inst.placement.groupName, "\n");
+ print("\tTenancy: ", inst.placement.tenancy, "\n");
+ print("\tPrivate IP: ", inst.privateIpAddress, "\n");
+ print("\tPublic IP: ", inst.ipAddress, "\n");
+ if (inst.groupSet.item) {
+ print("\tGroups:\n");
+ for (grp in inst.groupSet.item)
+ print("\t\t", inst.groupSet.item.groupId, " -- ", inst.groupSet.item.groupName, "\n");
+ }
+ print("\tRoot Device Type: ", inst.rootDeviceType, "\n");
+ print("\tRoot Device Name: ", inst.rootDeviceName, "\n");
+ print("\tDevice mapping:\n");
+ for (dev in inst.blockDeviceMapping.item) {
+ print("\t\t", dev.deviceName, " ", dev.ebs.volumeId, " ",
+ dev.ebs.status, " ", dev.ebs.attachTime, " ",
+ dev.ebs.deleteOnTermination, "\n");
+ }
+ print("\tVirtualization: ", inst.virtualizationType, "\n");
+ print("\tTag Set:\n");
+ for (tag in inst.tagSet.item) {
+ print("\t\t", tag.key, "=", tag.value, "\n");
+ }
+ print("\tHypervisor: ", inst.hypervisor, "\n");
+ // FIXME: networkInterfaceSet
+ print("\tEBS Optimized: ", inst.ebsOptimized, "\n");
+ print("End of instance\n\n");
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/etc/describe-tags.fln b/etc/describe-tags.fln
new file mode 100644
index 0000000..30d8798
--- a/dev/null
+++ b/etc/describe-tags.fln
@@ -0,0 +1,24 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+if (.DescribeTagsResponse) {
+ for (var in .DescribeTagsResponse.tagSet.item) {
+ print(var.resourceId,"\t",
+ var.resourceType,"\t",
+ var.key,"\t",
+ var.value,"\n");
+ }
+} \ No newline at end of file
diff --git a/etc/eclat.cfin b/etc/eclat.cfin
new file mode 100644
index 0000000..006f6d9
--- a/dev/null
+++ b/etc/eclat.cfin
@@ -0,0 +1,32 @@
+/* Default configuration file for Eclat.
+ *
+ * See eclat.conf(5) or run "info eclat configuration" for a detailed
+ * description.
+ */
+
+# Use this endpoint by default.
+default-endpoint "ec2.amazonaws.com";
+
+# Declare what endpoints to use for each availability region.
+# The syntax is:
+# region REGNAME ENDPOINT;
+
+# US East (Northern Virginia) Region
+region us-east-1 ec2.us-east-1.amazonaws.com;
+# US West (Oregon) Region
+region us-west-2 ec2.us-west-2.amazonaws.com;
+# US West (Northern California) Region
+region us-west-1 ec2.us-west-1.amazonaws.com;
+# EU (Ireland) Region
+region eu-west-1 ec2.eu-west-1.amazonaws.com;
+# Asia Pacific (Singapore) Region
+region ap-southeast-1 ec2.ap-southeast-1.amazonaws.com;
+# Asia Pacific (Tokyo) Region
+region ap-northeast-1 ec2.ap-northeast-1.amazonaws.com;
+# South America (Sao Paulo) Region
+region sa-east-1 ec2.sa-east-1.amazonaws.com;
+
+format-file "FORMATDIR/FORMATNAME.forlan";
+
+
+
diff --git a/etc/flncat.c b/etc/flncat.c
new file mode 100644
index 0000000..6f67e0e
--- a/dev/null
+++ b/etc/flncat.c
@@ -0,0 +1,94 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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 <stdio.h>
+#include <ctype.h>
+#include <assert.h>
+
+int
+comment(FILE *fp, int c)
+{
+ if (c != '/') {
+ ungetc(c, fp);
+ return 0;
+ }
+
+ if ((c = getc(fp)) == '/') {
+ while ((c = getc(fp)) != EOF && c != '\n')
+ ;
+ return 1;
+ }
+
+ if (c == '*') {
+ do {
+ while ((c = getc(fp)) != '*') {
+ if (c == EOF)
+ return 0;
+ }
+ } while ((c = getc(fp)) != '/');
+ return 1;
+ }
+ ungetc(c, fp);
+ ungetc('/', fp);
+ return 0;
+}
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ FILE *fp;
+ int c;
+ char buf[128];
+ size_t lev = 0;
+
+ for (i = 1; i < argc; i++) {
+ fp = fopen(*++argv, "r");
+ if (!fp) {
+ perror(*argv);
+ return 1;
+ }
+
+ if (i > 1) {
+ /* Skip whitespace and comment lines */
+ do {
+ while ((c = fgetc(fp)) != EOF && isspace(c))
+ ;
+ } while (c != EOF && comment(fp, c));
+ printf(" else ");
+ }
+
+ while ((c = fgetc(fp)) != EOF) {
+ putchar(c);
+ if (c == '}') {
+ lev = 0;
+ while ((c = fgetc(fp)) != EOF &&
+ isspace(c)) {
+ assert(lev < sizeof(buf));
+ buf[lev++] = c;
+ }
+ if (c == EOF)
+ break;
+ else {
+ buf[lev++] = c;
+ fwrite(buf, lev, 1, stdout);
+ }
+ }
+ }
+ fclose(fp);
+ }
+ return 0;
+}
diff --git a/etc/start-instances.fln b/etc/start-instances.fln
new file mode 100644
index 0000000..137a202
--- a/dev/null
+++ b/etc/start-instances.fln
@@ -0,0 +1,23 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+if (.StartInstancesResponse) {
+ for (var in .StartInstancesResponse.instancesSet.item) {
+ print(var.instanceId,": ",
+ var.previousState.name," => ",
+ var.currentState.name,"\n");
+ }
+} \ No newline at end of file
diff --git a/etc/stop-instances.fln b/etc/stop-instances.fln
new file mode 100644
index 0000000..bb45347
--- a/dev/null
+++ b/etc/stop-instances.fln
@@ -0,0 +1,23 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+if (.StopInstancesResponse) {
+ for (var in .StopInstancesResponse.instancesSet.item) {
+ print(var.instanceId,": ",
+ var.previousState.name," => ",
+ var.currentState.name,"\n");
+ }
+} \ No newline at end of file
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b114cc..7f3e1f0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,16 +56,10 @@ BUILT_SOURCES=\
EXTRA_DIST=\
cmdline.opt\
- $(OPTFILES)\
- eclat.conf
+ $(OPTFILES)
SUFFIXES=.opt .c .h
.opt.h:
m4 -s $(top_srcdir)/grecs/build-aux/getopt.m4 $< | sed '1d' > $@
-install-data-local:
- @test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
- @if [ -r $(DESTDIR)$(sysconfdir)/eclat.conf ]; then :; \
- else ${INSTALL} -m 644 $(top_srcdir)/src/eclat.conf \
- $(DESTDIR)$(sysconfdir)/eclat.conf; fi
diff --git a/src/cmdline.opt b/src/cmdline.opt
index d07309f..3f0549f 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -112,7 +112,7 @@ END
OPTION(format,F,FILE,
[<use FILE to format the output>])
BEGIN
- format_file = optarg;
+ format_file_option = optarg;
END
OPTION(sort,s,,
diff --git a/src/config.c b/src/config.c
index 82033d3..aa60323 100644
--- a/src/config.c
+++ b/src/config.c
@@ -139,7 +139,9 @@ static struct grecs_keyword eclat_kw[] = {
grecs_type_string, GRECS_DFLT, &region_name },
{ "format", "<command: string> <format: string>",
"Set default format for the <command>",
- grecs_type_string, GRECS_MULT, NULL, 0, cb_format },
+ grecs_type_string, GRECS_MULT, NULL, 0, cb_format },
+ { "format-file", "file", "Read format from <file>",
+ grecs_type_string, GRECS_DFLT, &format_file },
{ NULL }
};
diff --git a/src/eclat.c b/src/eclat.c
index a8c5728..31f2144 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -26,8 +26,9 @@ int use_ssl;
char *access_key;
char *secret_key;
char *region_name;
-char *format_file;
+char *format_file_option;
int sort_option;
+char *format_file;
FILE *xml_dump_file;
@@ -333,17 +334,6 @@ compile_format_file(const char *fmtfile)
return env;
}
-forlan_eval_env_t
-compile_default_format(struct command *cmd)
-{
- forlan_eval_env_t env;
-
- env = forlan_parse_buffer(cmd->fmt, strlen(cmd->fmt), &cmd->locus.beg);
- if (!env)
- exit(EX_UNAVAILABLE);
-
- return env;
-}
struct filter_descr *available_filters;
@@ -394,6 +384,57 @@ list_filters(FILE *fp)
fputc('\n', fp);
}
+static forlan_eval_env_t
+read_format(struct command *cmd)
+{
+ forlan_eval_env_t env = NULL;
+
+ if (format_file_option)
+ env = compile_format_file(format_file_option);
+ else if (cmd && cmd->fmt)
+ env = forlan_parse_buffer(cmd->fmt, strlen(cmd->fmt),
+ &cmd->locus.beg);
+ else if (format_file) {
+ struct wordsplit ws;
+ const char *kve[5];
+ struct grecs_locus_point pt;
+ FILE *fp;
+
+ kve[0] = "command";
+ kve[1] = cmd->ident;
+ kve[2] = "action";
+ kve[3] = cmd->tag;
+ kve[4] = NULL;
+
+ ws.ws_env = kve;
+ if (wordsplit(format_file, &ws,
+ WRDSF_NOSPLIT | WRDSF_NOCMD |
+ WRDSF_ENV | WRDSF_ENV_KV))
+ die(EX_SOFTWARE,
+ "error expanding format-file: %s",
+ wordsplit_strerror(&ws));
+
+ fp = fopen(ws.ws_wordv[0], "r");
+ if (!fp)
+ die(EX_UNAVAILABLE,
+ "cannot open format file %s: %s",
+ ws.ws_wordv[0], strerror(errno));
+
+ pt.file = ws.ws_wordv[0];
+ pt.line = 1;
+ pt.col = 0;
+
+ env = forlan_parse_file(fp, &pt);
+ fclose(fp);
+ wordsplit_free(&ws);
+ } else
+ return NULL;
+
+ if (!env)
+ exit(EX_UNAVAILABLE);
+ return env;
+}
+
int
main(int argc, char **argv)
@@ -448,11 +489,8 @@ main(int argc, char **argv)
die(EX_OSFILE, "cannot access \"%s\": %s",
conffile, strerror(errno));
- if (format_file)
- env = compile_format_file(format_file);
- else if (command && command->fmt)
- env = compile_default_format(command);
-
+ env = read_format(command);
+
if (lint_mode)
exit(0);
diff --git a/src/eclat.conf b/src/eclat.conf
deleted file mode 100644
index ec371e3..0000000
--- a/src/eclat.conf
+++ b/dev/null
@@ -1,165 +0,0 @@
-/* Default configuration file for Eclat.
- *
- * See eclat.conf(5) or run "info eclat configuration" for a detailed
- * description.
- */
-
-# Use this endpoint by default.
-default-endpoint "ec2.amazonaws.com";
-
-# Declare what endpoints to use for each availability region.
-# The syntax is:
-# region REGNAME ENDPOINT;
-
-# US East (Northern Virginia) Region
-region us-east-1 ec2.us-east-1.amazonaws.com;
-# US West (Oregon) Region
-region us-west-2 ec2.us-west-2.amazonaws.com;
-# US West (Northern California) Region
-region us-west-1 ec2.us-west-1.amazonaws.com;
-# EU (Ireland) Region
-region eu-west-1 ec2.eu-west-1.amazonaws.com;
-# Asia Pacific (Singapore) Region
-region ap-southeast-1 ec2.ap-southeast-1.amazonaws.com;
-# Asia Pacific (Tokyo) Region
-region ap-northeast-1 ec2.ap-northeast-1.amazonaws.com;
-# South America (Sao Paulo) Region
-region sa-east-1 ec2.sa-east-1.amazonaws.com;
-
-format "DescribeTags" <<\EOT
-if (.DescribeTagsResponse) {
- for (var in .DescribeTagsResponse.tagSet.item) {
- print(var.resourceId,"\t",
- var.resourceType,"\t",
- var.key,"\t",
- var.value,"\n");
- }
-} else if (.Response.Errors)
- error("Error: ",.Response.Errors.Error.Message,"\n");
-else {
- error("Unrecognized response:\n");
- dump(.);
-}
-EOT;
-
-format "DescribeInstanceStatus" <<\EOT
-if (.DescribeInstanceStatusResponse.instanceStatusSet) {
- for (var in .DescribeInstanceStatusResponse.instanceStatusSet.item) {
- print(var.instanceId,"\t",
- var.availabilityZone,"\t",
- var.instanceState.name);
- if (var.instanceState.name[running]) {
- print("\t",var.systemStatus.status);
- for (detail in var.systemStatus.details.item) {
- print("\tSys.",detail.name,"=",detail.status);
- }
- for (detail in var.instanceStatus.details.item) {
- print("\tInst.",detail.name,"=",detail.status);
- }
- }
- print("\n");
- for (event in var.eventsSet.item) {
- error(var.instanceId,"\t","Event: ", event.description,"\n");
- }
- }
-} else if (.Response.Errors)
- error("Error: ",.Response.Errors.Error.Message,"\n");
-else {
- error("Unrecognized response:\n");
- dump(.);
-}
-EOT;
-
-format "StartInstances" <<\EOT
-if (.StartInstancesResponse) {
- for (var in .StartInstancesResponse.instancesSet.item) {
- print(var.instanceId,": ",
- var.previousState.name," => ",
- var.currentState.name,"\n");
- }
-} else if (.Response.Errors)
- error("Error: ",.Response.Errors.Error.Message,"\n");
-else {
- error("Unrecognized response:\n");
- dump(.);
-}
-EOT;
-
-format "StopInstances" <<\EOT
-if (.StopInstancesResponse) {
- for (var in .StopInstancesResponse.instancesSet.item) {
- print(var.instanceId,": ",
- var.previousState.name," => ",
- var.currentState.name,"\n");
- }
-} else if (.Response.Errors)
- error("Error: ",.Response.Errors.Error.Message,"\n");
-else {
- error("Unrecognized response:\n");
- dump(.);
-}
-EOT;
-
-format "DescribeInstances" <<\EOT
-if (.DescribeInstancesResponse.reservationSet) {
- for (var in .DescribeInstancesResponse.reservationSet.item) {
- print("Reservation ID: ", var.reservationId, "\n");
- print("Owner ID: ", var.ownerId, "\n");
- if (var.groupSet) {
- print("Groups:\n");
- for (grp in var.groupSet.item)
- print("\t", grp.groupId,"\t", grp.groupName, "\n");
- }
- if (var.instancesSet) {
- // print("Instances:\n");
- for (inst in var.instancesSet.item) {
- print("\nInstance: ", inst.instanceId, "\n");
- print("\tImage ID: ", inst.imageId, "\n");
- print("\tState: ", inst.instanceState.name, "\n");
- print("\tKernel ID: ", inst.kernelId, "\n");
- print("\tArchitecture: ", inst.architecture, "\n");
- print("\tPrivate DNS: ", inst.privateDnsName, "\n");
- print("\tPublic DNS: ", inst.dnsName, "\n");
- print("\tKey: ", inst.keyName, "\n");
- print("\tType: ", inst.instanceType, "\n");
- print("\tLaunch Time: ", inst.launchTime, "\n");
- print("\tAvailability Zone: ", inst.placement.availabilityZone, "\n");
- print("\tGroup Name: ", inst.placement.groupName, "\n");
- print("\tTenancy: ", inst.placement.tenancy, "\n");
- print("\tPrivate IP: ", inst.privateIpAddress, "\n");
- print("\tPublic IP: ", inst.ipAddress, "\n");
- if (inst.groupSet.item) {
- print("\tGroups:\n");
- for (grp in inst.groupSet.item)
- print("\t\t", inst.groupSet.item.groupId, " -- ", inst.groupSet.item.groupName, "\n");
- }
- print("\tRoot Device Type: ", inst.rootDeviceType, "\n");
- print("\tRoot Device Name: ", inst.rootDeviceName, "\n");
- print("\tDevice mapping:\n");
- for (dev in inst.blockDeviceMapping.item) {
- print("\t\t", dev.deviceName, " ", dev.ebs.volumeId, " ",
- dev.ebs.status, " ", dev.ebs.attachTime, " ",
- dev.ebs.deleteOnTermination, "\n");
- }
- print("\tVirtualization: ", inst.virtualizationType, "\n");
- print("\tTag Set:\n");
- for (tag in inst.tagSet.item) {
- print("\t\t", tag.key, "=", tag.value, "\n");
- }
- print("\tHypervisor: ", inst.hypervisor, "\n");
- // FIXME: networkInterfaceSet
- print("\tEBS Optimized: ", inst.ebsOptimized, "\n");
- print("End of instance\n\n");
- }
- }
- }
-} else if (.Response.Errors)
- error("Error: ",.Response.Errors.Error.Message,"\n");
-else {
- error("Unrecognized response:\n");
- dump(.);
-}
-EOT;
-
-
-
diff --git a/src/eclat.h b/src/eclat.h
index bd7a86b..242861b 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -43,6 +43,7 @@ extern char *region_name;
extern char *access_file_name;
extern char *access_key;
extern char *secret_key;
+extern char *format_file;
typedef int (*config_finish_hook_t) (void*);
diff --git a/tests/.gitignore b/tests/.gitignore
index 8b76ee0..06ac629 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -6,5 +6,6 @@ testsuite.dir
testsuite.log
tforlan
thmac
+trws
turlenc
txml
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4af19e3..99c2ae6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,6 +40,9 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
## ------------ ##
TESTSUITE_AT = \
+ describe-instance-status.at\
+ describe-instances.at\
+ describe-tags.at\
dump01.at\
dump02.at\
forlan01.at\
@@ -52,6 +55,8 @@ TESTSUITE_AT = \
print01.at\
print02.at\
print03.at\
+ start-instances.at\
+ stop-instances.at\
tagshairy.at\
testsuite.at\
urlenc01.at\
@@ -81,6 +86,7 @@ check-local: atconfig atlocal $(TESTSUITE)
noinst_PROGRAMS = \
tforlan\
thmac\
+ trws\
turlenc\
txml
diff --git a/tests/describe-instance-status.at b/tests/describe-instance-status.at
new file mode 100644
index 0000000..e01b5fc
--- a/dev/null
+++ b/tests/describe-instance-status.at
@@ -0,0 +1,154 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 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_TEST_FORMAT([DescribeInstanceStatus],
+[DescribeInstanceStatus],
+[describe-instance-status.fln],
+[<DescribeInstanceStatusResponse xmlns='http://ec2.amazonaws.com/doc/2012-04-01/'>
+ <requestId>3be1508e-c444-4fef-89cc-0b1223c4f02f</requestId>
+ <instanceStatusSet>
+ <item>
+ <instanceId>i-283f9f47</instanceId>
+ <availabilityZone>us-east-1d</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>impaired</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>failed</status>
+ <impairedSince>2012-03-27T16:10:46.000Z</impairedSince>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>impaired</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>failed</status>
+ <impairedSince>2012-03-27T16:10:46.000Z</impairedSince>
+ </item>
+ </details>
+ </instanceStatus>
+ <eventsSet>
+ <item>
+ <code>instance-retirement</code>
+ <notBefore>2011-12-05T13:00:00+0000</notBefore>
+ <notAfter>2011-12-06T13:00:00+000</notAfter>
+ <description>The instance is running on degraded hardware</description>
+ </item>
+ </eventsSet>
+ </item>
+ <item>
+ <instanceId>i-d2e36dbd</instanceId>
+ <availabilityZone>us-east-1d</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </instanceStatus>
+ <eventsSet>
+ <item>
+ <code>instance-reboot</code>
+ <notBefore>2011-12-05T13:00:00+0000</notBefore>
+ <notAfter>2011-12-06T13:00:00+000</notAfter>
+ <description>The instance is scheduled for a reboot</description>
+ </item>
+ </eventsSet>
+ </item>
+ <item>
+ <instanceId>i-9fa454f1</instanceId>
+ <availabilityZone>us-east-1c</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </instanceStatus>
+ </item>
+ <item>
+ <instanceId>i-0ed2936e</instanceId>
+ <availabilityZone>us-east-1c</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>insufficient-data</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>insufficient-data</status>
+ </item>
+ </details>
+ </instanceStatus>
+ </item>
+ </instanceStatusSet>
+</DescribeInstanceStatusResponse>
+],[i-283f9f47 us-east-1d running impaired Sys.reachability=failed Inst.reachability=failed
+i-d2e36dbd us-east-1d running ok Sys.reachability=passed Inst.reachability=passed
+i-9fa454f1 us-east-1c running ok Sys.reachability=passed Inst.reachability=passed
+i-0ed2936e us-east-1c running ok Sys.reachability=passed Inst.reachability=insufficient-data
+],
+[i-283f9f47 Event: "The instance is running on degraded hardware"
+i-d2e36dbd Event: "The instance is scheduled for a reboot"
+])
diff --git a/tests/describe-instances.at b/tests/describe-instances.at
new file mode 100644
index 0000000..2c862c8
--- a/dev/null
+++ b/tests/describe-instances.at
@@ -0,0 +1,274 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 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_TEST_FORMAT([DescribeInstances],
+[DescribeInstances],
+[describe-instances.fln],
+[<DescribeInstancesResponse xmlns='http://ec2.amazonaws.com/doc/2012-08-15/'>
+ <requestId>fdcdcab1-ae5c-489e-9c33-4637c5dda355</requestId>
+ <reservationSet>
+ <item>
+ <reservationId>r-0ece705a</reservationId>
+ <ownerId>053230519467</ownerId>
+ <groupSet/>
+ <instancesSet>
+ <item>
+ <instanceId>i-7a00642e</instanceId>
+ <imageId>ami-1cd4924e</imageId>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <privateDnsName/>
+ <dnsName/>
+ <reason/>
+ <keyName>VPCKey</keyName>
+ <amiLaunchIndex>0</amiLaunchIndex>
+ <productCodes/>
+ <instanceType>c1.medium</instanceType>
+ <launchTime>2012-06-28T17:41:48.000Z</launchTime>
+ <placement>
+ <availabilityZone>ap-southeast-1b</availabilityZone>
+ <groupName/>
+ <tenancy>default</tenancy>
+ </placement>
+ <platform>windows</platform>
+ <monitoring>
+ <state>disabled</state>
+ </monitoring>
+ <subnetId>subnet-c53c87ac</subnetId>
+ <vpcId>vpc-cc3c87a5</vpcId>
+ <privateIpAddress>10.0.0.12</privateIpAddress>
+ <ipAddress>46.51.219.63</ipAddress>
+ <sourceDestCheck>true</sourceDestCheck>
+ <groupSet>
+ <item>
+ <groupId>sg-374b565b</groupId>
+ <groupName>quick-start-3</groupName>
+ </item>
+ </groupSet>
+ <architecture>x86_64</architecture>
+ <rootDeviceType>ebs</rootDeviceType>
+ <rootDeviceName>/dev/sda1</rootDeviceName>
+ <blockDeviceMapping>
+ <item>
+ <deviceName>/dev/sda1</deviceName>
+ <ebs>
+ <volumeId>vol-9e151bfc</volumeId>
+ <status>attached</status>
+ <attachTime>2012-06-28T17:42:05.000Z</attachTime>
+ <deleteOnTermination>true</deleteOnTermination>
+ </ebs>
+ </item>
+ </blockDeviceMapping>
+ <virtualizationType>hvm</virtualizationType>
+ <clientToken>JNlxa1340905307390</clientToken>
+ <tagSet>
+ <item>
+ <key>Name</key>
+ <value>SingleENI</value>
+ </item>
+ </tagSet>
+ <hypervisor>xen</hypervisor>
+ <networkInterfaceSet>
+ <item>
+ <networkInterfaceId>eni-d83388b1</networkInterfaceId>
+ <subnetId>subnet-c53c87ac</subnetId>
+ <vpcId>vpc-cc3c87a5</vpcId>
+ <description>Primary network interface</description>
+ <ownerId>053230519467</ownerId>
+ <status>in-use</status>
+ <privateIpAddress>10.0.0.12</privateIpAddress>
+ <sourceDestCheck>true</sourceDestCheck>
+ <groupSet>
+ <item>
+ <groupId>sg-374b565b</groupId>
+ <groupName>quick-start-3</groupName>
+ </item>
+ </groupSet>
+ <attachment>
+ <attachmentId>eni-attach-31b87358</attachmentId>
+ <deviceIndex>0</deviceIndex>
+ <status>attached</status>
+ <attachTime>2012-06-28T17:41:48.000Z</attachTime>
+ <deleteOnTermination>true</deleteOnTermination>
+ </attachment>
+ <association>
+ <publicIp>46.51.219.63</publicIp>
+ <ipOwnerId>053230519467</ipOwnerId>
+ </association>
+ <privateIpAddressesSet>
+ <item>
+ <privateIpAddress>10.0.0.12</privateIpAddress>
+ <primary>true</primary>
+ <association>
+ <publicIp>46.51.219.63</publicIp>
+ <ipOwnerId>053230519467</ipOwnerId>
+ </association>
+ </item>
+ <item>
+ <privateIpAddress>10.0.0.14</privateIpAddress>
+ <primary>false</primary>
+ <association>
+ <publicIp>46.51.221.177</publicIp>
+ <ipOwnerId>053230519467</ipOwnerId>
+ </association>
+ </item>
+ </privateIpAddressesSet>
+ </item>
+ </networkInterfaceSet>
+ </item>
+ </instancesSet>
+ </item>
+ <item>
+ <reservationId>r-58b30a0c</reservationId>
+ <ownerId>053230519467</ownerId>
+ <groupSet>
+ <item>
+ <groupId>sg-aa4170f8</groupId>
+ <groupName>quick-start-5</groupName>
+ </item>
+ </groupSet>
+ <instancesSet>
+ <item>
+ <instanceId>i-507f1804</instanceId>
+ <imageId>ami-70d49222</imageId>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <privateDnsName>ip-10-139-34-251.ap-southeast-1.compute.internal</privateDnsName>
+ <dnsName>ec2-122-248-233-255.ap-southeast-1.compute.amazonaws.com</dnsName>
+ <reason/>
+ <keyName>EC2Key</keyName>
+ <amiLaunchIndex>0</amiLaunchIndex>
+ <productCodes/>
+ <instanceType>t1.micro</instanceType>
+ <launchTime>2012-06-29T22:53:42.000Z</launchTime>
+ <placement>
+ <availabilityZone>ap-southeast-1a</availabilityZone>
+ <groupName/>
+ <tenancy>default</tenancy>
+ </placement>
+ <platform>windows</platform>
+ <monitoring>
+ <state>disabled</state>
+ </monitoring>
+ <privateIpAddress>10.139.34.251</privateIpAddress>
+ <ipAddress>122.248.233.255</ipAddress>
+ <groupSet>
+ <item>
+ <groupId>sg-aa4170f8</groupId>
+ <groupName>quick-start-5</groupName>
+ </item>
+ </groupSet>
+ <architecture>x86_64</architecture>
+ <rootDeviceType>ebs</rootDeviceType>
+ <rootDeviceName>/dev/sda1</rootDeviceName>
+ <blockDeviceMapping>
+ <item>
+ <deviceName>/dev/sda1</deviceName>
+ <ebs>
+ <volumeId>vol-a22b3ac0</volumeId>
+ <status>attached</status>
+ <attachTime>2012-06-29T22:54:02.000Z</attachTime>
+ <deleteOnTermination>true</deleteOnTermination>
+ </ebs>
+ </item>
+ </blockDeviceMapping>
+ <virtualizationType>hvm</virtualizationType>
+ <clientToken>clNwH1341010421443</clientToken>
+ <tagSet>
+ <item>
+ <key>Name</key>
+ <value>EC2 Instance</value>
+ </item>
+ </tagSet>
+ <hypervisor>xen</hypervisor>
+ <networkInterfaceSet/>
+ </item>
+ </instancesSet>
+ </item>
+ </reservationSet>
+</DescribeInstancesResponse>
+],
+[Reservation ID: r-0ece705a
+Owner ID: 053230519467
+Groups:
+
+Instance: i-7a00642e
+ Image ID: ami-1cd4924e
+ State: running
+ Kernel ID:
+ Architecture: x86_64
+ Private DNS:
+ Public DNS:
+ Key: VPCKey
+ Type: c1.medium
+ Launch Time: 2012-06-28T17:41:48.000Z
+ Availability Zone: ap-southeast-1b
+ Group Name:
+ Tenancy: default
+ Private IP: 10.0.0.12
+ Public IP: 46.51.219.63
+ Groups:
+ sg-374b565b -- quick-start-3
+ Root Device Type: ebs
+ Root Device Name: /dev/sda1
+ Device mapping:
+ /dev/sda1 vol-9e151bfc attached 2012-06-28T17:42:05.000Z true
+ Virtualization: hvm
+ Tag Set:
+ Name=SingleENI
+ Hypervisor: xen
+ EBS Optimized:
+End of instance
+
+Reservation ID: r-58b30a0c
+Owner ID: 053230519467
+Groups:
+ sg-aa4170f8 quick-start-5
+
+Instance: i-507f1804
+ Image ID: ami-70d49222
+ State: running
+ Kernel ID:
+ Architecture: x86_64
+ Private DNS: ip-10-139-34-251.ap-southeast-1.compute.internal
+ Public DNS: ec2-122-248-233-255.ap-southeast-1.compute.amazonaws.com
+ Key: EC2Key
+ Type: t1.micro
+ Launch Time: 2012-06-29T22:53:42.000Z
+ Availability Zone: ap-southeast-1a
+ Group Name:
+ Tenancy: default
+ Private IP: 10.139.34.251
+ Public IP: 122.248.233.255
+ Groups:
+ sg-aa4170f8 -- quick-start-5
+ Root Device Type: ebs
+ Root Device Name: /dev/sda1
+ Device mapping:
+ /dev/sda1 vol-a22b3ac0 attached 2012-06-29T22:54:02.000Z true
+ Virtualization: hvm
+ Tag Set:
+ Name="EC2 Instance"
+ Hypervisor: xen
+ EBS Optimized:
+End of instance
+
+])
+
diff --git a/tests/describe-tags.at b/tests/describe-tags.at
new file mode 100644
index 0000000..d91a6e7
--- a/dev/null
+++ b/tests/describe-tags.at
@@ -0,0 +1,68 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 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_TEST_FORMAT([DescribeTags],
+[DescribeTags],
+[describe-tags.fln],
+[<DescribeTagsResponse xmlns="http://ec2.amazonaws.com/doc/2012-08-15/">
+ <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
+ <tagSet>
+ <item>
+ <resourceId>ami-1a2b3c4d</resourceId>
+ <resourceType>image</resourceType>
+ <key>webserver</key>
+ <value/>
+ </item>
+ <item>
+ <resourceId>ami-1a2b3c4d</resourceId>
+ <resourceType>image</resourceType>
+ <key>stack</key>
+ <value>Production</value>
+ </item>
+ <item>
+ <resourceId>i-5f4e3d2a</resourceId>
+ <resourceType>instance</resourceType>
+ <key>webserver</key>
+ <value/>
+ </item>
+ <item>
+ <resourceId>i-5f4e3d2a</resourceId>
+ <resourceType>instance</resourceType>
+ <key>stack</key>
+ <value>Production</value>
+ </item>
+ <item>
+ <resourceId>i-12345678</resourceId>
+ <resourceType>instance</resourceType>
+ <key>database_server</key>
+ <value/>
+ </item>
+ <item>
+ <resourceId>i-12345678</resourceId>
+ <resourceType>instance</resourceType>
+ <key>stack</key>
+ <value>Test</value>
+ </item>
+ </tagSet>
+</DescribeTagsResponse>
+],
+[ami-1a2b3c4d image webserver
+ami-1a2b3c4d image stack Production
+i-5f4e3d2a instance webserver
+i-5f4e3d2a instance stack Production
+i-12345678 instance database_server
+i-12345678 instance stack Test
+]) \ No newline at end of file
diff --git a/tests/dscrinststat.at b/tests/dscrinststat.at
new file mode 100644
index 0000000..de733c1
--- a/dev/null
+++ b/tests/dscrinststat.at
@@ -0,0 +1,128 @@
+AT_DATA([result],[<DescribeInstanceStatusResponse xmlns='http://ec2.amazonaws.com/doc/2012-04-01/'>
+ <requestId>3be1508e-c444-4fef-89cc-0b1223c4f02f</requestId>
+ <instanceStatusSet>
+ <item>
+ <instanceId>i-283f9f47</instanceId>
+ <availabilityZone>us-east-1d</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>impaired</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>failed</status>
+ <impairedSince>2012-03-27T16:10:46.000Z</impairedSince>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>impaired</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>failed</status>
+ <impairedSince>2012-03-27T16:10:46.000Z</impairedSince>
+ </item>
+ </details>
+ </instanceStatus>
+ <eventsSet>
+ <code>instance-retirement</code>
+ <notBefore>2011-12-05T13:00:00+0000</notBefore>
+ <notAfter>2011-12-06T13:00:00+000</notAfter>
+ <description>
+ The instance is running on degraded hardware
+ </description>
+ </eventsSet>
+ </item>
+ <item>
+ <instanceId>i-d2e36dbd</instanceId>
+ <availabilityZone>us-east-1d</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </instanceStatus>
+ <eventsSet>
+ <code>instance-reboot</code>
+ <notBefore>2011-12-05T13:00:00+0000</notBefore>
+ <notAfter>2011-12-06T13:00:00+000</notAfter>
+ <description>
+ The instance is scheduled for a reboot
+ </description>
+ </eventsSet>
+ </item>
+ <item>
+ <instanceId>i-9fa454f1</instanceId>
+ <availabilityZone>us-east-1c</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </instanceStatus>
+ </item>
+ <item>
+ <instanceId>i-0ed2936e</instanceId>
+ <availabilityZone>us-east-1c</availabilityZone>
+ <instanceState>
+ <code>16</code>
+ <name>running</name>
+ </instanceState>
+ <systemStatus>
+ <status>ok</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>passed</status>
+ </item>
+ </details>
+ </systemStatus>
+ <instanceStatus>
+ <status>insufficient-data</status>
+ <details>
+ <item>
+ <name>reachability</name>
+ <status>insufficient-data</status>
+ </item>
+ </details>
+ </instanceStatus>
+ </item>
+ </instanceStatusSet>
+</DescribeInstanceStatusResponse>
+])
diff --git a/tests/start-instances.at b/tests/start-instances.at
new file mode 100644
index 0000000..fec42c7
--- a/dev/null
+++ b/tests/start-instances.at
@@ -0,0 +1,38 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 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_TEST_FORMAT([StartInstances],
+[StartInstances],
+[start-instances.fln],
+[<StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-08-15/">
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <instancesSet>
+ <item>
+ <instanceId>i-10a64379</instanceId>
+ <currentState>
+ <code>0</code>
+ <name>pending</name>
+ </currentState>
+ <previousState>
+ <code>80</code>
+ <name>stopped</name>
+ </previousState>
+ </item>
+ </instancesSet>
+</StartInstancesResponse>
+],
+[i-10a64379: stopped => pending
+])
diff --git a/tests/stop-instances.at b/tests/stop-instances.at
new file mode 100644
index 0000000..a2dcd45
--- a/dev/null
+++ b/tests/stop-instances.at
@@ -0,0 +1,39 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012 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_TEST_FORMAT([StopInstances],
+[StopInstances],
+[stop-instances.fln],
+[<StopInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-08-15/">
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <instancesSet>
+ <item>
+ <instanceId>i-10a64379</instanceId>
+ <currentState>
+ <code>64</code>
+ <name>stopping</name>
+ </currentState>
+ <previousState>
+ <code>16</code>
+ <name>running</name>
+ </previousState>
+ </item>
+ </instancesSet>
+</StopInstancesResponse>
+],
+[i-10a64379: running => stopping
+])
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 87a7f7c..55fe2d4 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -18,6 +18,16 @@ m4_version_prereq([2.52g])
m4_define([AT_SKIP_TEST],[exit 77])
+dnl ECLAT_TEST_FORMAT DESCR KW FILE INPUT OUTPUT STDERR
+dnl $1 $2 $3 $4 $5 $6
+m4_define([ECLAT_TEST_FORMAT],[
+AT_SETUP([$1])
+AT_KEYWORDS([format dflfmt $2])
+AT_DATA([result],[$4])
+AT_CHECK([tforlan $[]abs_top_srcdir/etc/$3 result|trws],[0],[$5],[$6])
+AT_CLEANUP
+])
+
AT_INIT
AT_BANNER([HMAC-SHA1])
m4_include(hmac01.at)
@@ -42,4 +52,11 @@ m4_include([let.at])
m4_include([listall.at])
m4_include([tagshairy.at])
+AT_BANNER([Default formats])
+m4_include([describe-instance-status.at])
+m4_include([describe-instances.at])
+m4_include([describe-tags.at])
+m4_include([start-instances.at])
+m4_include([stop-instances.at])
+
# End of testsuite.at
diff --git a/tests/trws.c b/tests/trws.c
new file mode 100644
index 0000000..d288759
--- a/dev/null
+++ b/tests/trws.c
@@ -0,0 +1,46 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 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/>. */
+
+/* This program filters out trailing whitespace from the input. */
+
+#include <stdio.h>
+#include <assert.h>
+
+int
+main()
+{
+ char buf[512];
+ size_t lev = 0;
+ int c;
+
+ while ((c = getchar()) != EOF) {
+ if (c == ' ' || c == '\t') {
+ assert(lev < sizeof(buf));
+ buf[lev++] = c;
+ continue;
+ } else if (c == '\n')
+ lev = 0;
+ else if (lev) {
+ fwrite(buf, lev, 1, stdout);
+ lev = 0;
+ }
+ putchar(c);
+ }
+ assert(!ferror(stdout));
+ return 0;
+}
+
+

Return to:

Send suggestions and report system problems to the System administrator.