diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-09-28 17:17:01 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-09-28 17:17:01 +0300 |
commit | 2b6198883155009bbf22e984daff8a970d7d52d1 (patch) | |
tree | 3e4a71eb15bb75122de7c83f69b26229d1e7f442 /src | |
parent | 4d6c1e56790f61be15501977e970753a6088104f (diff) | |
download | eclat-2b6198883155009bbf22e984daff8a970d7d52d1.tar.gz eclat-2b6198883155009bbf22e984daff8a970d7d52d1.tar.bz2 |
Initial implementation of associate/dissociate address requests.
* etc/Makefile.am: Add new files.
* etc/associate-address.fln: New file.
* etc/disassociate-address.fln: New file.
* lib/forlan.c (eval_expr): Fix boolean NOT.
* src/Makefile.am: Add new files.
* src/asscaddr.c: New file.
* src/dscrtags.c (eclat_describe_tags): Remove unused variables.
* src/eclat.c (cmdtab): Register new commands.
* src/eclat.h (eclat_associate_address)
(eclat_disassociate_address): New commands.
* src/util.c: Add AWSAccessKeyId param in eclat_send_query
instead of in describe_query_create.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Include new test cases.
* tests/associate-address.at: New test case.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/asscaddr.c | 62 | ||||
-rw-r--r-- | src/dscrtags.c | 2 | ||||
-rw-r--r-- | src/eclat.c | 4 | ||||
-rw-r--r-- | src/eclat.h | 2 | ||||
-rw-r--r-- | src/util.c | 4 |
6 files changed, 71 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e2702ca..423dbd8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ bin_PROGRAMS=eclat eclat_SOURCES=\ accfile.c\ + asscaddr.c\ cmdline.h\ config.c\ dscrtags.c\ diff --git a/src/asscaddr.c b/src/asscaddr.c new file mode 100644 index 0000000..b18abc9 --- /dev/null +++ b/src/asscaddr.c @@ -0,0 +1,62 @@ +/* This file is part of Eclat. + Copyright (C) 2012 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" + +int +eclat_associate_address(CURL *curl, int argc, char **argv) +{ + int i; + struct ec2_query *q; + + generic_parse_options("eclat associate-address", + "INSTANCE IP", + argc, argv, &i); + argc -= i; + argv += i; + + if (argc != 2) + die(EX_USAGE, "wrong number of arguments to associate-address"); + + q = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/"); + eclat_query_add_param(q, "Action", "AssociateAddress"); + eclat_query_add_param(q, "InstanceId", argv[0]); + eclat_query_add_param(q, "PublicIp", argv[1]); + + return eclat_send_query(curl, q); +} + +int +eclat_disassociate_address(CURL *curl, int argc, char **argv) +{ + int i; + struct ec2_query *q; + + generic_parse_options("eclat disassociate-address", + "IP", + argc, argv, &i); + argc -= i; + argv += i; + + if (argc != 1) + die(EX_USAGE, "wrong number of arguments to disassociate-address"); + + q = eclat_query_create(use_ssl ? EC2_QF_HTTPS : 0, endpoint, "/"); + eclat_query_add_param(q, "Action", "DisassociateAddress"); + eclat_query_add_param(q, "PublicIp", argv[0]); + + return eclat_send_query(curl, q); +} diff --git a/src/dscrtags.c b/src/dscrtags.c index 0d762e7..6dc200c 100644 --- a/src/dscrtags.c +++ b/src/dscrtags.c @@ -59,8 +59,6 @@ eclat_describe_tags(CURL *curl, int argc, char **argv) { int i; struct ec2_query *q; - CURLcode res; - char *url; parse_options(argc, argv, &i); argv += i; diff --git a/src/eclat.c b/src/eclat.c index 7d37940..6caeb10 100644 --- a/src/eclat.c +++ b/src/eclat.c @@ -226,6 +226,10 @@ struct command cmdtab[] = { eclat_describe_instance_status }, { "describe-instances", "DescribeInstances", eclat_describe_instances }, + { "associate-address", "AssociateAddress", + eclat_associate_address }, + { "disassociate-address", "DisassociateAddress", + eclat_disassociate_address }, }; size_t cmdcnt = sizeof(cmdtab) / sizeof(cmdtab[0]); diff --git a/src/eclat.h b/src/eclat.h index acea219..fd3dd60 100644 --- a/src/eclat.h +++ b/src/eclat.h @@ -62,6 +62,8 @@ int eclat_stop_instance(CURL *curl, int argc, char **argv); int eclat_describe_tags(CURL *curl, int argc, char **argv); int eclat_describe_instance_status(CURL *curl, int argc, char **argv); int eclat_describe_instances(CURL *curl, int argc, char **argv); +int eclat_associate_address(CURL *curl, int argc, char **argv); +int eclat_disassociate_address(CURL *curl, int argc, char **argv); char *region_to_endpoint(const char *region); @@ -83,8 +83,6 @@ describe_query_create(CURL *curl, const char *verb, int argc, char **argv, wordsplit_free(&ws); free(bufptr); - eclat_query_add_param(q, "AWSAccessKeyId", access_key); - return q; } @@ -95,6 +93,8 @@ eclat_send_query(CURL *curl, struct ec2_query *q) CURLcode res; int rc = 0; + eclat_query_add_param(q, "AWSAccessKeyId", access_key); + eclat_query_signature(q, secret_key); url = eclat_query_to_url(q, NULL); |