aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--doc/Makefile.am3
-rw-r--r--doc/eclat-allocate-address.162
-rw-r--r--doc/eclat-associate-address.16
-rw-r--r--doc/eclat-describe-addresses.14
-rw-r--r--doc/eclat-disassociate-address.14
-rw-r--r--doc/eclat-release-address.196
-rw-r--r--doc/eclat.121
-rw-r--r--etc/Makefile.am1
-rw-r--r--etc/release-address.fln22
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/confirm.c41
-rw-r--r--lib/getyn.c77
-rw-r--r--lib/libeclat.h6
-rw-r--r--src/Makefile.am4
-rw-r--r--src/cmdline.opt12
-rw-r--r--src/eclat.c2
-rw-r--r--src/eclat.h3
-rw-r--r--src/reladdr-cl.opt37
-rw-r--r--src/reladdr.c42
20 files changed, 439 insertions, 8 deletions
diff --git a/TODO b/TODO
index accd665..1403095 100644
--- a/TODO
+++ b/TODO
@@ -129,7 +129,7 @@ MonitorInstances MONINSTS [ ] [ ]
PurchaseReservedInstancesOffering PURRSRVDINSTSOFR [ ] [ ]
RebootInstances RBTINSTS [X] [X]
RegisterImage REGIMG [ ] [ ]
-ReleaseAddress RLSADR [ ] [ ]
+ReleaseAddress RLSADR [X] [ ]
ReplaceNetworkAclAssociation RPLNETACLASCN [ ] [ ]
ReplaceNetworkAclEntry RPLNETACLENT [ ] [ ]
ReplaceRoute RPLROUT [ ] [ ]
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 0f38d80..cf20541 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -33,7 +33,8 @@ MANPAGES1=\
eclat-get-console-output.1\
eclat-start-instances.1\
eclat-stop-instances.1\
- eclat-reboot-instances.1
+ eclat-reboot-instances.1\
+ eclat-release-address.1
MANPAGES5=\
eclat.conf.5
diff --git a/doc/eclat-allocate-address.1 b/doc/eclat-allocate-address.1
new file mode 100644
index 0000000..2ff1050
--- /dev/null
+++ b/doc/eclat-allocate-address.1
@@ -0,0 +1,62 @@
+.\" 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 ALLOCATE\-ADDRESS 1 "December 5, 2012" "ECLAT" "Eclat User Reference"
+.SH NAME
+eclat allocate\-address \- allocate an Elastic IP address
+.SH SYNOPSIS
+eclat allocate\-address [\fB\-v\fR] [\f\--vpc\fR]
+
+eclat allocate\-address \fB\-\-help\fR
+.SH DESCRIPTION
+The
+.B allocate\-address
+command allocates an Elastic IP address. It does not take arguments.
+.PP
+.SH OPTIONS
+.TP
+\fB\-v\fR, \fB\-\-vpc\fR
+Allocate address for use with instances in a VPC.
+.SH "OUTPUT AND RETURN VALUE"
+The default output format displays the allocated IP address on
+success.
+.PP
+On success, the code 0 is returned to the shell. Non-zero status code
+is returned on error.
+.SH "SEE ALSO"
+.BR eclat (1),
+.BR eclat\-associate\-address (1),
+.BR eclat\-release\-address (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/eclat-associate-address.1 b/doc/eclat-associate-address.1
index 0ff61b0..45f4688 100644
--- a/doc/eclat-associate-address.1
+++ b/doc/eclat-associate-address.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 ASSOCIATE\-ADDRESS 1 "October 15, 2012" "ECLAT" "Eclat User Reference"
+.TH ASSOCIATE\-ADDRESS 1 "December 5, 2012" "ECLAT" "Eclat User Reference"
.SH NAME
eclat associate\-address \- associate an IP address with an instance
.SH SYNOPSIS
@@ -72,7 +72,9 @@ Associate an IP address with an instance in the VPC:
.fi
.SH "SEE ALSO"
.BR eclat (1),
-.BR eclat\-associate\-address (1).
+.BR eclat\-allocate\-address (1),
+.BR eclat\-release\-address (1),
+.BR eclat\-disassociate\-address (1).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
diff --git a/doc/eclat-describe-addresses.1 b/doc/eclat-describe-addresses.1
index fd163eb..a8e88f6 100644
--- a/doc/eclat-describe-addresses.1
+++ b/doc/eclat-describe-addresses.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 DESCRIBE\-ADDRESSES 1 "October 15, 2012" "ECLAT" "Eclat User Reference"
+.TH DESCRIBE\-ADDRESSES 1 "December 5, 2012" "ECLAT" "Eclat User Reference"
.SH NAME
eclat describe\-addresses \- return information about IP addresses in
your account
@@ -74,6 +74,8 @@ standard 198.51.100.2
.fi
.SH "SEE ALSO"
.BR eclat (1),
+.BR eclat\-allocate\-address (1),
+.BR eclat\-release\-address (1),
.BR eclat\-associate\-address (1),
.BR eclat\-disassociate\-address (1).
.SH AUTHORS
diff --git a/doc/eclat-disassociate-address.1 b/doc/eclat-disassociate-address.1
index 63c8209..2d4cdf3 100644
--- a/doc/eclat-disassociate-address.1
+++ b/doc/eclat-disassociate-address.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 DISASSOCIATE\-ADDRESS 1 "October 15, 2012" "ECLAT" "Eclat User Reference"
+.TH DISASSOCIATE\-ADDRESS 1 "December 5, 2012" "ECLAT" "Eclat User Reference"
.SH NAME
eclat disassociate\-address \- disassociate IP address from EC2 instance.
.SH SYNOPSIS
@@ -47,7 +47,7 @@ Disassociate the Elastic IP:
Disassociate the VPC Elastic IP:
.P
.nf
-.B eclat associate\-address \-\-vpc eipalloc\-5723d13e
+.B eclat disassociate\-address \-\-vpc eipalloc\-5723d13e
.fi
.SH "SEE ALSO"
.BR eclat (1),
diff --git a/doc/eclat-release-address.1 b/doc/eclat-release-address.1
new file mode 100644
index 0000000..f2e8d5f
--- /dev/null
+++ b/doc/eclat-release-address.1
@@ -0,0 +1,96 @@
+.\" 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 DISASSOCIATE\-ADDRESS 1 "December 5, 2012" "ECLAT" "Eclat User Reference"
+.SH NAME
+eclat release\-address \- release Elastic IP address.
+.SH SYNOPSIS
+eclat release\-address [\fB\-\-vpc\fR] [\fB\-v\fR] IP-OR-ALLOCID
+
+eclat release\-address \fB\-\-help\fR
+.SH DESCRIPTION
+This command releases IP address. This is a destructive operation,
+beacause normally the released IP address cannot be recovered for your
+account. Therefore, before actually doing this,
+.B eclat
+will ask you for confirmation interactively. You can disable this by
+using the \fB\-Y\fR (\fB\-\-yes\fR) or \fB\-N\fR (\fB\-\-no\fR)
+option, for positive and negative answer, correspondingly.
+.PP
+The use of one of this options is mandatory if
+.B eclat
+is started from a shell script.
+.SH OPTIONS
+.TP
+\fB\-v\fR, \fB\-\-vpc\fR
+Release a VPC Elastic IP address. If this option is given, the
+argument is treated as the allocation ID corresponding to the VPC
+Elastic IP address.
+.SH "OUTPUT AND RETURN VALUE"
+The default output format does not display anything if the operation
+succeeds. Otherwise it prints on the standard error the diagnostic
+message returned by the Amazon, and returns code 1 to the shell.
+.PP
+The code 2 is returned if
+.B eclat
+is unable to recognize the response.
+.PP
+The code 16 is returned if the operation is not confirmed.
+.SH EXAMPLES
+.SS 1.
+Release the Elastic IP:
+.P
+.nf
+.B $ eclat release\-address 192.0.2.1
+Really release IP 192.0.2.1 [Y/n] y
+.fi
+.SS 2.
+Same, with confirmation disabled:
+.P
+.nf
+.B $ eclat -Y release\-address 192.0.2.1
+.fi
+.SS 3.
+Release the VPC Elastic IP:
+.P
+.nf
+.B eclat release\-address \-\-vpc eipalloc\-5723d13e
+.fi
+.SH "SEE ALSO"
+.BR eclat (1),
+.BR eclat\-allocate\-address (1),
+.BR eclat\-associate\-address (1),
+.BR eclat\-disassociate\-address (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/eclat.1 b/doc/eclat.1
index 3172d97..58a67e7 100644
--- a/doc/eclat.1
+++ b/doc/eclat.1
@@ -225,6 +225,7 @@ commands are implemented:
.BR disassociate\-address ,
.BR get\-console\-output ,
.BR reboot\-instances ,
+.BR release\-address ,
.BR start\-instances ,
.BR stop\-instances .
.PP
@@ -317,11 +318,29 @@ Set access file.
Set AWS region name.
.SS Modifiers
.TP
+\fB\-N\fR, \fB\-\-no\fR
+Some potentially dangerous and unrecoverable operations (such as
+.BR release-address )
+require confirmation. If started from the command line,
+.B eclat
+will ask for confirmation interactively. This option disables this
+behavior and instructs the program to assume negative answer to all
+confirmations. See also \fB\-Y\fR option below.
+.TP
\fB\-s\fR, \fB\-\-sort\fR
Sort the returned XML teee prior to outputting it.
.TP
\fB\-\-ssl\fR
Use SSL (HTTPS) connection
+.TP
+\fB\-Y\fR, \fB\-\-yes\fR
+Some potentially dangerous and unrecoverable operations (such as
+.BR release-address )
+require confirmation. If started from the command line,
+.B eclat
+will ask for confirmation interactively. This option disables this
+behavior and instructs the program to assume positive answer to all
+confirmations. See also \fB\-N\fR option above.
.SS Mapping
.TP
\fB\-M\fR, \fB\-\-map\fR=\fIMAPNAME\fR
@@ -406,6 +425,7 @@ Other exit codes may be returned as a result of calling
from the format file.
.SH "SEE ALSO"
.BR eclat.conf (5),
+.BR eclat\-allocate\-address (1),
.BR eclat\-associate\-address (1),
.BR eclat\-create\-tags (1),
.BR eclat\-create\-snapshot (1),
@@ -422,6 +442,7 @@ from the format file.
.BR eclat\-disassociate\-address (1),
.BR eclat\-get\-console\-output (1),
.BR eclat\-reboot\-instances (1),
+.BR eclat\-release\-address (1),
.BR eclat\-start\-instances (1),
.BR eclat\-stop\-instances (1),
.BR forlan (5).
diff --git a/etc/Makefile.am b/etc/Makefile.am
index aa88a74..0a64e40 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -34,6 +34,7 @@ FLNFILES=\
disassociate-address.fln\
get-console-output.fln\
reboot-instances.fln\
+ release-address.fln\
start-instances.fln\
stop-instances.fln
diff --git a/etc/release-address.fln b/etc/release-address.fln
new file mode 100644
index 0000000..c79c220
--- /dev/null
+++ b/etc/release-address.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 (.ReleaseAddressResponse.return) {
+ if (!.ReleaseAddressResponse.return[true]) {
+ error("Return: ",.ReleaseAddressResponse.return,"\n");
+ exit(1);
+ }
+}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7b2cb11..e418134 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -31,6 +31,7 @@ maps = \
libeclat_a_SOURCES=\
base64.c\
+ confirm.c\
diag.c\
expand.c\
forlan.c\
@@ -39,6 +40,7 @@ libeclat_a_SOURCES=\
forlangrm.y\
forlanlex.l\
getans.c\
+ getyn.c\
hmac_sha1.c\
libeclat.h\
map.c\
diff --git a/lib/confirm.c b/lib/confirm.c
new file mode 100644
index 0000000..bd283a1
--- /dev/null
+++ b/lib/confirm.c
@@ -0,0 +1,41 @@
+/* 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 "libeclat.h"
+#include <sysexits.h>
+
+int eclat_confirm_mode = -1;
+
+int
+eclat_confirm(const char *prompt, ...)
+{
+ int rc;
+ va_list ap;
+
+ if (!isatty(0) || eclat_confirm_mode >= 0) {
+ if (eclat_confirm_mode == -1)
+ die(EX_USAGE, "stdin not a terminal and no default response provided; use -Y or -N option to override");
+ return eclat_confirm_mode;
+ }
+
+ va_start(ap, prompt);
+ rc = eclat_vgetyn(!!eclat_confirm_mode, prompt, ap);
+ va_end(ap);
+
+ return rc;
+}
+
+
diff --git a/lib/getyn.c b/lib/getyn.c
new file mode 100644
index 0000000..8ec8a07
--- /dev/null
+++ b/lib/getyn.c
@@ -0,0 +1,77 @@
+/* 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 "libeclat.h"
+#include <stdio.h>
+#include <sysexits.h>
+
+int
+eclat_vgetyn(int dfl, const char *prompt, va_list ap)
+{
+ static char *hint[] = { "y/N", "Y/n" };
+ int state = 0;
+ int c, resp;
+
+ do {
+ switch (state) {
+ case 1:
+ if (c == ' ' || c == '\t')
+ continue;
+ resp = c;
+ state = 2;
+ /* fall through */
+ case 2:
+ if (c == '\n') {
+ switch (resp) {
+ case 'y':
+ case 'Y':
+ return 1;
+ case 'n':
+ case 'N':
+ return 0;
+ case '\n':
+ return dfl;
+ default:
+ err("Please, reply 'y' or 'n'");
+ }
+ state = 0;
+ } else
+ break;
+ case 0:
+ vfprintf(stdout, prompt, ap);
+ fprintf(stdout, " [%s] ", hint[dfl]);
+ fflush(stdout);
+ state = 1;
+ break;
+ }
+ } while ((c = getchar()) != EOF);
+
+ exit(EX_USAGE);
+}
+
+
+int
+eclat_getyn(int dfl, const char *prompt, ...)
+{
+ va_list ap;
+ int rc;
+
+ va_start(ap, prompt);
+ rc = eclat_vgetyn(dfl, prompt, ap);
+ va_end(ap);
+ return rc;
+}
+
diff --git a/lib/libeclat.h b/lib/libeclat.h
index ee94345..35d2538 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -107,6 +107,12 @@ void eclat_partial_tree_end_handler(void *data, const XML_Char *name);
void eclat_trimnl(char *s);
char *eclat_expand_kw(const char *input, const char **ukw);
char *eclat_getans(char *prompt, char *dfl, int pass);
+int eclat_getyn(int dfl, const char *prompt, ...);
+int eclat_vgetyn(int dfl, const char *prompt, va_list ap);
+
+extern int eclat_confirm_mode;
+int eclat_confirm(const char *prompt, ...);
+
#define ECLAT_MAP_OPEN 0x01
diff --git a/src/Makefile.am b/src/Makefile.am
index e75c549..715af98 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,6 +38,7 @@ eclat_SOURCES=\
eclat.h\
genericcl.c\
getconout.c\
+ reladdr.c\
startinst.c\
util.c
@@ -58,7 +59,8 @@ OPTFILES=\
dscrinststat-cl.opt\
dscrsecgrps-cl.opt\
dscrsnap-cl.opt\
- generic-cl.opt
+ generic-cl.opt\
+ reladdr-cl.opt
eclat_SOURCES += $(OPTFILES:.opt=.h)
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 8d82e9d..2d75f24 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -153,6 +153,18 @@ BEGIN
sort_option = 1;
END
+OPTION(yes,Y,,
+ [<assume `yes' to all questions>])
+BEGIN
+ eclat_confirm_mode = 1;
+END
+
+OPTION(no,N,,
+ [<assume `no' to all questions>])
+BEGIN
+ eclat_confirm_mode = 0;
+END
+
GROUP(Identifier translation)
OPTION(translate,x,,
diff --git a/src/eclat.c b/src/eclat.c
index 70cb6c4..e5ea2c1 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -222,6 +222,8 @@ struct command cmdtab[] = {
eclat_describe_volumes },
{ "allocate-address", "AllocateAddress",
eclat_allocate_address },
+ { "release-address", "ReleaseAddress",
+ eclat_release_address },
{ "associate-address", "AssociateAddress",
eclat_associate_address },
{ "disassociate-address", "DisassociateAddress",
diff --git a/src/eclat.h b/src/eclat.h
index 10441f8..57c624f 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -30,6 +30,8 @@
#include "libeclat.h"
#include "forlan.h"
+#define EX_CANCELLED 16
+
#define ECLAT_DEBCAT_MAIN 0
#define ECLAT_DEBCAT_CFGRAM 1
#define ECLAT_DEBCAT_CFLEX 2
@@ -69,6 +71,7 @@ int eclat_describe_tags(CURL *curl, int argc, char **argv);
int eclat_describe_instance_status(CURL *curl, int argc, char **argv);
int eclat_describe_instances(CURL *curl, int argc, char **argv);
int eclat_allocate_address(CURL *curl, int argc, char **argv);
+int eclat_release_address(CURL *curl, int argc, char **argv);
int eclat_associate_address(CURL *curl, int argc, char **argv);
int eclat_disassociate_address(CURL *curl, int argc, char **argv);
int eclat_describe_addresses(CURL *curl, int argc, char **argv);
diff --git a/src/reladdr-cl.opt b/src/reladdr-cl.opt
new file mode 100644
index 0000000..d240fd3
--- /dev/null
+++ b/src/reladdr-cl.opt
@@ -0,0 +1,37 @@
+/* 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/>. */
+
+OPTIONS_BEGIN("eclat release-address",
+ [<release Elastic IP address>],
+ [<IP-OR-ALLOCID>],
+ [<gnu>],
+ [<nousage>],
+ [<noversion>])
+
+OPTION(vpc,v,,
+ [<assign VPC addresses>])
+BEGIN
+ vpc = 1;
+END
+
+OPTIONS_END
+
+static void
+parse_options(int argc, char *argv[], int *index)
+{
+ GETOPT(argc, argv, *index, exit(EX_USAGE))
+}
+
diff --git a/src/reladdr.c b/src/reladdr.c
new file mode 100644
index 0000000..5dc4ead
--- /dev/null
+++ b/src/reladdr.c
@@ -0,0 +1,42 @@
+/* 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 int vpc;
+#include "reladdr-cl.h"
+
+int
+eclat_release_address(CURL *curl, int argc, char **argv)
+{
+ int i;
+ struct ec2_query *q;
+
+ parse_options(argc, argv, &i);
+ argc -= i;
+ argv += i;
+
+ if (argc != 1)
+ die(EX_USAGE, "wrong number of arguments to release-address");
+ if (!eclat_confirm("Really release %s %s",
+ vpc ? "allocation ID" : "IP", argv[0]))
+ exit(EX_CANCELLED);
+
+ q = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/");
+ eclat_query_add_param(q, "Action", "ReleaseAddress");
+ eclat_query_add_param(q, vpc ? "AssociationId" : "PublicIp", argv[0]);
+
+ return eclat_send_query(curl, q);
+}

Return to:

Send suggestions and report system problems to the System administrator.