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/asscaddr.c | |
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/asscaddr.c')
-rw-r--r-- | src/asscaddr.c | 62 |
1 files changed, 62 insertions, 0 deletions
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); +} |