summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-06 14:04:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2012-12-06 14:07:22 (GMT)
commit141a22cb7bb918a08698785f860a902ea4448b5c (patch) (side-by-side diff)
tree2d092c6cadd49301da86dd95fea140990132b42b
parent033b6994c89bb28788c5525df2f10b19b694a4c7 (diff)
downloadeclat-141a22cb7bb918a08698785f860a902ea4448b5c.tar.gz
eclat-141a22cb7bb918a08698785f860a902ea4448b5c.tar.bz2
Implement the describe-regions command.
* TODO: Update. * doc/Makefile.am: Add new files. * doc/eclat-describe-availability-zones.1: Mention describe-regions. * doc/eclat-describe-regions.1: New file. * doc/tmpl.1: Fix time-stamp-start setting. * etc/Makefile.am: Add new files. * etc/describe-regions.fln: New file. * src/Makefile.am: Add new files. * src/dscrregs.c: New file. * src/eclat.c: Register describe-regions. * src/eclat.h (eclat_describe_regions): New proto.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--TODO2
-rw-r--r--doc/Makefile.am1
-rw-r--r--doc/eclat-describe-availability-zones.16
-rw-r--r--doc/eclat-describe-regions.177
-rw-r--r--doc/tmpl.14
-rw-r--r--etc/Makefile.am1
-rw-r--r--etc/describe-regions.fln21
-rw-r--r--src/Makefile.am1
-rw-r--r--src/dscrregs.c50
-rw-r--r--src/eclat.c2
-rw-r--r--src/eclat.h1
11 files changed, 162 insertions, 4 deletions
diff --git a/TODO b/TODO
index 467c528..44fa7e7 100644
--- a/TODO
+++ b/TODO
@@ -87,7 +87,7 @@ DescribeNetworkAcls DSCRNETACLS [ ] [ ]
DescribeNetworkInterfaceAttribute DSCRNETIFATTR [ ] [ ]
DescribeNetworkInterfaces DSCRNETIFS [ ] [ ]
DescribePlacementGroups DSCRPLCGRPS [ ] [ ]
-DescribeRegions DSCRREGS [ ] [ ]
+DescribeRegions DSCRREGS [X] [X]
DescribeReservedInstances DSCRRSRVDINSTS [ ] [ ]
DescribeReservedInstancesListings DSCRRSRVDINSTSLSTS [ ] [ ]
DescribeReservedInstancesOfferings DSCRRSRVDINSTSOFRS [ ] [ ]
diff --git a/doc/Makefile.am b/doc/Makefile.am
index eb56d02..051b8e0 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -27,6 +27,7 @@ MANPAGES1=\
eclat-describe-instance-attribute.1\
eclat-describe-instance-status.1\
eclat-describe-instances.1\
+ eclat-describe-regions.1\
eclat-describe-security-groups.1\
eclat-describe-snapshots.1\
eclat-describe-tags.1\
diff --git a/doc/eclat-describe-availability-zones.1 b/doc/eclat-describe-availability-zones.1
index 6e719ea..722becc 100644
--- a/doc/eclat-describe-availability-zones.1
+++ b/doc/eclat-describe-availability-zones.1
@@ -28,6 +28,9 @@ set by the
configuration file statement or the
.B \-\-region
command line option.
+.PP
+If no arguments are given, the command will list all availability
+zones. Otherwise, it will list only zones with the supplied names.
.SH FILTERS
Filters allow you to select only zones matching particular
criteria. The following filters are defined:
@@ -63,7 +66,8 @@ eu-west-1b available
eu-west-1c available
.fi
.SH "SEE ALSO"
-.BR eclat (1).
+.BR eclat (1),
+.BR eclat\-describe\-regions (1).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
diff --git a/doc/eclat-describe-regions.1 b/doc/eclat-describe-regions.1
new file mode 100644
index 0000000..fe0c4fe
--- a/dev/null
+++ b/doc/eclat-describe-regions.1
@@ -0,0 +1,77 @@
+.\" This file is part of Eclat -*- nroff -*-
+.\" 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/>.
+.TH ECLAT\-DESCRIBE\-REGIONS 1 "December 6, 2012" "ECLAT" "Eclat User Reference"
+.SH NAME
+eclat describe\-regions \- describe EC2 regions
+.SH SYNOPSIS
+eclat describe\-regions [\fBFILTER\fR...] [\fBREGION\fR...]
+
+eclat describe\-regions \fB\-\-help\fR
+.SH DESCRIPTION
+This command lists the EC2 regions. If no arguments are provided, it
+lists all regions available to the account. Otherwise, each argument
+is treated as a name of the region to describe.
+.SH FILTERS
+Filters allow you to select only regions matching particular
+criteria. The following filters are defined:
+.TP
+\fBendpoint\fR=\fIstring\fR
+The endpoint of the region.
+.TP
+\fBregion\-name\fR=\fIstring\fR
+The region name. It is the same as giving \fBstring\fR as a command
+line argument.
+.SH OUTPUT
+The default output shows one region per line. Each line of output
+contains region name and corresponding endpoint, separated by a single
+horizontal tab character.
+.SH EXAMPLE
+.nf
+.sp 2
+$ \fBeclat describe-regions\fR
+eu-west-1 ec2.eu-west-1.amazonaws.com
+sa-east-1 ec2.sa-east-1.amazonaws.com
+us-east-1 ec2.us-east-1.amazonaws.com
+ap-northeast-1 ec2.ap-northeast-1.amazonaws.com
+us-west-2 ec2.us-west-2.amazonaws.com
+us-west-1 ec2.us-west-1.amazonaws.com
+ap-southeast-1 ec2.ap-southeast-1.amazonaws.com
+ap-southeast-2 ec2.ap-southeast-2.amazonaws.com
+.fi
+.SH "SEE ALSO"
+.BR eclat (1),
+.BR eclat\-describe\-availability\-zones (1).
+.SH AUTHORS
+Sergey Poznyakoff
+.SH "BUG REPORTS"
+Report bugs to <bug\-eclat@gnu.org.ua>.
+.SH COPYRIGHT
+Copyright \(co 2012 Sergey Poznyakoff
+.br
+.na
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+.br
+.ad
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+.\" Local variables:
+.\" eval: (add-hook 'write-file-hooks 'time-stamp)
+.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_.\\-]* [0-9] \""
+.\" time-stamp-format: "%:B %:d, %:y"
+.\" time-stamp-end: "\""
+.\" time-stamp-line-limit: 20
+.\" end:
+
diff --git a/doc/tmpl.1 b/doc/tmpl.1
index 7a9de87..077b07f 100644
--- a/doc/tmpl.1
+++ b/doc/tmpl.1
@@ -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 "October 15, 2012" "ECLAT" "Eclat User Reference"
+.TH ECLAT 1 "December 6, 2012" "ECLAT" "Eclat User Reference"
.SH NAME
eclat \- EC2 Command Line Administrator Tool
.SH SYNOPSIS
@@ -37,7 +37,7 @@ This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
.\" Local variables:
.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_.-]* [0-9] \""
+.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_.\\-]* [0-9] \""
.\" time-stamp-format: "%:B %:d, %:y"
.\" time-stamp-end: "\""
.\" time-stamp-line-limit: 20
diff --git a/etc/Makefile.am b/etc/Makefile.am
index 0a64e40..4cde97f 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -27,6 +27,7 @@ FLNFILES=\
describe-instance-attribute.fln\
describe-instance-status.fln\
describe-instances.fln\
+ describe-regions.fln\
describe-security-groups.fln\
describe-snapshots.fln\
describe-tags.fln\
diff --git a/etc/describe-regions.fln b/etc/describe-regions.fln
new file mode 100644
index 0000000..bbe7328
--- a/dev/null
+++ b/etc/describe-regions.fln
@@ -0,0 +1,21 @@
+/* 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 (.DescribeRegionsResponse) {
+ for (var in .DescribeRegionsResponse.regionInfo.item) {
+ print(var.regionName,"\t",var.regionEndpoint,"\n");
+ }
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 7f20ba4..4d2b443 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,7 @@ eclat_SOURCES=\
dscraddrs.c\
dscrazs.c\
dscrsnap.c\
+ dscrregs.c\
dscrtags.c\
dscrinstattr.c\
dscrinsts.c\
diff --git a/src/dscrregs.c b/src/dscrregs.c
new file mode 100644
index 0000000..658e71e
--- a/dev/null
+++ b/src/dscrregs.c
@@ -0,0 +1,50 @@
+/* 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 "eclat.h"
+
+static void
+parse_options(int argc, char *argv[], int *index)
+{
+ static struct filter_descr filters[] = {
+ { "endpoint", FILTER_STRING },
+ { "region-name", FILTER_STRING },
+ { NULL }
+ };
+
+ available_filters = filters;
+ generic_proginfo->print_help_hook = list_filters;
+ generic_proginfo->args_doc = "[REGION [REGION...]]";
+ return generic_parse_options("eclat describe-regiones",
+ "List available regions",
+ argc, argv, index);
+}
+
+int
+eclat_describe_regions(CURL *curl, int argc, char **argv)
+{
+ int i;
+ struct ec2_query *q;
+
+ parse_options(argc, argv, &i);
+ argv += i;
+ argc -= i;
+ translate_ids(argc, argv, "reg");
+
+ q = describe_query_create(curl, "DescribeRegions",
+ argc, argv, "RegionName");
+ return eclat_send_query(curl, q);
+}
diff --git a/src/eclat.c b/src/eclat.c
index c6a1fa4..2c0dcfe 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -244,6 +244,8 @@ struct command cmdtab[] = {
eclat_delete_snapshot },
{ "describe-avaialbility-zones", "DescribeAvaialbilityZones",
eclat_describe_avaialbility_zones },
+ { "describe-regions", "DescribeRegions",
+ eclat_describe_regions },
};
size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]);
diff --git a/src/eclat.h b/src/eclat.h
index 94140bb..e369b7c 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -85,6 +85,7 @@ int eclat_create_snapshot(CURL *curl, int argc, char **argv);
int eclat_describe_snapshots(CURL *curl, int argc, char **argv);
int eclat_delete_snapshot(CURL *curl, int argc, char **argv);
int eclat_describe_avaialbility_zones(CURL *curl, int argc, char **argv);
+int eclat_describe_regions(CURL *curl, int argc, char **argv);
char *region_to_endpoint(const char *region);

Return to:

Send suggestions and report system problems to the System administrator.