aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-12-19 22:54:20 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-12-19 23:03:45 +0200
commit8d43103165e7e2f16c10d0592e5a51d86dac01ed (patch)
treec479c34f16e8a1d989fb95af462e47c318565cd8
parent2a69cacdfe3f43c61c65ea4359c821236b7f141c (diff)
downloadeclat-8d43103165e7e2f16c10d0592e5a51d86dac01ed.tar.gz
eclat-8d43103165e7e2f16c10d0592e5a51d86dac01ed.tar.bz2
Implement security group creation and deletion.
* doc/eclat-lssg.1: New file. * doc/eclat-sg.1: New file. * doc/Makefile.inc: Add new files. * etc/create-security-group.fln: New file. * etc/delete-security-group.fln: New file. * etc/Makefile.am: Add new files. * src/mksg-cl.opt: New file. * src/mksg.c: New file. * src/rmsg-cl.opt: New file. * src/rmsg.c: New file. * src/sg.h: New file. * src/Makefile.am: Add new files. * src/eclat.c (cmdtab): New commands "mksg" and "rmsg". * src/eclat.h (eclat_create_security_group) (eclat_delete_security_group): New protos. * src/lssg.c: Include sg.h. Use groupkw instead of the static rt[], which is removed. * src/sg-cl.opt: Use groupkw * src/sg.c (groupkw): New global. * TODO: Update.
-rw-r--r--TODO4
-rw-r--r--doc/Makefile.inc38
-rw-r--r--doc/eclat-lssg.18
-rw-r--r--doc/eclat-sg.16
-rw-r--r--etc/Makefile.am2
-rw-r--r--etc/create-security-group.fln23
-rw-r--r--etc/delete-security-group.fln22
-rw-r--r--src/Makefile.am5
-rw-r--r--src/eclat.c4
-rw-r--r--src/eclat.h6
-rw-r--r--src/lssg.c12
-rw-r--r--src/mksg-cl.opt34
-rw-r--r--src/mksg.c38
-rw-r--r--src/rmsg-cl.opt35
-rw-r--r--src/rmsg.c36
-rw-r--r--src/sg-cl.opt10
-rw-r--r--src/sg.c11
-rw-r--r--src/sg.h9
18 files changed, 256 insertions, 47 deletions
diff --git a/TODO b/TODO
index c8182b6..bd7ec6a 100644
--- a/TODO
+++ b/TODO
@@ -38,13 +38,13 @@ CreateNetworkAcl - [ ] [ ]
CreateNetworkAclEntry - [ ] [ ]
CreateNetworkInterface - [ ] [ ]
CreatePlacementGroup - [ ] [ ]
CreateReservedInstancesListing - [ ] [ ]
CreateRoute - [ ] [ ]
CreateRouteTable - [ ] [ ]
-CreateSecurityGroup - [ ] [ ]
+CreateSecurityGroup mksg [X] [X]
CreateSnapshot mksnap [X] [X]
CreateSpotDatafeedSubscription - [ ] [ ]
CreateSubnet - [ ] [ ]
CreateTags mktag [X] [X]
CreateVolume mkvol [X] [X]
CreateVpc - [ ] [ ]
@@ -58,13 +58,13 @@ DeleteKeyPair - [ ] [ ]
DeleteNetworkAcl - [ ] [ ]
DeleteNetworkAclEntry - [ ] [ ]
DeleteNetworkInterface - [ ] [ ]
DeletePlacementGroup - [ ] [ ]
DeleteRoute - [ ] [ ]
DeleteRouteTable - [ ] [ ]
-DeleteSecurityGroup - [ ] [ ]
+DeleteSecurityGroup rmsg [X] [X]
DeleteSnapshot rmsnap [X] [X]
DeleteSpotDatafeedSubscription - [ ] [ ]
DeleteSubnet - [ ] [ ]
DeleteTags rmtag [X] [X]
DeleteVolume rmvol [X] [X]
DeleteVpc - [ ] [ ]
diff --git a/doc/Makefile.inc b/doc/Makefile.inc
index 4c10f82..0fa843f 100644
--- a/doc/Makefile.inc
+++ b/doc/Makefile.inc
@@ -17,45 +17,47 @@
# This file contains the lists of manual pages to be installed. They
# are kept separately so they may be included from another makefiles.
# Currently they are used in the Makefile.am and in the webdoc Makefile.
MANPAGES1=\
eclat.1\
- eclat-mkaddr.1\
eclat-assocaddr.1\
eclat-atvol.1\
eclat-clrsattr.1\
+ eclat-conmesg.1\
eclat-cpimg.1\
eclat-cpsnap.1\
- eclat-mkinst.1\
- eclat-mkimg.1\
- eclat-mksnap.1\
- eclat-mktag.1\
- eclat-mkvol.1\
- eclat-rmsnap.1\
- eclat-rmtag.1\
eclat-deimg.1\
+ eclat-devol.1\
+ eclat-disasaddr.1\
eclat-lsaddr.1\
- eclat-lszon.1\
- eclat-lsimg.1\
eclat-lsiattr.1\
- eclat-lsistat.1\
+ eclat-lsimg.1\
eclat-lsinst.1\
+ eclat-lsistat.1\
eclat-lsreg.1\
- eclat-lssg.1\
eclat-lssattr.1\
+ eclat-lssg.1\
eclat-lssnap.1\
eclat-lstag.1\
eclat-lsvol.1\
- eclat-devol.1\
- eclat-disasaddr.1\
+ eclat-lszon.1\
+ eclat-mkaddr.1\
+ eclat-mkimg.1\
+ eclat-mkinst.1\
+ eclat-mksg.1\
+ eclat-mksnap.1\
+ eclat-mktag.1\
+ eclat-mkvol.1\
+ eclat-reboot.1\
+ eclat-rmaddr.1\
+ eclat-rmsg.1\
+ eclat-rmsnap.1\
+ eclat-rmtag.1\
eclat-setiattr.1\
eclat-setsattr.1\
eclat-sg.1\
- eclat-conmesg.1\
eclat-start.1\
- eclat-stop.1\
- eclat-reboot.1\
- eclat-rmaddr.1
+ eclat-stop.1
MANPAGES5=\
eclat.conf.5
diff --git a/doc/eclat-lssg.1 b/doc/eclat-lssg.1
index 69c31c9..50ce425 100644
--- a/doc/eclat-lssg.1
+++ b/doc/eclat-lssg.1
@@ -10,19 +10,19 @@
.\" 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 LSSEC 1 "December 16, 2013" "ECLAT" "Eclat User Reference"
+.TH LSSEC 1 "December 19, 2013" "ECLAT" "Eclat User Reference"
.SH NAME
eclat lssg, describe\-security\-groups \- return information about security groups
.SH SYNOPSIS
\fBeclat lssg\fR [\fB\-n\fR] [\fB\-\-name\fR]\
[\fIFILTER\fR...] [\fIID\fR]
-
+.br
\fBeclat lssg\fR \fB\-\-help\fR
.SH DESCRIPTION
This command returns information about security groups. By default,
all security groups pertaining to your account will be described.
Particular groups can be selected by specifying their IDs (or names,
if the \fB\-n\fR (\fB\-\-name\fR) option is used) in the command
@@ -106,13 +106,15 @@ VPC ID:
Incoming:
user 111122223333, group sg\-99gh4012 ("Group B") 6000\-7000
Outgoing:
.EE
.SH "SEE ALSO"
.BR eclat (1),
-.BR eclat\-sg (1).
+.BR eclat\-sg (1),
+.BR eclat\-mksg (1),
+.BR eclat\-rmsg (1).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <bug\-eclat@gnu.org.ua>.
.SH COPYRIGHT
Copyright \(co 2012, 2013 Sergey Poznyakoff
diff --git a/doc/eclat-sg.1 b/doc/eclat-sg.1
index 6e9e708..7dcac0f 100644
--- a/doc/eclat-sg.1
+++ b/doc/eclat-sg.1
@@ -10,13 +10,13 @@
.\" 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 SG 1 "December 17, 2013" "ECLAT" "Eclat User Reference"
+.TH SG 1 "December 19, 2013" "ECLAT" "Eclat User Reference"
.SH NAME
eclat sg \- manipulate security groups
.SH SYNOPSIS
\fBeclat sg\fR \fB\-A\fR|\fB\-D\fR|\fB\-\-add\fR|\fB\-\-delete\fR [\fB\-Nn\fR] [\fB\-G\fR \fINAME\fR] [\fB\-P\fR \fIPORT\fR[\fB\-\fIPORT\fR]]
[\fB\-g\fR \fIID\fR] [\fB\-p\fR \fIPROTO\fR] [\fB\-s\fR \fICIDR\fR] [\fB\-u\fR \fIUSER\fR] [\fB\-\-group\-id\fR=\fIID\fR]
[\fB\-\-group\-name\fR=\fINAME\fR] [\fB\-\-name\fR] [\fB\-\-next\fR, \fB\-\-new\fR]
@@ -127,13 +127,15 @@ Begins next rule.
Give a terse help summary.
.TP
.BR \-\-usage
List command line syntax and available options.
.SH "SEE ALSO"
.BR eclat (1),
-.BR eclat\-lssg (1).
+.BR eclat\-lssg (1),
+.BR eclat\-mksg (1),
+.BR eclat\-rmsg (1).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <bug\-eclat@gnu.org.ua>.
.SH COPYRIGHT
Copyright \(co 2012, 2013 Sergey Poznyakoff
diff --git a/etc/Makefile.am b/etc/Makefile.am
index caa780c..c62369b 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -20,15 +20,17 @@ FLNFILES=\
allocate-address.fln\
attach-volume.fln\
associate-address.fln\
copy-image.fln\
copy-snapshot.fln\
create-image.fln\
+ create-security-group.fln\
create-snapshot.fln\
create-tags.fln\
create-volume.fln\
+ delete-security-group.fln\
delete-snapshot.fln\
delete-tags.fln\
delete-volume.fln\
deregister-image.fln\
describe-addresses.fln\
describe-availability-zones.fln\
diff --git a/etc/create-security-group.fln b/etc/create-security-group.fln
new file mode 100644
index 0000000..06d021d
--- /dev/null
+++ b/etc/create-security-group.fln
@@ -0,0 +1,23 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012, 2013 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 (.CreateSecurityGroupResponse.return) {
+ if (!.CreateSecurityGroupResponse.return[true]) {
+ print("Return: ",.CreateSecurityGroupResponse.return,"\n");
+ exit(1);
+ } else
+ print(.CreateSecurityGroupResponse.groupId,"\n");
+}
diff --git a/etc/delete-security-group.fln b/etc/delete-security-group.fln
new file mode 100644
index 0000000..ca1c611
--- /dev/null
+++ b/etc/delete-security-group.fln
@@ -0,0 +1,22 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012, 2013 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 (.DeleteSecurityGroupResponse.return) {
+ if (!.DeleteSecurityGroupResponse.return[true]) {
+ print("Return: ",.DeleteSecurityGroupResponse.return,"\n");
+ exit(1);
+ }
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 6654f5c..9bc68d0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,20 +47,23 @@ eclat_SOURCES=\
lssnap.c\
lstag.c\
lsvol.c\
lszon.c\
mkimg.c\
mkinst.c\
+ mksg.c\
mksnap.c\
mktags.c\
mkvol.c\
rmaddr.c\
+ rmsg.c\
rmsnap.c\
rmvol.c\
setiattr.c\
sg.c\
+ sg.h\
startstop.c\
util.c
LDADD=../lib/libeclat.a @LIBOBJS@ ../grecs/src/libgrecs.a $(CURL_LIBS) @MAPLIBS@
AM_CPPFLAGS = \
-I$(top_srcdir)/grecs/src/ -I$(top_srcdir)/lib $(CURL_CFLAGS)\
@@ -83,15 +86,17 @@ OPTFILES=\
lsistat-cl.opt\
lssg-cl.opt\
lssnap-cl.opt\
lstag-cl.opt\
mkimg-cl.opt\
mkinst-cl.opt\
+ mksg-cl.opt\
mktags-cl.opt\
mkvol-cl.opt\
rmaddr-cl.opt\
+ rmsg-cl.opt\
sg-cl.opt
eclat_SOURCES += $(OPTFILES:.opt=.h)
BUILT_SOURCES=\
cmdline.h\
diff --git a/src/eclat.c b/src/eclat.c
index 0558fcd..a046eb9 100644
--- a/src/eclat.c
+++ b/src/eclat.c
@@ -147,12 +147,16 @@ struct eclat_command cmdtab[] = {
eclat_copy_image },
{ "cpsnap", "copy-snapshot", "CopySnapshot",
eclat_copy_snapshot },
{ "lsattr", NULL, NULL,
eclat_lsattr, CMD_NOQRY },
{ "sg", NULL, NULL, eclat_sg },
+ { "mksg", "create-security-group", "CreateSecurityGroup",
+ eclat_create_security_group },
+ { "rmsg", "delete-security-group", "DeleteSecurityGroup",
+ eclat_delete_security_group }
};
size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]);
static int
cmdcmp(const void *a, const void *b)
{
diff --git a/src/eclat.h b/src/eclat.h
index 03a0bdf..903e49e 100644
--- a/src/eclat.h
+++ b/src/eclat.h
@@ -141,12 +141,17 @@ int eclat_describe_images(eclat_command_env_t *env, int argc, char **argv);
int eclat_create_image(eclat_command_env_t *env, int argc, char **argv);
int eclat_deregister_image(eclat_command_env_t *env, int argc, char **argv);
int eclat_copy_image(eclat_command_env_t *env, int argc, char **argv);
int eclat_copy_snapshot(eclat_command_env_t *env, int argc, char **argv);
int eclat_sg(eclat_command_env_t *env, int argc, char **argv);
+int eclat_create_security_group(eclat_command_env_t *env,
+ int argc, char **argv);
+int eclat_delete_security_group(eclat_command_env_t *env,
+ int argc, char **argv);
+
int eclat_lsattr(eclat_command_env_t *env, int argc, char **argv);
char *region_to_endpoint(const char *region);
void define_format(const char *name, const char *format, grecs_locus_t *locus);
void set_command_format(const char *name, const char *format,
@@ -209,6 +214,7 @@ void generic_parse_options(struct eclat_command const *command,
extern struct grecs_proginfo *generic_proginfo;
void set_command_confirmation(const char *name, enum eclat_confirm_mode cfmode,
grecs_locus_t *locus);
extern struct eclat_map_drv eclat_map_drv_ec2;
+
diff --git a/src/lssg.c b/src/lssg.c
index 039feb1..a4eef38 100644
--- a/src/lssg.c
+++ b/src/lssg.c
@@ -14,28 +14,22 @@
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"
static int name_option;
#include "lssg-cl.h"
+#include "sg.h"
int
eclat_describe_security_groups(eclat_command_env_t *env, int argc, char **argv)
{
int i;
- static struct {
- char *resid;
- char *map;
- } rt[] = {
- { "GroupId", MAP_GROUPID },
- { "GroupName", MAP_GROUPNAME }
- };
parse_options(env, argc, argv, &i);
argv += i;
argc -= i;
- translate_ids(argc, argv, rt[name_option].map);
+ translate_ids(argc, argv, groupkw[name_option].map);
- describe_query_create(env, argc, argv, rt[name_option].resid);
+ describe_query_create(env, argc, argv, groupkw[name_option].resid);
return 0;
}
diff --git a/src/mksg-cl.opt b/src/mksg-cl.opt
new file mode 100644
index 0000000..1dd10b1
--- /dev/null
+++ b/src/mksg-cl.opt
@@ -0,0 +1,34 @@
+/* This file is part of Eclat.
+ Copyright (C) 2013 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/>. */
+
+static char *vpcid;
+
+ECLAT_CL_BEGIN([<create EC2 security group>],
+ [<GROUPNAME DESCR>])
+
+OPTION(vpc-id,i,[<ID>],
+ [<VPC ID>])
+BEGINb
+ vpcid = optarg;
+END
+
+ECLAT_CL_END
+
+ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[<
+{
+ GETOPT(argc, argv, *index, exit(EX_USAGE))
+}
+>])
diff --git a/src/mksg.c b/src/mksg.c
new file mode 100644
index 0000000..dcffdd9
--- /dev/null
+++ b/src/mksg.c
@@ -0,0 +1,38 @@
+/* This file is part of Eclat.
+ Copyright (C) 2013 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"
+#include "mksg-cl.h"
+
+int
+eclat_create_security_group(eclat_command_env_t *env, int argc, char **argv)
+{
+ int i;
+ struct ec2_query *q = env->query;
+
+ parse_options(env, argc, argv, &i);
+ argc -= i;
+ argv += i;
+ if (argc != 2)
+ die(EX_USAGE, "wrong number of arguments");
+
+ eclat_query_add_param(q, "GroupName", argv[0]);
+ eclat_query_add_param(q, "GroupDescription", argv[1]);
+ if (vpcid)
+ eclat_query_add_param(q, "VpcId", vpcid);
+ return 0;
+}
+
diff --git a/src/rmsg-cl.opt b/src/rmsg-cl.opt
new file mode 100644
index 0000000..2801b56
--- /dev/null
+++ b/src/rmsg-cl.opt
@@ -0,0 +1,35 @@
+/* This file is part of Eclat.
+ Copyright (C) 2013 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 "sg.h"
+static int group_n = GROUP_ID;
+
+ECLAT_CL_BEGIN([<delete group>],
+ [<GROUPARG>])
+OPTION(name,n,,
+ [<the GROUPARG argument is a group name>])
+BEGIN
+ group_n = GROUP_NAME;
+END
+
+ECLAT_CL_END
+
+ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[<
+{
+ GETOPT(argc, argv, *index, exit(EX_USAGE))
+}
+>])
+
diff --git a/src/rmsg.c b/src/rmsg.c
new file mode 100644
index 0000000..fff5902
--- /dev/null
+++ b/src/rmsg.c
@@ -0,0 +1,36 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012, 2013 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"
+#include "rmsg-cl.h"
+
+int
+eclat_delete_security_group(eclat_command_env_t *env, int argc, char **argv)
+{
+ int i;
+ struct ec2_query *q = env->query;
+
+ parse_options(env, argc, argv, &i);
+ argc -= i;
+ argv += i;
+ if (argc != 1)
+ die(EX_USAGE, "bad number of arguments");
+ translate_ids(1, &argv[0], groupkw[group_n].map);
+ eclat_query_add_param(q, groupkw[group_n].resid, argv[0]);
+ return 0;
+}
+
+
diff --git a/src/sg-cl.opt b/src/sg-cl.opt
index aa44095..433d705 100644
--- a/src/sg-cl.opt
+++ b/src/sg-cl.opt
@@ -46,26 +46,26 @@ BEGIN
END
OPTION(group-id,g,[<ID>],
[<source group ID>])
BEGIN
struct group_arg *g = grecs_malloc(sizeof(*g));
- translate_ids(1, &optarg, rt[GROUP_ID].map);
+ translate_ids(1, &optarg, groupkw[GROUP_ID].map);
g->type = GROUP_ID;
g->str = optarg;
g->usr = user;
if (!group_list)
group_list = _grecs_simple_list_create(1);
grecs_list_append(group_list, g);
END
OPTION(group-name,G,[<NAME>],
[<source group name>])
BEGIN
struct group_arg *g = grecs_malloc(sizeof(*g));
- translate_ids(1, &optarg, rt[GROUP_NAME].map);
+ translate_ids(1, &optarg, groupkw[GROUP_NAME].map);
g->type = GROUP_NAME;
g->str = optarg;
g->usr = user;
if (!group_list)
group_list = _grecs_simple_list_create(1);
grecs_list_append(group_list, g);
@@ -128,20 +128,20 @@ ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[]>],[<
from_port || to_port)
die(EX_USAGE, "conflicting options");
if (argc > 1)
die(EX_USAGE, "bad number of arguments");
} else if (argc != 1)
die(EX_USAGE, "bad number of arguments");
- translate_ids(argc, argv, rt[dest_n].map);
+ translate_ids(argc, argv, groupkw[dest_n].map);
eclat_query_add_param(env->query, "Action", command);
if (list_option)
- describe_query_create(env, argc, argv, rt[dest_n].resid);
+ describe_query_create(env, argc, argv, groupkw[dest_n].resid);
else {
if (group_list || source_list || from_port || to_port || proto)
flush_rule();
if (rule_n == 1)
die(EX_USAGE, "no rules");
- eclat_query_add_param(query, rt[dest_n].resid, argv[0]);
+ eclat_query_add_param(query, groupkw[dest_n].resid, argv[0]);
}
}>])
diff --git a/src/sg.c b/src/sg.c
index 2fc0a9b..160851c 100644
--- a/src/sg.c
+++ b/src/sg.c
@@ -14,20 +14,15 @@
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"
#include <arpa/inet.h>
#include <netdb.h>
+#include "sg.h"
-#define GROUP_ID 0
-#define GROUP_NAME 1
-
-static struct {
- char *resid;
- char *map;
-} rt[] = {
+struct groupkw groupkw[] = {
{ "GroupId", MAP_GROUPID },
{ "GroupName", MAP_GROUPNAME }
};
static struct ec2_query *query;
static char *command;
@@ -171,13 +166,13 @@ flush_rule()
for (i = 1, ep = group_list->head; ep; ep = ep->next, i++) {
struct group_arg *a = ep->data;
grecs_asprintf(&bufptr, &bufsize,
"IpPermissions.%d.Groups.%d.%s",
rule_n, i,
- rt[a->type].resid);
+ groupkw[a->type].resid);
eclat_query_add_param(query, bufptr, a->str);
if (a->usr) {
grecs_asprintf(&bufptr, &bufsize,
"IpPermissions.%d.Groups.%d.UserId",
rule_n, i);
eclat_query_add_param(query, bufptr, a->usr);
diff --git a/src/sg.h b/src/sg.h
new file mode 100644
index 0000000..a406c51
--- /dev/null
+++ b/src/sg.h
@@ -0,0 +1,9 @@
+struct groupkw {
+ char *resid;
+ char *map;
+};
+
+#define GROUP_ID 0
+#define GROUP_NAME 1
+
+extern struct groupkw groupkw[];

Return to:

Send suggestions and report system problems to the System administrator.