aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO4
-rw-r--r--doc/Makefile.am1
-rw-r--r--doc/eclat-create-volume.171
-rw-r--r--doc/eclat-delete-volume.173
-rw-r--r--doc/eclat-release-address.14
-rw-r--r--doc/eclat.14
-rw-r--r--etc/Makefile.am2
-rw-r--r--etc/create-volume.fln20
-rw-r--r--etc/delete-volume.fln22
-rw-r--r--src/Makefile.am3
-rw-r--r--src/crevol-cl.opt45
-rw-r--r--src/crevol.c47
-rw-r--r--src/delvol.c43
-rw-r--r--src/eclat.c5
-rw-r--r--src/eclat.h2
15 files changed, 342 insertions, 4 deletions
diff --git a/TODO b/TODO
index 44fa7e7..6cae592 100644
--- a/TODO
+++ b/TODO
@@ -43,7 +43,7 @@ CreateSnapshot CRESNAP [X] [X]
CreateSpotDatafeedSubscription CRESPOTDFSSCR [ ] [ ]
CreateSubnet CRESUB [ ] [ ]
CreateTags CRETAGS [X] [X]
-CreateVolume CREVOL [ ] [ ]
+CreateVolume CREVOL [X] [X]
CreateVpc CREVPC [ ] [ ]
CreateVpnConnection CREVPNCNCT [ ] [ ]
CreateVpnConnectionRoute CREVPNCNCTROUT [ ] [ ]
@@ -63,7 +63,7 @@ DeleteSnapshot DELSNAP [X] [X]
DeleteSpotDatafeedSubscription DELSPOTDFSSCR [ ] [ ]
DeleteSubnet DELSUB [ ] [ ]
DeleteTags DELTAGS [X] [X]
-DeleteVolume DELVOL [ ] [ ]
+DeleteVolume DELVOL [X] [X]
DeleteVpc DELVPC [ ] [ ]
DeleteVpnConnection DELVPNCNCT [ ] [ ]
DeleteVpnConnectionRoute DELVPNCNCTROUT [ ] [ ]
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 051b8e0..271b4b6 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -20,6 +20,7 @@ MANPAGES1=\
eclat-associate-address.1\
eclat-create-snapshot.1\
eclat-create-tags.1\
+ eclat-create-volume.1\
eclat-delete-snapshot.1\
eclat-delete-tags.1\
eclat-describe-addresses.1\
diff --git a/doc/eclat-create-volume.1 b/doc/eclat-create-volume.1
new file mode 100644
index 0000000..a861fdb
--- /dev/null
+++ b/doc/eclat-create-volume.1
@@ -0,0 +1,71 @@
+.\" 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\-CREATE\-VOLUME 1 "December 6, 2012" "ECLAT" "Eclat User Reference"
+.SH NAME
+eclat create\-volume \- create an Amazon EBS volume
+.SH SYNOPSIS
+eclat create\-volume [\fB\-i\fR \fIN\fR] [\fB\-s\fR]\
+ [\fB\-\-iops\fR=\fIN\fR] [\fB\-\-snapshot\fR=\fIID\fR] \fBSIZE\fR \fBZONE\fR
+
+eclat create\-volume \fB\-\-help\fR
+.SH DESCRIPTION
+This command creates a new Amazon EBS volume of size \fBSIZE\fR in the
+availability zone \fBZONE\fR. The created volume can then be attached
+to any EC2 instance in the same Availability Zone.
+.SH OPTIONS
+.TP
+\fB\-i\fR, \fB\-\-iops\fR \fIN\fR
+Sets the supported number of I/O operations per second (IOPS).
+.TP
+\fB\-s\fR, \fB\-\-snapshot\fR \fIID\fR
+The snapshot ID from which to create the new volume.
+.SH OUTPUT
+On success, the default format prints the ID of the created volume and
+its status.
+.SH EXAMPLE
+.nf
+.sp 2
+$ \fBeclat create-volume 80 eu-west-1b\fR
+vol-de1203fa creating
+.fi
+.SH "SEE ALSO"
+.BR eclat (1),
+.BR eclat\-delete\-volume (1),
+.BR eclat\-describe\-volumes (1),
+.BR eclat\-attach\-volume (1),
+.BR eclat\-detach\-volume (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/eclat-delete-volume.1 b/doc/eclat-delete-volume.1
new file mode 100644
index 0000000..a9d7489
--- /dev/null
+++ b/doc/eclat-delete-volume.1
@@ -0,0 +1,73 @@
+.\" 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\-DELETE\-VOLUME 1 "December 6, 2012" "ECLAT" "Eclat User Reference"
+.SH NAME
+eclat delete\-volume \- delete an EC2 volume
+.SH SYNOPSIS
+eclat delete\-volume \fBVOL\-ID\fR
+
+eclat delete\-volume \fB\-\-help\fR
+.SH DESCRIPTION
+This command deletes an Amazon EBS volume. The volume must be in the
+available state, i.e. it must not be attached to an instance.
+.PP
+If ID mapping is enabled (see the section \fBMAPS\fR
+in
+.BR eclat (1)),
+this command treats the \fBVOL\-ID\fR as volume names and translates
+it to the AWS IDs using the \fBVolumeId\fR map.
+.PP
+Since this operation is destructive and may result in a loss of data
+if used carelessly,
+.B eclat
+will ask you for confirmation before actually deleting the volume.
+You can disable this feature by using the \fB\-Y\fR (\fB\-\-yes\fR)
+eclat option, e.g.:
+.nf
+.sp 2
+$ \fBeclat -Y delete-volume vol-d1234aef
+.fi
+.PP
+The use of one of this option is mandatory if this command is invoked
+from a shell script.
+.SH "SEE ALSO"
+.BR eclat (1),
+.BR eclat\-create\-volume (1),
+.BR eclat\-describe\-volumes (1),
+.BR eclat\-attach\-volume (1),
+.BR eclat\-detach\-volume (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/eclat-release-address.1 b/doc/eclat-release-address.1
index f2e8d5f..9ecefa5 100644
--- a/doc/eclat-release-address.1
+++ b/doc/eclat-release-address.1
@@ -13,11 +13,11 @@
.\"
.\" 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"
+.TH DISASSOCIATE\-ADDRESS 1 "December 6, 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\-\-vpc\fR] [\fB\-v\fR] IP\-OR\-ALLOCID
eclat release\-address \fB\-\-help\fR
.SH DESCRIPTION
diff --git a/doc/eclat.1 b/doc/eclat.1
index ee04c7a..3b8a9ed 100644
--- a/doc/eclat.1
+++ b/doc/eclat.1
@@ -212,8 +212,10 @@ commands are implemented:
.BR associate\-address ,
.BR create\-tags ,
.BR create\-snapshot ,
+.BR create\-volume ,
.BR delete\-tags ,
.BR delete\-snapshot ,
+.BR delete\-volume ,
.BR describe\-addresses ,
.BR describe\-availability\-zones ,
.BR describe\-instance\-attribute ,
@@ -430,8 +432,10 @@ from the format file.
.BR eclat\-associate\-address (1),
.BR eclat\-create\-tags (1),
.BR eclat\-create\-snapshot (1),
+.BR eclat\-create\-volume (1),
.BR eclat\-delete\-tags (1),
.BR eclat\-delete\-snapshot (1),
+.BR eclat\-delete\-volume (1),
.BR eclat\-describe\-addresses (1),
.BR eclat\-describe\-availability\-zones (1),
.BR eclat\-describe\-instance\-attribute (1),
diff --git a/etc/Makefile.am b/etc/Makefile.am
index ebbfd7e..236b43d 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -21,8 +21,10 @@ FLNFILES=\
associate-address.fln\
create-snapshot.fln\
create-tags.fln\
+ create-volume.fln\
delete-snapshot.fln\
delete-tags.fln\
+ delete-volume.fln\
describe-addresses.fln\
describe-availability-zones.fln\
describe-instance-attribute.fln\
diff --git a/etc/create-volume.fln b/etc/create-volume.fln
new file mode 100644
index 0000000..d8c9da1
--- /dev/null
+++ b/etc/create-volume.fln
@@ -0,0 +1,20 @@
+/* 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 (.CreateVolumeResponse) {
+ print(.CreateVolumeResponse.volumeId,"\t",
+ .CreateVolumeResponse.status,"\n");
+}
diff --git a/etc/delete-volume.fln b/etc/delete-volume.fln
new file mode 100644
index 0000000..18e9870
--- /dev/null
+++ b/etc/delete-volume.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 (.DeleteVolumeResponse.return) {
+ if (!.DeleteVolumeResponse.return[true]) {
+ error("Return: ",.DeleteVolumeResponse.return,"\n");
+ exit(1);
+ }
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 4d2b443..b77e286 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,9 @@ eclat_SOURCES=\
config.c\
cretags.c\
cresnap.c\
+ crevol.c\
delsnap.c\
+ delvol.c\
disassaddr.c\
dscraddrs.c\
dscrazs.c\
@@ -56,6 +58,7 @@ OPTFILES=\
allocaddr-cl.opt\
asscaddr-cl.opt\
cretags-cl.opt\
+ crevol-cl.opt\
disassaddr-cl.opt\
dscraddrs-cl.opt\
dscrinststat-cl.opt\
diff --git a/src/crevol-cl.opt b/src/crevol-cl.opt
new file mode 100644
index 0000000..af62a07
--- /dev/null
+++ b/src/crevol-cl.opt
@@ -0,0 +1,45 @@
+/* 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 create-volume",
+ [<create EC2 volume>],
+ [<SIZE ZONE>],
+ [<gnu>],
+ [<nousage>],
+ [<noversion>])
+
+OPTION(iops,i,[<IOPS>],
+ [<number of I/O operations per second>])
+BEGIN
+ char *p;
+ unsigned long n = strtoul(optarg, &p, 10);
+ if (*p || n < 100 || n > 2000)
+ die(EX_USAGE, "invalid number of IOPS: %s", optarg);
+END
+
+OPTION(snapshot,s,[<ID>],
+ [<snapshot ID>])
+BEGIN
+ snapshot = optarg;
+END
+
+OPTIONS_END
+
+static void
+parse_options(int argc, char *argv[], int *index)
+{
+ GETOPT(argc, argv, *index, exit(EX_USAGE))
+}
diff --git a/src/crevol.c b/src/crevol.c
new file mode 100644
index 0000000..309e7e7
--- /dev/null
+++ b/src/crevol.c
@@ -0,0 +1,47 @@
+/* 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"
+char *zone;
+char *snapshot;
+char *iops;
+#include "crevol-cl.h"
+
+int
+eclat_create_volume(CURL *curl, int argc, char **argv)
+{
+ int i;
+ struct ec2_query *q;
+
+ parse_options(argc, argv, &i);
+ argc -= i;
+ argv += i;
+ if (argc != 2)
+ die(EX_USAGE, "wrong number of arguments");
+
+ q = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/");
+ eclat_query_add_param(q, "Action", "CreateVolume");
+ eclat_query_add_param(q, "Size", argv[0]);
+ eclat_query_add_param(q, "AvailabilityZone", argv[1]);
+ if (iops) {
+ eclat_query_add_param(q, "VolumeType", "io1");
+ eclat_query_add_param(q, "Iops", iops);
+ }
+ return eclat_send_query(curl, q);
+}
+
+
+
diff --git a/src/delvol.c b/src/delvol.c
new file mode 100644
index 0000000..e3a17f2
--- /dev/null
+++ b/src/delvol.c
@@ -0,0 +1,43 @@
+/* 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"
+
+int
+eclat_delete_volume(CURL *curl, int argc, char **argv)
+{
+ int i;
+ struct ec2_query *q;
+
+ generic_proginfo->args_doc = "VOL-ID";
+ generic_parse_options("eclat delete-volume",
+ "delete a EC2 volume",
+ argc, argv, &i);
+ argc -= i;
+ argv += i;
+
+ if (argc != 1)
+ die(EX_USAGE, "bad number of arguments");
+ translate_ids(argc, argv, "VolumeId");
+ if (!eclat_confirm("Really release volume %s", argv[0]))
+ exit(EX_CANCELLED);
+ q = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/");
+ eclat_query_add_param(q, "Action", "DeleteVolume");
+ eclat_query_add_param(q, "VolumeId", argv[0]);
+ return eclat_send_query(curl, q);
+}
+
+
diff --git a/src/eclat.c b/src/eclat.c
index 2c0dcfe..8eb2402 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -246,6 +246,10 @@ struct command cmdtab[] = {
eclat_describe_avaialbility_zones },
{ "describe-regions", "DescribeRegions",
eclat_describe_regions },
+ { "create-volume", "CreateVolume",
+ eclat_create_volume },
+ { "delete-volume", "DeleteVolume",
+ eclat_delete_volume },
};
size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]);
@@ -503,6 +507,7 @@ find_format(const char *name)
defn = grecs_symtab_lookup_or_install(format_table, &key, NULL);
if (!defn)
return NULL;
+
env = forlan_parse_buffer(defn->text, strlen(defn->text),
&defn->locus.beg);
return env;
diff --git a/src/eclat.h b/src/eclat.h
index e369b7c..ceca4d4 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -86,6 +86,8 @@ 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);
+int eclat_create_volume(CURL *curl, int argc, char **argv);
+int eclat_delete_volume(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.