aboutsummaryrefslogtreecommitdiff
path: root/src/igw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/igw.c')
-rw-r--r--src/igw.c133
1 files changed, 133 insertions, 0 deletions
diff --git a/src/igw.c b/src/igw.c
new file mode 100644
index 0000000..a0f6f48
--- /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}

Return to:

Send suggestions and report system problems to the System administrator.