summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-12-14 22:03:30 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-12-14 22:03:30 (GMT)
commit2116e1ef1cd5597e23f785e84d67d8fea5537475 (patch) (unidiff)
tree6b9b8c33c639a84c81c2db67b4913cd3ef89f35c
parent35c194f2f3bfe666494c62fe3a770661e3886aa6 (diff)
downloadeclat-2116e1ef1cd5597e23f785e84d67d8fea5537475.tar.gz
eclat-2116e1ef1cd5597e23f785e84d67d8fea5537475.tar.bz2
Implement ModifyVolume and DescribeVolumesModifications
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--TODO2
-rw-r--r--etc/Makefile.am2
-rw-r--r--etc/describe-volumes-modifications.fln49
-rw-r--r--etc/modify-volume.fln45
-rw-r--r--lib/libeclat.h2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/chvol.c86
-rw-r--r--src/eclat.c5
-rw-r--r--src/eclat.h4
-rw-r--r--src/lschvol.c68
10 files changed, 263 insertions, 2 deletions
diff --git a/TODO b/TODO
index 3e45bda..f0b5579 100644
--- a/TODO
+++ b/TODO
@@ -104,6 +104,7 @@ DescribeSpotPriceHistory - [ ] [ ]
104DescribeSubnets lssubnet [X] [ ] 104DescribeSubnets lssubnet [X] [ ]
105DescribeTags lstag [X] [X] 105DescribeTags lstag [X] [X]
106DescribeVolumes lsvol [X] [X] 106DescribeVolumes lsvol [X] [X]
107DescribeVolumesModifications lschvol [X] [ ]
107DescribeVolumeAttribute - [ ] [ ] 108DescribeVolumeAttribute - [ ] [ ]
108DescribeVolumeStatus - [ ] [ ] 109DescribeVolumeStatus - [ ] [ ]
109DescribeVpcAttribute lsvpcattr [X] [ ] 110DescribeVpcAttribute lsvpcattr [X] [ ]
@@ -129,6 +130,7 @@ ModifyInstanceAttribute setiattr [X] [X]
129ModifyNetworkInterfaceAttribute - [ ] [ ] 130ModifyNetworkInterfaceAttribute - [ ] [ ]
130ModifySnapshotAttribute setsattr [X] [X] 131ModifySnapshotAttribute setsattr [X] [X]
131ModifySubnetAttribute setsubnetattr [X] [ ] 132ModifySubnetAttribute setsubnetattr [X] [ ]
133ModifyVolume chvol [X] [ ]
132ModifyVolumeAttribute - [ ] [ ] 134ModifyVolumeAttribute - [ ] [ ]
133ModifyVpcAttribute setvpcattr [X] [ ] 135ModifyVpcAttribute setvpcattr [X] [ ]
134MonitorInstances - [ ] [ ] 136MonitorInstances - [ ] [ ]
diff --git a/etc/Makefile.am b/etc/Makefile.am
index 2376583..7d0b355 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -60,6 +60,7 @@ FLNFILES=\
60 describe-subnets.fln\ 60 describe-subnets.fln\
61 describe-tags.fln\ 61 describe-tags.fln\
62 describe-volumes.fln\ 62 describe-volumes.fln\
63 describe-volumes-modifications.fln\
63 describe-vpc-attribute.fln\ 64 describe-vpc-attribute.fln\
64 describe-vpcs.fln\ 65 describe-vpcs.fln\
65 detach-internet-gateway.fln\ 66 detach-internet-gateway.fln\
@@ -72,6 +73,7 @@ FLNFILES=\
72 modify-instance-attribute.fln\ 73 modify-instance-attribute.fln\
73 modify-snapshot-attribute.fln\ 74 modify-snapshot-attribute.fln\
74 modify-subnet-attribute.fln\ 75 modify-subnet-attribute.fln\
76 modify-volume.fln\
75 modify-vpc-attribute.fln\ 77 modify-vpc-attribute.fln\
76 reboot-instances.fln\ 78 reboot-instances.fln\
77 release-address.fln\ 79 release-address.fln\
diff --git a/etc/describe-volumes-modifications.fln b/etc/describe-volumes-modifications.fln
new file mode 100644
index 0000000..f752490
--- a/dev/null
+++ b/etc/describe-volumes-modifications.fln
@@ -0,0 +1,49 @@
1/* This file is part of Eclat.
2 Copyright (C) 2018 Sergey Poznyakoff.
3
4 Eclat is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Eclat is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
16
17if (.DescribeVolumesModificationsResponse.volumeModificationSet.item) {
18 for (var in .DescribeVolumesModificationsResponse.volumeModificationSet.item) {
19 print(var.volumeId,
20 " ",
21 var.modificationState,
22 " ",
23 var.progress,
24 "%\n");
25 if (var.targetSize) {
26 print("\tsize: ",
27 var.originalSize,
28 " => ",
29 var.targetSize,
30 "\n");
31 }
32 if (var.targetVolumeType) {
33 print("\ttype: ",
34 var.originalVolumeType,
35 " => ",
36 var.targetVolumeType,
37 "\n");
38 }
39 if (var.targetIops) {
40 print("\tiops:",
41 var.originalIops,
42 " => ",
43 var.targetIops,
44 "\n");
45 }
46 }
47}
48
49
diff --git a/etc/modify-volume.fln b/etc/modify-volume.fln
new file mode 100644
index 0000000..6b04bec
--- a/dev/null
+++ b/etc/modify-volume.fln
@@ -0,0 +1,45 @@
1/* This file is part of Eclat.
2 Copyright (C) 2018 Sergey Poznyakoff.
3
4 Eclat is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Eclat is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
16
17if (.ModifyVolumeResponse.volumeModification) {
18 print(.ModifyVolumeResponse.volumeModification.volumeId,
19 ": ",
20 .ModifyVolumeResponse.volumeModification.modificationState,
21 " ",
22 .ModifyVolumeResponse.volumeModification.progress,
23 "%\n");
24 if (.ModifyVolumeResponse.volumeModification.targetSize) {
25 print("\tsize: ",
26 .ModifyVolumeResponse.volumeModification.originalSize,
27 " => ",
28 .ModifyVolumeResponse.volumeModification.targetSize,
29 "\n");
30 }
31 if (.ModifyVolumeResponse.volumeModification.targetVolumeType) {
32 print("\ttype: ",
33 .ModifyVolumeResponse.volumeModification.originalVolumeType,
34 " => ",
35 .ModifyVolumeResponse.volumeModification.targetVolumeType,
36 "\n");
37 }
38 if (.ModifyVolumeResponse.volumeModification.targetIops) {
39 print("\tiops: ",
40 .ModifyVolumeResponse.volumeModification.originalIops,
41 " => ",
42 .ModifyVolumeResponse.volumeModification.targetIops,
43 "\n");
44 }
45 } \ No newline at end of file
diff --git a/lib/libeclat.h b/lib/libeclat.h
index 6f1acf6..285e045 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -83,7 +83,7 @@ struct ec2_param {
83 int encoded; 83 int encoded;
84}; 84};
85 85
86#define EC2_API_VERSION "2014-06-15" 86#define EC2_API_VERSION "2016-11-15"
87 87
88#define EC2_RF_HTTPS 0x01 88#define EC2_RF_HTTPS 0x01
89#define EC2_RF_POST 0x02 89#define EC2_RF_POST 0x02
diff --git a/src/Makefile.am b/src/Makefile.am
index e78461c..c4fc211 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,7 @@ eclat_SOURCES=\
21 allocaddr.c\ 21 allocaddr.c\
22 asscaddr.c\ 22 asscaddr.c\
23 atvol.c\ 23 atvol.c\
24 chvol.c\
24 cmdline.h\ 25 cmdline.h\
25 config.c\ 26 config.c\
26 cpimg.c\ 27 cpimg.c\
@@ -39,6 +40,7 @@ eclat_SOURCES=\
39 lsaddr.c\ 40 lsaddr.c\
40 lsattr.c\ 41 lsattr.c\
41 lsaattr.c\ 42 lsaattr.c\
43 lschvol.c\
42 lsiattr.c\ 44 lsiattr.c\
43 lsimg.c\ 45 lsimg.c\
44 lsinst.c\ 46 lsinst.c\
diff --git a/src/chvol.c b/src/chvol.c
new file mode 100644
index 0000000..f1246c9
--- a/dev/null
+++ b/src/chvol.c
@@ -0,0 +1,86 @@
1/* This file is part of Eclat.
2 Copyright (C) 2012-2018 Sergey Poznyakoff.
3
4 Eclat is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Eclat is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
16
17#include "eclat.h"
18
19// eclat modvol VOLID [iops=V] [size=S] [type=V]
20
21char const *params[] = {
22 "iops",
23 "Iops",
24 "size",
25 "Size",
26 "type",
27 "VolumeType"
28};
29
30static char const *
31getparam(char const *p, size_t len)
32{
33 int i;
34
35 for (i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
36 if (len == strlen(params[i])
37 && memcmp(params[i], p, len) == 0) {
38 if (i % 2 == 0)
39 i++;
40 return params[i];
41 }
42 }
43 return NULL;
44}
45
46int
47eclat_modify_volume(eclat_command_env_t *env, int argc, char **argv)
48{
49 int i;
50 struct ec2_request *q = env->request;
51
52 generic_proginfo->args_doc = "VOL-ID [iops=V] [size=S] [type=V]";
53 generic_parse_options(env->cmd,
54 "modify volume parameters",
55 argc, argv, &i);
56 argv += i;
57 argc -= i;
58
59 if (argc == 0)
60 die(EX_USAGE, "wrong number of arguments");
61
62 translate_ids(1, argv, MAP_VOLUME);
63 eclat_request_add_param(q, "VolumeId", argv[0]);
64 for (i = 1; i < argc; i++) {
65 size_t len;
66 char const *param;
67 char const *value;
68
69 len = strcspn(argv[i], "=");
70 param = getparam(argv[i], len);
71 if (!param)
72 die(EX_USAGE, "unrecognized parameter: %s", argv[i]);
73 if (argv[i][len]) {
74 value = argv[i] + len + 1;
75 } else {
76 i++;
77 if (i == argc)
78 die(EX_USAGE, "missing value for %s",
79 argv[i-1]);
80 value = argv[i];
81 }
82 eclat_request_add_param(q, param, value);
83 }
84 return 0;
85}
86
diff --git a/src/eclat.c b/src/eclat.c
index 26a8f9f..43387be 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -208,7 +208,10 @@ struct eclat_command cmdtab[] = {
208 { "disasrtab", "disassociate-route-table", "DisassociateRouteTable", 208 { "disasrtab", "disassociate-route-table", "DisassociateRouteTable",
209 eclat_disassociate_route_table, CMD_MOD }, 209 eclat_disassociate_route_table, CMD_MOD },
210 { "route", NULL, NULL, eclat_route }, 210 { "route", NULL, NULL, eclat_route },
211 211 { "chvol", "modify-volume", "ModifyVolume",
212 eclat_modify_volume },
213 { "lschvol", "describe-volumes-modifications", "DescribeVolumesModifications",
214 eclat_describe_volumes_modifications }
212}; 215};
213size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]); 216size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]);
214 217
diff --git a/src/eclat.h b/src/eclat.h
index 1948234..f314476 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -157,6 +157,10 @@ int eclat_create_volume(eclat_command_env_t *env, int argc, char **argv);
157int eclat_delete_volume(eclat_command_env_t *env, int argc, char **argv); 157int eclat_delete_volume(eclat_command_env_t *env, int argc, char **argv);
158int eclat_attach_volume(eclat_command_env_t *env, int argc, char **argv); 158int eclat_attach_volume(eclat_command_env_t *env, int argc, char **argv);
159int eclat_detach_volume(eclat_command_env_t *env, int argc, char **argv); 159int eclat_detach_volume(eclat_command_env_t *env, int argc, char **argv);
160int eclat_modify_volume(eclat_command_env_t *env, int argc, char **argv);
161int eclat_describe_volumes_modifications(eclat_command_env_t *env, int argc,
162 char **argv);
163
160int eclat_modify_instance_attribute(eclat_command_env_t *env, 164int eclat_modify_instance_attribute(eclat_command_env_t *env,
161 int argc, char **argv); 165 int argc, char **argv);
162int eclat_run_instances(eclat_command_env_t *env, int argc, char **argv); 166int eclat_run_instances(eclat_command_env_t *env, int argc, char **argv);
diff --git a/src/lschvol.c b/src/lschvol.c
new file mode 100644
index 0000000..28e7dc2
--- a/dev/null
+++ b/src/lschvol.c
@@ -0,0 +1,68 @@
1/* This file is part of Eclat.
2 Copyright (C) 2018 Sergey Poznyakoff.
3
4 Eclat is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Eclat is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
16
17#include "eclat.h"
18
19static char *modification_state_enum[] = {
20 "modifying",
21 "optimizing",
22 "completed",
23 "failed",
24 NULL
25};
26
27static char *volume_type_enum[] = {
28 "standard",
29 "io1",
30 "gp2",
31 "sc1",
32 "st1",
33 NULL
34};
35
36static struct filter_descr filters[] = {
37 { "volume-id", FILTER_STRING },
38 { "modification-state", FILTER_ENUM, modification_state_enum },
39 { "target-size", FILTER_INT },
40 { "target-iops", FILTER_INT },
41 { "target-volume-type", FILTER_ENUM, volume_type_enum },
42 { "original-size", FILTER_INT },
43 { "original-iops", FILTER_INT },
44 { "original-volume-type", FILTER_ENUM, volume_type_enum },
45 { "start-time", FILTER_DATE },
46 { NULL }
47};
48
49int
50eclat_describe_volumes_modifications(eclat_command_env_t *env, int argc,
51 char **argv)
52{
53 int i;
54
55 available_filters = filters;
56 generic_proginfo->print_help_hook = list_filters;
57 generic_proginfo->args_doc = "[FILTER...] [ID...]";
58 generic_parse_options(env->cmd,
59 "describe current modifications status of EBS volumes",
60 argc, argv, &i);
61 argv += i;
62 argc -= i;
63 translate_ids(argc, argv, MAP_VOLUME);
64
65 describe_request_create(env, argc, argv, "VolumeId");
66 return 0;
67}
68

Return to:

Send suggestions and report system problems to the System administrator.