aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-12-15 00:03:30 +0200
committerSergey Poznyakoff <gray@gnu.org>2018-12-15 00:03:30 +0200
commit2116e1ef1cd5597e23f785e84d67d8fea5537475 (patch)
tree6b9b8c33c639a84c81c2db67b4913cd3ef89f35c
parent35c194f2f3bfe666494c62fe3a770661e3886aa6 (diff)
downloadeclat-2116e1ef1cd5597e23f785e84d67d8fea5537475.tar.gz
eclat-2116e1ef1cd5597e23f785e84d67d8fea5537475.tar.bz2
Implement ModifyVolume and DescribeVolumesModifications
-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
@@ -106,2 +106,3 @@ DescribeTags lstag [X] [X]
106DescribeVolumes lsvol [X] [X] 106DescribeVolumes lsvol [X] [X]
107DescribeVolumesModifications lschvol [X] [ ]
107DescribeVolumeAttribute - [ ] [ ] 108DescribeVolumeAttribute - [ ] [ ]
@@ -131,2 +132,3 @@ ModifySnapshotAttribute setsattr [X] [X]
131ModifySubnetAttribute setsubnetattr [X] [ ] 132ModifySubnetAttribute setsubnetattr [X] [ ]
133ModifyVolume chvol [X] [ ]
132ModifyVolumeAttribute - [ ] [ ] 134ModifyVolumeAttribute - [ ] [ ]
diff --git a/etc/Makefile.am b/etc/Makefile.am
index 2376583..7d0b355 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -62,2 +62,3 @@ FLNFILES=\
62 describe-volumes.fln\ 62 describe-volumes.fln\
63 describe-volumes-modifications.fln\
63 describe-vpc-attribute.fln\ 64 describe-vpc-attribute.fln\
@@ -74,2 +75,3 @@ FLNFILES=\
74 modify-subnet-attribute.fln\ 75 modify-subnet-attribute.fln\
76 modify-volume.fln\
75 modify-vpc-attribute.fln\ 77 modify-vpc-attribute.fln\
diff --git a/etc/describe-volumes-modifications.fln b/etc/describe-volumes-modifications.fln
new file mode 100644
index 0000000..f752490
--- /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
--- /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
@@ -85,3 +85,3 @@ struct ec2_param {
85 85
86#define EC2_API_VERSION "2014-06-15" 86#define EC2_API_VERSION "2016-11-15"
87 87
diff --git a/src/Makefile.am b/src/Makefile.am
index e78461c..c4fc211 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,2 +23,3 @@ eclat_SOURCES=\
23 atvol.c\ 23 atvol.c\
24 chvol.c\
24 cmdline.h\ 25 cmdline.h\
@@ -41,2 +42,3 @@ eclat_SOURCES=\
41 lsaattr.c\ 42 lsaattr.c\
43 lschvol.c\
42 lsiattr.c\ 44 lsiattr.c\
diff --git a/src/chvol.c b/src/chvol.c
new file mode 100644
index 0000000..f1246c9
--- /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}