summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--TODO2
-rw-r--r--doc/Makefile.inc1
-rw-r--r--doc/eclat-mkinst.15
-rw-r--r--doc/eclat-reboot.14
-rw-r--r--doc/eclat-terminate.158
-rw-r--r--etc/Makefile.am3
-rw-r--r--etc/terminate-instances.fln23
-rw-r--r--src/eclat.c4
-rw-r--r--src/eclat.h1
-rw-r--r--src/startstop.c14
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/terminate-instances.at39
-rw-r--r--tests/testsuite.at1
13 files changed, 149 insertions, 7 deletions
diff --git a/TODO b/TODO
index 4fa62d9..3e45bda 100644
--- a/TODO
+++ b/TODO
@@ -142,16 +142,16 @@ ReplaceRoute route ID chg|replace [X] [ ]
ReplaceRouteTableAssociation - [ ] [ ]
ReportInstanceStatus - [ ] [ ]
RequestSpotInstances - [ ] [ ]
ResetImageAttribute - [ ] [ ]
ResetInstanceAttribute - [ ] [ ]
ResetNetworkInterfaceAttribute - [ ] [ ]
ResetSnapshotAttribute clrsattr [X] [X]
RevokeSecurityGroupEgress sg [X] [X]
RevokeSecurityGroupIngress sg [X] [X]
RunInstances mkinst [X] [X]
StartInstances start [X] [X]
StopInstances stop [X] [X]
-TerminateInstances killinst [ ] [ ]
+TerminateInstances terminate [X] [X]
UnassignPrivateIpAddresses - [ ] [ ]
UnmonitorInstances - [ ] [ ]
diff --git a/doc/Makefile.inc b/doc/Makefile.inc
index 143f579..43b62b3 100644
--- a/doc/Makefile.inc
+++ b/doc/Makefile.inc
@@ -52,16 +52,17 @@ MANPAGES1=\
eclat-mkvpc.1\
eclat-reboot.1\
eclat-rmaddr.1\
eclat-rmsg.1\
eclat-rmsnap.1\
eclat-rmtag.1\
eclat-setaattr.1\
eclat-setiattr.1\
eclat-setsattr.1\
eclat-sg.1\
eclat-start.1\
eclat-stop.1\
+ eclat-terminate.1\
ispeek.1
MANPAGES5=\
eclat.conf.5
diff --git a/doc/eclat-mkinst.1 b/doc/eclat-mkinst.1
index f934484..4db3c7e 100644
--- a/doc/eclat-mkinst.1
+++ b/doc/eclat-mkinst.1
@@ -4,25 +4,25 @@
.\" 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-MKINST 1 "January 26, 2015" "ECLAT" "Eclat User Reference"
+.TH ECLAT-MKINST 1 "November 17, 2018" "ECLAT" "Eclat User Reference"
.SH NAME
eclat-mkinst, eclat-run-instances \- launch new EC2 instances
.SH SYNOPSIS
.nh
.na
\fBeclat mkinst\fR [\fB\-a\fR \fIIFACE\fR] [\fB\-d\fR \fISTRING\fR]\
[\fB\-f\fR \fI FILE\fR] [\fB\-g\fR \fISTRING\fR]\
[\fB\-k\fR \fIID\fR] [\fB\-m\fR \fIDEV\fR=\fISPEC\fR] [\fB\-n\fR \fIN\fR]\
[\fB\-p\fR \fINAME\fR] [\fB\-s\fR \fIID\fR] [\fB\-t\fR \fITYPE\fR]\
[\fB\-z\fR \fIZONE\fR] [\fB\-\-data\fR=\fISTRING\fR]\
[\fB\-\-data\-file\fR=\fIFILE\fR]\
[\fB\-\-devmap\fR=\fIDEV\fR=\fISPEC\fR]\
@@ -157,37 +157,38 @@ Instance type.
\fB\-\-tenancy\fR=\fISTRING\fR
Placement tenancy.
.TP
\fB\-z\fR, \fB\-\-zone\fR, \fB\-\-availability\-zone\fR=\fIZONE\fR
Set availablility zone.
.SH OUTPUT
On success, the command outputs detailed description of each created
instance in the same format as the
.BR eclat-lsinst (1)
command
.SH "SEE ALSO"
.BR eclat (1),
+.BR eclat\-terminate (1),
.BR eclat\-lsiattr (1),
.BR eclat\-lsinst (1),
.BR eclat\-lsistat (1),
.BR eclat\-reboot (1),
.BR eclat\-setiattr (1),
.BR eclat\-start (1),
.BR eclat\-stop (1).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <bug\-eclat@gnu.org.ua>.
.SH COPYRIGHT
-Copyright \(co 2012-2015 Sergey Poznyakoff
+Copyright \(co 2012-2018 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: "\""
diff --git a/doc/eclat-reboot.1 b/doc/eclat-reboot.1
index 1addd87..d234808 100644
--- a/doc/eclat-reboot.1
+++ b/doc/eclat-reboot.1
@@ -4,41 +4,41 @@
.\" 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-REBOOT 1 "January 26, 2015" "ECLAT" "Eclat User Reference"
+.TH ECLAT-REBOOT 1 "November 17, 2018" "ECLAT" "Eclat User Reference"
.SH NAME
eclat-reboot, eclat-reboot-instances \- reboot EC2 instances
.SH SYNOPSIS
.nh
.na
\fBeclat reboot\fR \fIID\fR [\fIID\fR...]
.PP
\fBeclat reboot\fR \fB\-\-help\fR
.ad
.hy
.SH DESCRIPTION
The command
.B reboot
reboots running Amazon EBS-backed instances.
.SH OUTPUT
-The default output format lists o each line the instance ID, its
+The default output format lists on each line the instance ID, its
previous and current states, separated by single horizontal tab
characters.
.SH "SEE ALSO"
.BR eclat (1),
.BR eclat\-start (1),
.BR eclat\-stop (1).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <bug\-eclat@gnu.org.ua>.
.SH COPYRIGHT
Copyright \(co 2012-2015 Sergey Poznyakoff
diff --git a/doc/eclat-terminate.1 b/doc/eclat-terminate.1
new file mode 100644
index 0000000..a70a1ee
--- a/dev/null
+++ b/doc/eclat-terminate.1
@@ -0,0 +1,58 @@
+.\" This file is part of Eclat -*- nroff -*-
+.\" Copyright (C) 2012-2018 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-TERMINATE 1 "November 17, 2018" "ECLAT" "Eclat User Reference"
+.SH NAME
+eclat-terminate, eclat-terminate-instances \- terminate EC2 instances
+.SH SYNOPSIS
+.nh
+.na
+\fBeclat terminate\fR \fIID\fR [\fIID\fR...]
+.PP
+\fBeclat terminate\fR \fB\-\-help\fR
+.ad
+.hy
+.SH DESCRIPTION
+Terminates the listed Amazon EBS-backed instances.
+.SH OUTPUT
+The default output format lists on each line the instance ID, its
+previous and current states, separated by single horizontal tab
+characters.
+.SH "SEE ALSO"
+.BR eclat (1),
+.BR eclat\-mkinst (1),
+.BR eclat\-start (1),
+.BR eclat\-stop (1).
+.SH AUTHORS
+Sergey Poznyakoff
+.SH "BUG REPORTS"
+Report bugs to <bug\-eclat@gnu.org.ua>.
+.SH COPYRIGHT
+Copyright \(co 2012-2018 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/etc/Makefile.am b/etc/Makefile.am
index 21b958b..2376583 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -72,25 +72,26 @@ FLNFILES=\
modify-instance-attribute.fln\
modify-snapshot-attribute.fln\
modify-subnet-attribute.fln\
modify-vpc-attribute.fln\
reboot-instances.fln\
release-address.fln\
replace-route.fln\
route.fln\
reset-snapshot-attribute.fln\
run-instances.fln\
sg.fln\
start-instances.fln\
- stop-instances.fln
+ stop-instances.fln\
+ terminate-instances.fln
EXTRA_DIST=$(FLNFILES) default.fln eclat.cfin
SUFFIXES=.cfin .conf
if SPLIT_FORMATS
SUFFIXES += .forlan .fln
.fln.forlan:
$(AM_V_GEN)$(abs_builddir)/flncat $^ default.fln > $@
FORMATFILES = $(FLNFILES:.fln=.forlan)
FORMATNAME = $${command}
lsattr.forlan: describe-instance-attribute.fln describe-snapshot-attribute.fln
diff --git a/etc/terminate-instances.fln b/etc/terminate-instances.fln
new file mode 100644
index 0000000..12995c3
--- a/dev/null
+++ b/etc/terminate-instances.fln
@@ -0,0 +1,23 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012-2018 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 (.TerminateInstancesResponse) {
+ for (var in .TerminateInstancesResponse.instancesSet.item) {
+ print(var.instanceId,": ",
+ var.previousState.name," => ",
+ var.currentState.name,"\n");
+ }
+}
diff --git a/src/eclat.c b/src/eclat.c
index 12b4dd1..26a8f9f 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -81,24 +81,27 @@ void listcmd(char *fmt);
#define CMD_MOD 0x01
#define CMD_DESTR 0x02
#define CMD_NOQRY 0x04
struct eclat_command cmdtab[] = {
{ "start", "start-instances", "StartInstances", eclat_start_instance,
CMD_MOD },
{ "stop", "stop-instances", "StopInstances", eclat_stop_instance,
CMD_MOD },
{ "reboot", "reboot-instances", "RebootInstances", eclat_reboot_instance,
CMD_MOD },
+ { "terminate", "terminate-instances", "TerminateInstances",
+ eclat_terminate_instances, CMD_MOD|CMD_DESTR },
+
{ "lsaddr", "describe-addresses", "DescribeAddresses",
eclat_describe_addresses },
{ "lstag", "describe-tags", "DescribeTags", eclat_describe_tags },
{ "lsiattr", "describe-instance-attribute", "DescribeInstanceAttribute",
eclat_describe_instance_attribute },
{ "lsistat", "describe-instance-status", "DescribeInstanceStatus",
eclat_describe_instance_status },
{ "lsinst", "describe-instances", "DescribeInstances",
eclat_describe_instances },
{ "lsvol", "describe-volumes", "DescribeVolumes",
eclat_describe_volumes },
{ "mkaddr", "allocate-address", "AllocateAddress",
@@ -196,24 +199,25 @@ struct eclat_command cmdtab[] = {
eclat_delete_subnet, CMD_MOD|CMD_DESTR },
{ "mkrtab", "create-route-table", "CreateRouteTable",
eclat_create_route_table, CMD_MOD },
{ "rmrtab", "delete-route-table", "DeleteRouteTable",
eclat_delete_route_table, CMD_MOD|CMD_DESTR },
{ "lsrtab", "describe-route-tables", "DescribeRouteTables",
eclat_describe_route_tables },
{ "assocrtab", "associate-route-table", "AssociateRouteTable",
eclat_associate_route_table, CMD_MOD },
{ "disasrtab", "disassociate-route-table", "DisassociateRouteTable",
eclat_disassociate_route_table, CMD_MOD },
{ "route", NULL, NULL, eclat_route },
+
};
size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]);
static int
cmdcmp(const void *a, const void *b)
{
struct eclat_command const *cmda = a;
struct eclat_command const *cmdb = b;
if (cmda->name && cmdb->name)
return strcmp(cmda->name, cmdb->name);
else if (cmda->ident && cmdb->ident)
return strcmp(cmda->ident, cmdb->ident);
diff --git a/src/eclat.h b/src/eclat.h
index 21e89e1..1948234 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -117,24 +117,25 @@ struct eclat_io *eclat_io_init(int errfatal);
void eclat_io_free(struct eclat_io *io);
void eclat_io_shutdown(struct eclat_io *io);
struct grecs_node *eclat_io_finish(struct eclat_io *io);
int eclat_trace_fun(CURL *handle, curl_infotype type,
char *data, size_t size,
void *userp);
int eclat_start_instance(eclat_command_env_t *env, int argc, char **argv);
int eclat_stop_instance(eclat_command_env_t *env, int argc, char **argv);
int eclat_reboot_instance(eclat_command_env_t *env, int argc, char **argv);
+int eclat_terminate_instances(eclat_command_env_t *env, int argc, char **argv);
int eclat_describe_tags(eclat_command_env_t *env, int argc, char **argv);
int eclat_describe_instance_status(eclat_command_env_t *env, int argc, char **argv);
int eclat_describe_instances(eclat_command_env_t *env, int argc, char **argv);
int eclat_allocate_address(eclat_command_env_t *env, int argc, char **argv);
int eclat_release_address(eclat_command_env_t *env, int argc, char **argv);
int eclat_associate_address(eclat_command_env_t *env, int argc, char **argv);
int eclat_disassociate_address(eclat_command_env_t *env, int argc, char **argv);
int eclat_describe_addresses(eclat_command_env_t *env, int argc, char **argv);
int eclat_describe_volumes(eclat_command_env_t *env, int argc, char **argv);
int eclat_get_console_output(eclat_command_env_t *env, int argc, char **argv);
int eclat_describe_instance_attribute(eclat_command_env_t *env, int argc, char **argv);
int eclat_create_tags(eclat_command_env_t *env, int argc, char **argv);
diff --git a/src/startstop.c b/src/startstop.c
index 2460682..78c581c 100644
--- a/src/startstop.c
+++ b/src/startstop.c
@@ -35,25 +35,24 @@ start_stop_instance(eclat_command_env_t *env, int argc, char **argv)
if (argc == 0)
die(EX_USAGE, "no instance ids");
translate_ids(argc, argv, MAP_INSTANCE);
strcpy(buf, "InstanceId.");
bend = buf + strlen(buf);
bs = sizeof(buf) - strlen(buf);
for (i = 0; i < argc; i++) {
snprintf(bend, bs, "%lu", (unsigned long)(i + 1));
eclat_request_add_param(q, buf, argv[i]);
}
-
return 0;
}
int
eclat_start_instance(eclat_command_env_t *env, int argc, char **argv)
{
int i;
parse_options(env->cmd,
"Start named instances",
argc, argv, &i);
@@ -81,12 +80,25 @@ eclat_stop_instance(eclat_command_env_t *env, int argc, char **argv)
int
eclat_reboot_instance(eclat_command_env_t *env, int argc, char **argv)
{
int i;
parse_options(env->cmd,
"Reboot named instances",
argc, argv, &i);
debug(ECLAT_DEBCAT_MAIN, 1, ("rebooting instances"));
return start_stop_instance(env, argc - i, argv + i);
}
+
+int
+eclat_terminate_instances(eclat_command_env_t *env, int argc, char **argv)
+{
+ int i;
+
+ parse_options(env->cmd,
+ "Terminate named instances",
+ argc, argv, &i);
+
+ debug(ECLAT_DEBCAT_MAIN, 1, ("terminate instances"));
+ return start_stop_instance(env, argc - i, argv + i);
+}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 61046ba..36927c7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -75,24 +75,25 @@ TESTSUITE_AT = \
listall.at\
nullmap.at\
print01.at\
print02.at\
print03.at\
seqmap.at\
sortnum.at\
sortrevnum.at\
sortstring.at\
sortts.at\
start-instances.at\
stop-instances.at\
+ terminate-instances.at\
tagshairy.at\
testsuite.at\
urlenc01.at\
xml01.at
TESTSUITE = $(srcdir)/testsuite
M4=m4
AUTOTEST = $(AUTOM4TE) --language=autotest
$(TESTSUITE): package.m4 $(TESTSUITE_AT)
$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
mv $@.tmp $@
diff --git a/tests/terminate-instances.at b/tests/terminate-instances.at
new file mode 100644
index 0000000..7242986
--- a/dev/null
+++ b/tests/terminate-instances.at
@@ -0,0 +1,39 @@
+# This file is part of Eclat -*- Autotest -*-
+# Copyright (C) 2012-2018 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([TerminateInstances],
+[TerminateInstances],
+[terminate-instances.fln],
+[<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <instancesSet>
+ <item>
+ <instanceId>i-1234567890abcdef0</instanceId>
+ <currentState>
+ <code>32</code>
+ <name>shutting-down</name>
+ </currentState>
+ <previousState>
+ <code>16</code>
+ <name>running</name>
+ </previousState>
+ </item>
+ </instancesSet>
+</TerminateInstancesResponse>
+],
+[i-1234567890abcdef0: running => shutting-down
+])
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 6583b89..0d25b97 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -69,24 +69,25 @@ m4_include([delete-snapshot.at])
m4_include([describe-addresses.at])
m4_include([describe-availability-zones.at])
m4_include([describe-instance-attribute.at])
m4_include([describe-instance-status.at])
m4_include([describe-instances.at])
m4_include([describe-security-groups.at])
m4_include([describe-snapshots.at])
m4_include([describe-tags.at])
m4_include([describe-volumes.at])
m4_include([get-console-output.at])
m4_include([start-instances.at])
m4_include([stop-instances.at])
+m4_include([terminate-instances.at])
AT_BANNER([Sort])
m4_include([sortstring.at])
m4_include([sortnum.at])
m4_include([sortrevnum.at])
m4_include([sortts.at])
AT_BANNER([Maps])
m4_include([nullmap.at])
m4_include([filemap.at])
m4_include([gdbmmap.at])
m4_include([seqmap.at])

Return to:

Send suggestions and report system problems to the System administrator.