summaryrefslogtreecommitdiffabout
path: root/src
Unidiff
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/Makefile.am8
-rw-r--r--src/eclat.c20
-rw-r--r--src/eclat.h19
-rw-r--r--src/igw.c133
-rw-r--r--src/lsinst.c1
-rw-r--r--src/lsreg.c6
-rw-r--r--src/lstag-cl.opt9
-rw-r--r--src/lsvpc.c59
-rw-r--r--src/mksg-cl.opt2
-rw-r--r--src/mktags-cl.opt10
-rw-r--r--src/mkvpc-cl.opt36
-rw-r--r--src/mkvpc.c38
-rw-r--r--src/rmvpc.c40
-rw-r--r--src/util.c2
-rw-r--r--src/vpcattr.c96
15 files changed, 473 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7ec7c66..d46ad42 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,7 @@ eclat_SOURCES=\
34 eclat.h\ 34 eclat.h\
35 genericcl.c\ 35 genericcl.c\
36 getconout.c\ 36 getconout.c\
37 igw.c\
37 io.c\ 38 io.c\
38 lsaddr.c\ 39 lsaddr.c\
39 lsattr.c\ 40 lsattr.c\
@@ -48,6 +49,7 @@ eclat_SOURCES=\
48 lssnap.c\ 49 lssnap.c\
49 lstag.c\ 50 lstag.c\
50 lsvol.c\ 51 lsvol.c\
52 lsvpc.c\
51 lszon.c\ 53 lszon.c\
52 mkimg.c\ 54 mkimg.c\
53 mkinst.c\ 55 mkinst.c\
@@ -55,16 +57,19 @@ eclat_SOURCES=\
55 mksnap.c\ 57 mksnap.c\
56 mktags.c\ 58 mktags.c\
57 mkvol.c\ 59 mkvol.c\
60 mkvpc.c\
58 rmaddr.c\ 61 rmaddr.c\
59 rmsg.c\ 62 rmsg.c\
60 rmsnap.c\ 63 rmsnap.c\
61 rmvol.c\ 64 rmvol.c\
65 rmvpc.c\
62 setiattr.c\ 66 setiattr.c\
63 sg.c\ 67 sg.c\
64 sg.h\ 68 sg.h\
65 setaattr.c\ 69 setaattr.c\
66 startstop.c\ 70 startstop.c\
67 util.c 71 util.c\
72 vpcattr.c
68 73
69ispeek_SOURCES = \ 74ispeek_SOURCES = \
70 ispeek.c\ 75 ispeek.c\
@@ -98,6 +103,7 @@ OPTFILES=\
98 mksg-cl.opt\ 103 mksg-cl.opt\
99 mktags-cl.opt\ 104 mktags-cl.opt\
100 mkvol-cl.opt\ 105 mkvol-cl.opt\
106 mkvpc-cl.opt\
101 rmaddr-cl.opt\ 107 rmaddr-cl.opt\
102 rmsg-cl.opt\ 108 rmsg-cl.opt\
103 sg-cl.opt\ 109 sg-cl.opt\
diff --git a/src/eclat.c b/src/eclat.c
index 69efa8e..faba64a 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -164,6 +164,26 @@ struct eclat_command cmdtab[] = {
164 eclat_describe_image_attribute }, 164 eclat_describe_image_attribute },
165 { "setaattr", "modify-image-attribute", "ModifyImageAttribute", 165 { "setaattr", "modify-image-attribute", "ModifyImageAttribute",
166 eclat_modify_image_attribute, CMD_MOD }, 166 eclat_modify_image_attribute, CMD_MOD },
167 { "lsvpc", "describe-vpcs", "DescribeVpcs",
168 eclat_describe_vpcs },
169 { "lsvpcattr", "describe-vpc-attribute", "DescribeVpcAttribute",
170 eclat_describe_vpc_attribute },
171 { "mkvpc", "create-vpc", "CreateVpc",
172 eclat_create_vpc, CMD_MOD },
173 { "setvpcattr", "modify-vpc-attribute", "ModifyVpcAttribute",
174 eclat_modify_vpc_attribute, CMD_MOD },
175 { "rmvpc", "delete-vpc", "DeleteVpc",
176 eclat_delete_vpc, CMD_MOD|CMD_DESTR },
177 { "lsigw", "describe-internet-gateways", "DescribeInternetGateways",
178 eclat_describe_internet_gateways },
179 { "mkigw", "create-internet-gateway", "CreateInternetGateway",
180 eclat_create_internet_gateway, CMD_MOD },
181 { "rmigw", "delete-internet-gateway", "DeleteInternetGateway",
182 eclat_delete_internet_gateway, CMD_MOD|CMD_DESTR },
183 { "atigw", "attach-internet-gateway", "AttachInternetGateway",
184 eclat_attach_internet_gateway, CMD_MOD },
185 { "deigw", "detach-internet-gateway", "DetachInternetGateway",
186 eclat_detach_internet_gateway, CMD_MOD|CMD_DESTR },
167}; 187};
168size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]); 188size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]);
169 189
diff --git a/src/eclat.h b/src/eclat.h
index 604ffdc..6897c15 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -163,6 +163,22 @@ int eclat_copy_image(eclat_command_env_t *env, int argc, char **argv);
163int eclat_copy_snapshot(eclat_command_env_t *env, int argc, char **argv); 163int eclat_copy_snapshot(eclat_command_env_t *env, int argc, char **argv);
164int eclat_sg(eclat_command_env_t *env, int argc, char **argv); 164int eclat_sg(eclat_command_env_t *env, int argc, char **argv);
165 165
166int eclat_describe_vpcs(eclat_command_env_t *env, int argc, char **argv);
167int eclat_describe_vpc_attribute(eclat_command_env_t *env, int argc, char **argv);
168int eclat_modify_vpc_attribute(eclat_command_env_t *env, int argc, char **argv);
169int eclat_delete_vpc(eclat_command_env_t *env, int argc, char **argv);
170
171int eclat_create_internet_gateway(eclat_command_env_t *env,
172 int argc, char **argv);
173int eclat_delete_internet_gateway(eclat_command_env_t *env,
174 int argc, char **argv);
175int eclat_describe_internet_gateways(eclat_command_env_t *env,
176 int argc, char **argv);
177int eclat_attach_internet_gateway(eclat_command_env_t *env,
178 int argc, char **argv);
179int eclat_detach_internet_gateway(eclat_command_env_t *env,
180 int argc, char **argv);
181
166int eclat_create_security_group(eclat_command_env_t *env, 182int eclat_create_security_group(eclat_command_env_t *env,
167 int argc, char **argv); 183 int argc, char **argv);
168int eclat_delete_security_group(eclat_command_env_t *env, 184int eclat_delete_security_group(eclat_command_env_t *env,
@@ -174,6 +190,7 @@ int eclat_modify_image_attribute(eclat_command_env_t *env,
174 int argc, char **argv); 190 int argc, char **argv);
175 191
176int eclat_lsattr(eclat_command_env_t *env, int argc, char **argv); 192int eclat_lsattr(eclat_command_env_t *env, int argc, char **argv);
193int eclat_create_vpc(eclat_command_env_t *env, int argc, char **argv);
177 194
178char *region_to_endpoint(const char *region); 195char *region_to_endpoint(const char *region);
179 196
@@ -228,6 +245,8 @@ int get_scr_cols(void);
228#define MAP_VOLUME "VolumeId" 245#define MAP_VOLUME "VolumeId"
229#define MAP_AZ "AZ" 246#define MAP_AZ "AZ"
230#define MAP_REG "reg" 247#define MAP_REG "reg"
248#define MAP_VPC "VpcId"
249#define MAP_IGW "InternetGatewayId"
231 250
232void translate_ids(int argc, char **argv, const char *map); 251void translate_ids(int argc, char **argv, const char *map);
233void translate_resource_ids(int argc, char **argv); 252void translate_resource_ids(int argc, char **argv);
diff --git a/src/igw.c b/src/igw.c
new file mode 100644
index 0000000..a0f6f48
--- a/dev/null
+++ b/src/igw.c
@@ -0,0 +1,133 @@
1/* This file is part of Eclat.
2 Copyright (C) 2012-2015 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
19int
20eclat_create_internet_gateway(eclat_command_env_t *env, int argc, char **argv)
21{
22 int i;
23 struct ec2_request *q = env->request;
24 generic_proginfo->args_doc = NULL;
25 generic_parse_options(env->cmd,
26 "create internet gateway",
27 argc, argv, &i);
28 if (argc > i)
29 die(EX_USAGE, "wrong number of arguments");
30 return 0;
31}
32
33int
34eclat_delete_internet_gateway(eclat_command_env_t *env, int argc, char **argv)
35{
36 int i;
37 struct ec2_request *q = env->request;
38
39 generic_proginfo->args_doc = "IGW-ID";
40 generic_parse_options(env->cmd,
41 "delete internet gateway",
42 argc, argv, &i);
43 argv += i;
44 argc -= i;
45
46 if (argc != 1)
47 die(EX_USAGE, "wrong number of arguments");
48
49 translate_ids(1, argv, MAP_IGW);
50 eclat_request_add_param(q, "InternetGatewayId", argv[0]);
51
52 return 0;
53}
54
55static struct filter_descr filters[] = {
56 { "attachment.state", FILTER_STRING },
57 { "attachment.vpc-id", FILTER_STRING },
58 { "internet-gateway-id", FILTER_STRING },
59 { "tag-key", FILTER_STRING },
60 { "tag-value", FILTER_STRING },
61 { "tag:<KEY>", FILTER_STRING },
62 { NULL }
63 };
64
65int
66eclat_describe_internet_gateways(eclat_command_env_t *env,
67 int argc, char **argv)
68{
69 int i;
70
71 available_filters = filters;
72 generic_proginfo->print_help_hook = list_filters;
73 generic_proginfo->args_doc = "[FILTER...] [ID...]";
74 generic_parse_options(env->cmd,
75 "describe internet gateways",
76 argc, argv, &i);
77 argv += i;
78 argc -= i;
79 translate_ids(argc, argv, MAP_IGW);
80
81 describe_request_create(env, argc, argv, "InternetGatewayId");
82 return 0;
83}
84
85int
86eclat_attach_internet_gateway(eclat_command_env_t *env,
87 int argc, char **argv)
88{
89 int i;
90 struct ec2_request *q = env->request;
91
92 generic_proginfo->args_doc = "IGW-ID VPC-ID";
93 generic_parse_options(env->cmd,
94 "attach internet gateway to a VPC",
95 argc, argv, &i);
96 argv += i;
97 argc -= i;
98 if (argc != 2)
99 die(EX_USAGE, "wrong number of arguments");
100
101 translate_ids(1, argv, MAP_IGW);
102 translate_ids(1, argv+1, MAP_VPC);
103
104 eclat_request_add_param(q, "InternetGatewayId", argv[0]);
105 eclat_request_add_param(q, "VpcId", argv[1]);
106
107 return 0;
108}
109
110int
111eclat_detach_internet_gateway(eclat_command_env_t *env,
112 int argc, char **argv)
113{
114 int i;
115 struct ec2_request *q = env->request;
116
117 generic_proginfo->args_doc = "IGW-ID VPC-ID";
118 generic_parse_options(env->cmd,
119 "detach internet gateway from VPC",
120 argc, argv, &i);
121 argv += i;
122 argc -= i;
123 if (argc != 2)
124 die(EX_USAGE, "wrong number of arguments");
125
126 translate_ids(1, argv, MAP_IGW);
127 translate_ids(1, argv+1, MAP_VPC);
128
129 eclat_request_add_param(q, "InternetGatewayId", argv[0]);
130 eclat_request_add_param(q, "VpcId", argv[1]);
131
132 return 0;
133 }
diff --git a/src/lsinst.c b/src/lsinst.c
index 7c65495..79cc4ec 100644
--- a/src/lsinst.c
+++ b/src/lsinst.c
@@ -132,6 +132,7 @@ parse_options(struct eclat_command const *cmd, int argc, char *argv[],
132 132
133 available_filters = filters; 133 available_filters = filters;
134 generic_proginfo->print_help_hook = list_filters; 134 generic_proginfo->print_help_hook = list_filters;
135 generic_proginfo->args_doc = _("[FILTER...] [INST-ID...]");
135 return generic_parse_options(cmd, 136 return generic_parse_options(cmd,
136 "List instances", 137 "List instances",
137 argc, argv, index); 138 argc, argv, index);
diff --git a/src/lsreg.c b/src/lsreg.c
index 11c8203..78d3862 100644
--- a/src/lsreg.c
+++ b/src/lsreg.c
@@ -29,9 +29,9 @@ parse_options(struct eclat_command const *cmd,
29 available_filters = filters; 29 available_filters = filters;
30 generic_proginfo->print_help_hook = list_filters; 30 generic_proginfo->print_help_hook = list_filters;
31 generic_proginfo->args_doc = "[REGION [REGION...]]"; 31 generic_proginfo->args_doc = "[REGION [REGION...]]";
32 return generic_parse_options(cmd, 32 generic_parse_options(cmd,
33 "List available regions", 33 "List available regions",
34 argc, argv, index); 34 argc, argv, index);
35} 35}
36 36
37int 37int
diff --git a/src/lstag-cl.opt b/src/lstag-cl.opt
index 1c0c1af..15cd6f3 100644
--- a/src/lstag-cl.opt
+++ b/src/lstag-cl.opt
@@ -76,6 +76,15 @@ BEGIN
76 grecs_list_append(reslist, res); 76 grecs_list_append(reslist, res);
77END 77END
78 78
79OPTION(internet-gateway,g,[<ID>],
80 [<internet gateway ID>])
81BEGIN
82 struct resource *res = grecs_malloc(sizeof(*res));
83 res->map = MAP_IGW;
84 res->resid = optarg;
85 grecs_list_append(reslist, res);
86END
87
79ECLAT_CL_END 88ECLAT_CL_END
80 89
81ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[< 90ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[<
diff --git a/src/lsvpc.c b/src/lsvpc.c
new file mode 100644
index 0000000..edd8a13
--- a/dev/null
+++ b/src/lsvpc.c
@@ -0,0 +1,59 @@
1/* This file is part of Eclat.
2 Copyright (C) 2015 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 void
20parse_options(struct eclat_command const *cmd, int argc, char *argv[],
21 int *index)
22{
23 static char *state_enum[] = { "pending", "available", NULL };
24 static struct filter_descr filters[] = {
25 { "cidr", FILTER_STRING }, //FIXME: FILTER_CIDR
26 { "dhcp-options-id", FILTER_STRING },
27 { "isDefault", FILTER_BOOL },
28 { "state", FILTER_ENUM, state_enum },
29 { "tag-key", FILTER_STRING },
30 { "tag-value", FILTER_STRING },
31 { "tag:<KEY>", FILTER_STRING },
32 { "vpc-id", FILTER_STRING },
33 { NULL }
34 };
35
36 available_filters = filters;
37 generic_proginfo->print_help_hook = list_filters;
38 generic_proginfo->args_doc = _("[FILTER...] [VPC-ID...]");
39 return generic_parse_options(cmd,
40 "List VPCs",
41 argc, argv, index);
42}
43
44int
45eclat_describe_vpcs(eclat_command_env_t *env, int argc, char **argv)
46{
47 int i;
48
49 parse_options(env->cmd, argc, argv, &i);
50 argv += i;
51 argc -= i;
52 translate_ids(argc, argv, MAP_VPC);
53
54 describe_request_create(env, argc, argv, "VpcId");
55 return 0;
56}
57
58
59
diff --git a/src/mksg-cl.opt b/src/mksg-cl.opt
index 474b2ae..6b09ca6 100644
--- a/src/mksg-cl.opt
+++ b/src/mksg-cl.opt
@@ -21,7 +21,7 @@ ECLAT_CL_BEGIN([<create EC2 security group>],
21 21
22OPTION(vpc-id,i,[<ID>], 22OPTION(vpc-id,i,[<ID>],
23 [<VPC ID>]) 23 [<VPC ID>])
24BEGINb 24BEGIN
25 vpcid = optarg; 25 vpcid = optarg;
26END 26END
27 27
diff --git a/src/mktags-cl.opt b/src/mktags-cl.opt
index 8cb0033..510835b 100644
--- a/src/mktags-cl.opt
+++ b/src/mktags-cl.opt
@@ -77,6 +77,16 @@ BEGIN
77 grecs_list_append(reslist, res); 77 grecs_list_append(reslist, res);
78END 78END
79 79
80OPTION(internet-gateway,g,[<ID>],
81 [<internet gateway ID>])
82BEGIN
83 struct resource *res = grecs_malloc(sizeof(*res));
84 res->map = MAP_IGW;
85 res->resid = optarg;
86 grecs_list_append(reslist, res);
87END
88
89
80OPTION(from-file,T,[<FILE>], 90OPTION(from-file,T,[<FILE>],
81 [<read tags from FILE>]) 91 [<read tags from FILE>])
82BEGIN 92BEGIN
diff --git a/src/mkvpc-cl.opt b/src/mkvpc-cl.opt
new file mode 100644
index 0000000..03611f0
--- a/dev/null
+++ b/src/mkvpc-cl.opt
@@ -0,0 +1,36 @@
1/* This file is part of Eclat.
2 Copyright (C) 2013-2015 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
17static int vpc_dry_run;
18static char *vpc_tenancy;
19
20ECLAT_CL_BEGIN([<create VPC>],
21 [<CIDR>])
22
23OPTION(tenancy,t,
24 [<default|dedicated>],
25 [<instance tenancy>])
26BEGIN
27 vpc_tenancy = optarg;
28END
29
30ECLAT_CL_END
31
32ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[<
33{
34 GETOPT(argc, argv, *index, exit(EX_USAGE))
35}
36>])
diff --git a/src/mkvpc.c b/src/mkvpc.c
new file mode 100644
index 0000000..1c837ba
--- a/dev/null
+++ b/src/mkvpc.c
@@ -0,0 +1,38 @@
1/* This file is part of Eclat.
2 Copyright (C) 2015 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#include "mkvpc-cl.h"
19
20int
21eclat_create_vpc(eclat_command_env_t *env, int argc, char **argv)
22{
23 int i;
24 struct ec2_request *q = env->request;
25
26 parse_options(env, argc, argv, &i);
27 argc -= i;
28 argv += i;
29 if (argc != 1)
30 die(EX_USAGE, "wrong number of arguments");
31
32 if (vpc_tenancy)
33 eclat_request_add_param(q, "InstanceTenancy", "true");
34 eclat_request_add_param(q, "CidrBlock", argv[0]);
35 return 0;
36}
37
38
diff --git a/src/rmvpc.c b/src/rmvpc.c
new file mode 100644
index 0000000..d1c0026
--- a/dev/null
+++ b/src/rmvpc.c
@@ -0,0 +1,40 @@
1/* This file is part of Eclat.
2 Copyright (C) 2012-2015 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
19int
20eclat_delete_vpc(eclat_command_env_t *env, int argc, char **argv)
21{
22 int i;
23 struct ec2_request *q = env->request;
24
25 generic_proginfo->args_doc = "VPC-ID";
26 generic_parse_options(env->cmd,
27 "delete the VPC",
28 argc, argv, &i);
29 argv += i;
30 argc -= i;
31
32 if (argc != 1)
33 die(EX_USAGE, "wrong number of arguments");
34
35 translate_ids(1, argv, MAP_VPC);
36 eclat_request_add_param(q, "VpcId", argv[0]);
37
38 return 0;
39}
40
diff --git a/src/util.c b/src/util.c
index 79a78ff..7bf13ac 100644
--- a/src/util.c
+++ b/src/util.c
@@ -165,7 +165,7 @@ get_scr_cols()
165 165
166void 166void
167describe_request_update(eclat_command_env_t *env, int argc, char **argv, 167describe_request_update(eclat_command_env_t *env, int argc, char **argv,
168 const char *uparm, int n_in, int *n_out) 168 const char *uparm, int n_in, int *n_out)
169{ 169{
170 int i, j, k; 170 int i, j, k;
171 struct ec2_request *q = env->request; 171 struct ec2_request *q = env->request;
diff --git a/src/vpcattr.c b/src/vpcattr.c
new file mode 100644
index 0000000..1896ee1
--- a/dev/null
+++ b/src/vpcattr.c
@@ -0,0 +1,96 @@
1/* This file is part of Eclat.
2 Copyright (C) 2015 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
19int
20eclat_describe_vpc_attribute(eclat_command_env_t *env, int argc, char **argv)
21{
22 int i;
23 struct ec2_request *q = env->request;
24 const char *attrname;
25 static char *attrs[] = {
26 "enableDnsSupport",
27 "enableDnsHostnames",
28 NULL
29 };
30
31 generic_proginfo->args_doc = "VPC-ID [ATTR]";
32 available_attrs = attrs;
33 generic_proginfo->print_help_hook = list_attrs;
34 generic_parse_options(env->cmd,
35 "describe VPC attributes",
36 argc, argv, &i);
37 argv += i;
38 argc -= i;
39
40 switch (argc) {
41 default:
42 die(EX_USAGE, "wrong number of arguments");
43 case 2:
44 attrname = canonattrname(attrs, argv[1], NULL, NULL);
45 if (!attrname)
46 die(EX_USAGE, "unrecognized attribute name");
47 break;
48 case 1:
49 attrname = attrs[0];
50 }
51
52 translate_ids(1, argv, MAP_VPC);
53 eclat_request_add_param(q, "VpcId", argv[0]);
54 if (attrname)
55 eclat_request_add_param(q, "Attribute", attrname);
56 return 0;
57}
58
59int
60eclat_modify_vpc_attribute(eclat_command_env_t *env, int argc, char **argv)
61{
62 int i;
63 struct ec2_request *q = env->request;
64 const char *attrname;
65 char *bufptr = NULL;
66 size_t bufsize = 0;
67 static char *attrs[] = {
68 "EnableDnsSupport",
69 "EnableDnsHostnames",
70 NULL
71 };
72
73
74 generic_proginfo->args_doc = "VPC-ID ATTR VALUE";
75 available_attrs = attrs;
76 generic_proginfo->print_help_hook = list_attrs;
77 generic_parse_options(env->cmd,
78 "modify VPC attribute",
79 argc, argv, &i);
80 argv += i;
81 argc -= i;
82
83 if (argc != 3)
84 die(EX_USAGE, "wrong number of arguments");
85 attrname = canonattrname(attrs, argv[1], NULL, NULL);
86 if (!attrname)
87 die(EX_USAGE, "unrecognized attribute name");
88
89 translate_ids(1, argv, MAP_VPC);
90 eclat_request_add_param(q, "VpcId", argv[0]);
91 grecs_asprintf(&bufptr, &bufsize, "%s.Value", attrname);
92 eclat_request_add_param(q, bufptr, argv[2]);
93 free(bufptr);
94 return 0;
95}
96

Return to:

Send suggestions and report system problems to the System administrator.