diff options
-rw-r--r-- | TODO | 18 | ||||
-rw-r--r-- | doc/Makefile.inc | 1 | ||||
-rw-r--r-- | etc/Makefile.am | 2 | ||||
-rw-r--r-- | etc/describe-vpc-attribute.fln | 20 | ||||
-rw-r--r-- | etc/describe-vpcs.fln | 22 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/eclat.c | 20 | ||||
-rw-r--r-- | src/eclat.h | 19 | ||||
-rw-r--r-- | src/igw.c | 133 | ||||
-rw-r--r-- | src/lsinst.c | 1 | ||||
-rw-r--r-- | src/lsreg.c | 2 | ||||
-rw-r--r-- | src/lstag-cl.opt | 9 | ||||
-rw-r--r-- | src/lsvpc.c | 59 | ||||
-rw-r--r-- | src/mksg-cl.opt | 2 | ||||
-rw-r--r-- | src/mktags-cl.opt | 10 | ||||
-rw-r--r-- | src/mkvpc-cl.opt | 36 | ||||
-rw-r--r-- | src/mkvpc.c | 38 | ||||
-rw-r--r-- | src/rmvpc.c | 40 | ||||
-rw-r--r-- | src/util.c | 0 | ||||
-rw-r--r-- | src/vpcattr.c | 96 |
20 files changed, 525 insertions, 11 deletions
@@ -10,13 +10,13 @@ operation from the command line. +---------------------------------+----------------------+------------+-------+ AllocateAddress allocaddr [X] [X] AssignPrivateIpAddresses - [ ] [ ] AssociateAddress assocaddr [X] [X] AssociateDhcpOptions - [ ] [ ] AssociateRouteTable - [ ] [ ] -AttachInternetGateway - [ ] [ ] +AttachInternetGateway atigw [X] [ ] AttachNetworkInterface - [ ] [ ] AttachVolume atvol [X] [X] AttachVpnGateway - [ ] [ ] AuthorizeSecurityGroupEgress - [ ] [ ] AuthorizeSecurityGroupIngress sg [X] [X] BundleInstance - [ ] [ ] @@ -29,13 +29,13 @@ ConfirmProductInstance - [ ] [ ] CopyImage cpimg [X] [X] CopySnapshot cpsnap [X] [X] CreateCustomerGateway - [ ] [ ] CreateDhcpOptions - [ ] [ ] CreateImage mkimg [X] [X] CreateInstanceExportTask - [ ] [ ] -CreateInternetGateway - [ ] [ ] +CreateInternetGateway mkigw [X] [ ] CreateKeyPair - [ ] [ ] CreateNetworkAcl - [ ] [ ] CreateNetworkAclEntry - [ ] [ ] CreateNetworkInterface - [ ] [ ] CreatePlacementGroup - [ ] [ ] CreateReservedInstancesListing - [ ] [ ] @@ -44,19 +44,19 @@ CreateRouteTable - [ ] [ ] CreateSecurityGroup mksg [X] [X] CreateSnapshot mksnap [X] [X] CreateSpotDatafeedSubscription - [ ] [ ] CreateSubnet - [ ] [ ] CreateTags mktag [X] [X] CreateVolume mkvol [X] [X] -CreateVpc - [ ] [ ] +CreateVpc mkvpc [X] [X] CreateVpnConnection - [ ] [ ] CreateVpnConnectionRoute - [ ] [ ] CreateVpnGateway - [ ] [ ] DeleteCustomerGateway - [ ] [ ] DeleteDhcpOptions - [ ] [ ] -DeleteInternetGateway - [ ] [ ] +DeleteInternetGateway rmigw [X] [ ] DeleteKeyPair - [ ] [ ] DeleteNetworkAcl - [ ] [ ] DeleteNetworkAclEntry - [ ] [ ] DeleteNetworkInterface - [ ] [ ] DeletePlacementGroup - [ ] [ ] DeleteRoute - [ ] [ ] @@ -64,13 +64,13 @@ DeleteRouteTable - [ ] [ ] DeleteSecurityGroup rmsg [X] [X] DeleteSnapshot rmsnap [X] [X] DeleteSpotDatafeedSubscription - [ ] [ ] DeleteSubnet - [ ] [ ] DeleteTags rmtag [X] [X] DeleteVolume rmvol [X] [X] -DeleteVpc - [ ] [ ] +DeleteVpc rmvpc [X] [ ] DeleteVpnConnection - [ ] [ ] DeleteVpnConnectionRoute - [ ] [ ] DeleteVpnGateway - [ ] [ ] DeregisterImage deimg [X] [X] DescribeAddresses lsaddr [X] [X] DescribeAvailabilityZones lszon [X] [X] @@ -81,13 +81,13 @@ DescribeDhcpOptions - [ ] [ ] DescribeExportTasks - [ ] [ ] DescribeImageAttribute lsaattr [X] [X] DescribeImages lsimg [X] [X] DescribeInstanceAttribute lsiattr [X] [X] DescribeInstances lsinst [X] [X] DescribeInstanceStatus lsistat [X] [X] -DescribeInternetGateways - [ ] [ ] +DescribeInternetGateways lsigw [X] [ ] DescribeKeyPairs - [ ] [ ] DescribeNetworkAcls - [ ] [ ] DescribeNetworkInterfaceAttribute - [ ] [ ] DescribeNetworkInterfaces - [ ] [ ] DescribePlacementGroups - [ ] [ ] DescribeRegions lsreg [X] [X] @@ -103,16 +103,17 @@ DescribeSpotInstanceRequests - [ ] [ ] DescribeSpotPriceHistory - [ ] [ ] DescribeSubnets - [ ] [ ] DescribeTags lstag [X] [X] DescribeVolumes lsvol [X] [X] DescribeVolumeAttribute - [ ] [ ] DescribeVolumeStatus - [ ] [ ] -DescribeVpcs - [ ] [ ] +DescribeVpcAttribute lsvpcattr [X] [ ] +DescribeVpcs lsvpc [X] [ ] DescribeVpnConnections - [ ] [ ] DescribeVpnGateways - [ ] [ ] -DetachInternetGateway - [ ] [ ] +DetachInternetGateway deigw [X] [ ] DetachNetworkInterface - [ ] [ ] DetachVolume devol [X] [X] DetachVpnGateway - [ ] [ ] DisableVgwRoutePropagation - [ ] [ ] DisassociateAddress disasaddr [X] [X] DisassociateRouteTable - [ ] [ ] @@ -125,12 +126,13 @@ ImportKeyPair - [ ] [ ] ImportVolume - [ ] [ ] ModifyImageAttribute setaattr [X] [X] ModifyInstanceAttribute setiattr [X] [X] ModifyNetworkInterfaceAttribute - [ ] [ ] ModifySnapshotAttribute setsattr [X] [X] ModifyVolumeAttribute - [ ] [ ] +ModifyVpcAttribute setvpcattr [X] [ ] MonitorInstances - [ ] [ ] PurchaseReservedInstancesOffering - [ ] [ ] RebootInstances reboot [X] [X] RegisterImage - [ ] [ ] ReleaseAddress rmaddr [X] [X] ReplaceNetworkAclAssociation - [ ] [ ] diff --git a/doc/Makefile.inc b/doc/Makefile.inc index 5885e21..9997bca 100644 --- a/doc/Makefile.inc +++ b/doc/Makefile.inc @@ -46,12 +46,13 @@ MANPAGES1=\ eclat-mkimg.1\ eclat-mkinst.1\ eclat-mksg.1\ eclat-mksnap.1\ eclat-mktag.1\ eclat-mkvol.1\ + eclat-mkvpc.1\ eclat-reboot.1\ eclat-rmaddr.1\ eclat-rmsg.1\ eclat-rmsnap.1\ eclat-rmtag.1\ eclat-setaattr.1\ diff --git a/etc/Makefile.am b/etc/Makefile.am index 29ae900..10de3fd 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -24,12 +24,13 @@ FLNFILES=\ copy-snapshot.fln\ create-image.fln\ create-security-group.fln\ create-snapshot.fln\ create-tags.fln\ create-volume.fln\ + create-vpc.fln\ delete-security-group.fln\ delete-snapshot.fln\ delete-tags.fln\ delete-volume.fln\ deregister-image.fln\ describe-addresses.fln\ @@ -42,12 +43,13 @@ FLNFILES=\ describe-regions.fln\ describe-security-groups.fln\ describe-snapshot-attribute.fln\ describe-snapshots.fln\ describe-tags.fln\ describe-volumes.fln\ + describe-vpcs.fln\ detach-volume.fln\ disassociate-address.fln\ get-console-output.fln\ lsattr.fln\ modify-image-attribute.fln\ modify-instance-attribute.fln\ diff --git a/etc/describe-vpc-attribute.fln b/etc/describe-vpc-attribute.fln new file mode 100644 index 0000000..c96f624 --- /dev/null +++ b/etc/describe-vpc-attribute.fln @@ -0,0 +1,20 @@ +/* This file is part of Eclat. + Copyright (C) 2012-2015 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 (.DescribeVpcAttributeResponse.enableDnsHostnames || + .DescribeVpcAttributeResponse.enableDnsSupport) { + print(last.value,"\n"); +}
\ No newline at end of file diff --git a/etc/describe-vpcs.fln b/etc/describe-vpcs.fln new file mode 100644 index 0000000..e53e2fc --- /dev/null +++ b/etc/describe-vpcs.fln @@ -0,0 +1,22 @@ +/* This file is part of Eclat. + Copyright (C) 2012-2015 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 (.DescribeVpcsResponse.vpcSet) { + for (var in .DescribeVpcsResponse.vpcSet.item) { + print(var.vpcId, "\t", var.cidrBlock, "\t", var.dhcpOptionsId, "\t", + var.state, "\t", var.isDefault, "\n"); + } +} diff --git a/src/Makefile.am b/src/Makefile.am index 7ec7c66..d46ad42 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,12 +31,13 @@ eclat_SOURCES=\ disasaddr.c\ ec2map.c\ eclat.c\ eclat.h\ genericcl.c\ getconout.c\ + igw.c\ io.c\ lsaddr.c\ lsattr.c\ lsaattr.c\ lsiattr.c\ lsimg.c\ @@ -45,29 +46,33 @@ eclat_SOURCES=\ lsreg.c\ lssattr.c\ lssg.c\ lssnap.c\ lstag.c\ lsvol.c\ + lsvpc.c\ lszon.c\ mkimg.c\ mkinst.c\ mksg.c\ mksnap.c\ mktags.c\ mkvol.c\ + mkvpc.c\ rmaddr.c\ rmsg.c\ rmsnap.c\ rmvol.c\ + rmvpc.c\ setiattr.c\ sg.c\ sg.h\ setaattr.c\ startstop.c\ - util.c + util.c\ + vpcattr.c ispeek_SOURCES = \ ispeek.c\ ispeek-cl.h LDADD=../lib/libeclat.a @LIBOBJS@ ../grecs/src/libgrecs.a $(CURL_LIBS) @MAPLIBS@ @@ -95,12 +100,13 @@ OPTFILES=\ lstag-cl.opt\ mkimg-cl.opt\ mkinst-cl.opt\ mksg-cl.opt\ mktags-cl.opt\ mkvol-cl.opt\ + mkvpc-cl.opt\ rmaddr-cl.opt\ rmsg-cl.opt\ sg-cl.opt\ setiattr-cl.opt\ setaattr-cl.opt\ stop-cl.opt diff --git a/src/eclat.c b/src/eclat.c index 69efa8e..faba64a 100644 --- a/src/eclat.c +++ b/src/eclat.c @@ -161,12 +161,32 @@ struct eclat_command cmdtab[] = { { "rmsg", "delete-security-group", "DeleteSecurityGroup", eclat_delete_security_group, CMD_MOD|CMD_DESTR }, { "lsaattr", "describe-image-attribute", "DescribeImageAttribute", eclat_describe_image_attribute }, { "setaattr", "modify-image-attribute", "ModifyImageAttribute", eclat_modify_image_attribute, CMD_MOD }, + { "lsvpc", "describe-vpcs", "DescribeVpcs", + eclat_describe_vpcs }, + { "lsvpcattr", "describe-vpc-attribute", "DescribeVpcAttribute", + eclat_describe_vpc_attribute }, + { "mkvpc", "create-vpc", "CreateVpc", + eclat_create_vpc, CMD_MOD }, + { "setvpcattr", "modify-vpc-attribute", "ModifyVpcAttribute", + eclat_modify_vpc_attribute, CMD_MOD }, + { "rmvpc", "delete-vpc", "DeleteVpc", + eclat_delete_vpc, CMD_MOD|CMD_DESTR }, + { "lsigw", "describe-internet-gateways", "DescribeInternetGateways", + eclat_describe_internet_gateways }, + { "mkigw", "create-internet-gateway", "CreateInternetGateway", + eclat_create_internet_gateway, CMD_MOD }, + { "rmigw", "delete-internet-gateway", "DeleteInternetGateway", + eclat_delete_internet_gateway, CMD_MOD|CMD_DESTR }, + { "atigw", "attach-internet-gateway", "AttachInternetGateway", + eclat_attach_internet_gateway, CMD_MOD }, + { "deigw", "detach-internet-gateway", "DetachInternetGateway", + eclat_detach_internet_gateway, CMD_MOD|CMD_DESTR }, }; 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 604ffdc..6897c15 100644 --- a/src/eclat.h +++ b/src/eclat.h @@ -160,23 +160,40 @@ 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_describe_vpcs(eclat_command_env_t *env, int argc, char **argv); +int eclat_describe_vpc_attribute(eclat_command_env_t *env, int argc, char **argv); +int eclat_modify_vpc_attribute(eclat_command_env_t *env, int argc, char **argv); +int eclat_delete_vpc(eclat_command_env_t *env, int argc, char **argv); + +int eclat_create_internet_gateway(eclat_command_env_t *env, + int argc, char **argv); +int eclat_delete_internet_gateway(eclat_command_env_t *env, + int argc, char **argv); +int eclat_describe_internet_gateways(eclat_command_env_t *env, + int argc, char **argv); +int eclat_attach_internet_gateway(eclat_command_env_t *env, + int argc, char **argv); +int eclat_detach_internet_gateway(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_describe_image_attribute(eclat_command_env_t *env, int argc, char **argv); int eclat_modify_image_attribute(eclat_command_env_t *env, int argc, char **argv); int eclat_lsattr(eclat_command_env_t *env, int argc, char **argv); +int eclat_create_vpc(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, grecs_locus_t *locus); @@ -225,12 +242,14 @@ int get_scr_cols(void); #define MAP_GROUPID "GroupId" #define MAP_GROUPNAME "GroupName" #define MAP_SNAPSHOT "SnapshotId" #define MAP_VOLUME "VolumeId" #define MAP_AZ "AZ" #define MAP_REG "reg" +#define MAP_VPC "VpcId" +#define MAP_IGW "InternetGatewayId" void translate_ids(int argc, char **argv, const char *map); void translate_resource_ids(int argc, char **argv); void eclat_encode_devmap(struct ec2_request *q, struct grecs_list *list); int get_access_creds(const char *id, char **access_key_ptr, 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 @@ +/* This file is part of Eclat. + Copyright (C) 2012-2015 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_create_internet_gateway(eclat_command_env_t *env, int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + generic_proginfo->args_doc = NULL; + generic_parse_options(env->cmd, + "create internet gateway", + argc, argv, &i); + if (argc > i) + die(EX_USAGE, "wrong number of arguments"); + return 0; +} + +int +eclat_delete_internet_gateway(eclat_command_env_t *env, int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + + generic_proginfo->args_doc = "IGW-ID"; + generic_parse_options(env->cmd, + "delete internet gateway", + argc, argv, &i); + argv += i; + argc -= i; + + if (argc != 1) + die(EX_USAGE, "wrong number of arguments"); + + translate_ids(1, argv, MAP_IGW); + eclat_request_add_param(q, "InternetGatewayId", argv[0]); + + return 0; +} + +static struct filter_descr filters[] = { + { "attachment.state", FILTER_STRING }, + { "attachment.vpc-id", FILTER_STRING }, + { "internet-gateway-id", FILTER_STRING }, + { "tag-key", FILTER_STRING }, + { "tag-value", FILTER_STRING }, + { "tag:<KEY>", FILTER_STRING }, + { NULL } +}; + +int +eclat_describe_internet_gateways(eclat_command_env_t *env, + int argc, char **argv) +{ + int i; + + available_filters = filters; + generic_proginfo->print_help_hook = list_filters; + generic_proginfo->args_doc = "[FILTER...] [ID...]"; + generic_parse_options(env->cmd, + "describe internet gateways", + argc, argv, &i); + argv += i; + argc -= i; + translate_ids(argc, argv, MAP_IGW); + + describe_request_create(env, argc, argv, "InternetGatewayId"); + return 0; +} + +int +eclat_attach_internet_gateway(eclat_command_env_t *env, + int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + + generic_proginfo->args_doc = "IGW-ID VPC-ID"; + generic_parse_options(env->cmd, + "attach internet gateway to a VPC", + argc, argv, &i); + argv += i; + argc -= i; + if (argc != 2) + die(EX_USAGE, "wrong number of arguments"); + + translate_ids(1, argv, MAP_IGW); + translate_ids(1, argv+1, MAP_VPC); + + eclat_request_add_param(q, "InternetGatewayId", argv[0]); + eclat_request_add_param(q, "VpcId", argv[1]); + + return 0; +} + +int +eclat_detach_internet_gateway(eclat_command_env_t *env, + int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + + generic_proginfo->args_doc = "IGW-ID VPC-ID"; + generic_parse_options(env->cmd, + "detach internet gateway from VPC", + argc, argv, &i); + argv += i; + argc -= i; + if (argc != 2) + die(EX_USAGE, "wrong number of arguments"); + + translate_ids(1, argv, MAP_IGW); + translate_ids(1, argv+1, MAP_VPC); + + eclat_request_add_param(q, "InternetGatewayId", argv[0]); + eclat_request_add_param(q, "VpcId", argv[1]); + + return 0; +} diff --git a/src/lsinst.c b/src/lsinst.c index 7c65495..79cc4ec 100644 --- a/src/lsinst.c +++ b/src/lsinst.c @@ -129,12 +129,13 @@ parse_options(struct eclat_command const *cmd, int argc, char *argv[], { "association.allocation-id", FILTER_STRING }, { NULL } }; available_filters = filters; generic_proginfo->print_help_hook = list_filters; + generic_proginfo->args_doc = _("[FILTER...] [INST-ID...]"); return generic_parse_options(cmd, "List instances", argc, argv, index); } int diff --git a/src/lsreg.c b/src/lsreg.c index 11c8203..78d3862 100644 --- a/src/lsreg.c +++ b/src/lsreg.c @@ -26,13 +26,13 @@ parse_options(struct eclat_command const *cmd, { NULL } }; available_filters = filters; generic_proginfo->print_help_hook = list_filters; generic_proginfo->args_doc = "[REGION [REGION...]]"; - return generic_parse_options(cmd, + generic_parse_options(cmd, "List available regions", argc, argv, index); } int eclat_describe_regions(eclat_command_env_t *env, int argc, char **argv) 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 @@ -73,12 +73,21 @@ BEGIN struct resource *res = grecs_malloc(sizeof(*res)); res->map = MAP_SNAPSHOT; res->resid = optarg; grecs_list_append(reslist, res); END +OPTION(internet-gateway,g,[<ID>], + [<internet gateway ID>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + res->map = MAP_IGW; + res->resid = optarg; + grecs_list_append(reslist, res); +END + ECLAT_CL_END ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[< { static char *resource_types[] = { "customer-gateway", diff --git a/src/lsvpc.c b/src/lsvpc.c new file mode 100644 index 0000000..edd8a13 --- /dev/null +++ b/src/lsvpc.c @@ -0,0 +1,59 @@ +/* This file is part of Eclat. + Copyright (C) 2015 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" + +static void +parse_options(struct eclat_command const *cmd, int argc, char *argv[], + int *index) +{ + static char *state_enum[] = { "pending", "available", NULL }; + static struct filter_descr filters[] = { + { "cidr", FILTER_STRING }, //FIXME: FILTER_CIDR + { "dhcp-options-id", FILTER_STRING }, + { "isDefault", FILTER_BOOL }, + { "state", FILTER_ENUM, state_enum }, + { "tag-key", FILTER_STRING }, + { "tag-value", FILTER_STRING }, + { "tag:<KEY>", FILTER_STRING }, + { "vpc-id", FILTER_STRING }, + { NULL } + }; + + available_filters = filters; + generic_proginfo->print_help_hook = list_filters; + generic_proginfo->args_doc = _("[FILTER...] [VPC-ID...]"); + return generic_parse_options(cmd, + "List VPCs", + argc, argv, index); +} + +int +eclat_describe_vpcs(eclat_command_env_t *env, int argc, char **argv) +{ + int i; + + parse_options(env->cmd, argc, argv, &i); + argv += i; + argc -= i; + translate_ids(argc, argv, MAP_VPC); + + describe_request_create(env, argc, argv, "VpcId"); + return 0; +} + + + 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 @@ -18,13 +18,13 @@ static char *vpcid; ECLAT_CL_BEGIN([<create EC2 security group>], [<GROUPNAME DESCR>]) OPTION(vpc-id,i,[<ID>], [<VPC ID>]) -BEGINb +BEGIN vpcid = optarg; END ECLAT_CL_END ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[], int *index>],[< 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 @@ -74,12 +74,22 @@ BEGIN struct resource *res = grecs_malloc(sizeof(*res)); res->map = MAP_SNAPSHOT; res->resid = optarg; grecs_list_append(reslist, res); END +OPTION(internet-gateway,g,[<ID>], + [<internet gateway ID>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + res->map = MAP_IGW; + res->resid = optarg; + grecs_list_append(reslist, res); +END + + OPTION(from-file,T,[<FILE>], [<read tags from FILE>]) BEGIN from_file = optarg; END diff --git a/src/mkvpc-cl.opt b/src/mkvpc-cl.opt new file mode 100644 index 0000000..03611f0 --- /dev/null +++ b/src/mkvpc-cl.opt @@ -0,0 +1,36 @@ +/* This file is part of Eclat. + Copyright (C) 2013-2015 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 int vpc_dry_run; +static char *vpc_tenancy; + +ECLAT_CL_BEGIN([<create VPC>], + [<CIDR>]) + +OPTION(tenancy,t, + [<default|dedicated>], + [<instance tenancy>]) +BEGIN + vpc_tenancy = 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/mkvpc.c b/src/mkvpc.c new file mode 100644 index 0000000..1c837ba --- /dev/null +++ b/src/mkvpc.c @@ -0,0 +1,38 @@ +/* This file is part of Eclat. + Copyright (C) 2015 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 "mkvpc-cl.h" + +int +eclat_create_vpc(eclat_command_env_t *env, int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + + parse_options(env, argc, argv, &i); + argc -= i; + argv += i; + if (argc != 1) + die(EX_USAGE, "wrong number of arguments"); + + if (vpc_tenancy) + eclat_request_add_param(q, "InstanceTenancy", "true"); + eclat_request_add_param(q, "CidrBlock", argv[0]); + return 0; +} + + diff --git a/src/rmvpc.c b/src/rmvpc.c new file mode 100644 index 0000000..d1c0026 --- /dev/null +++ b/src/rmvpc.c @@ -0,0 +1,40 @@ +/* This file is part of Eclat. + Copyright (C) 2012-2015 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_delete_vpc(eclat_command_env_t *env, int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + + generic_proginfo->args_doc = "VPC-ID"; + generic_parse_options(env->cmd, + "delete the VPC", + argc, argv, &i); + argv += i; + argc -= i; + + if (argc != 1) + die(EX_USAGE, "wrong number of arguments"); + + translate_ids(1, argv, MAP_VPC); + eclat_request_add_param(q, "VpcId", argv[0]); + + return 0; +} + diff --git a/src/vpcattr.c b/src/vpcattr.c new file mode 100644 index 0000000..1896ee1 --- /dev/null +++ b/src/vpcattr.c @@ -0,0 +1,96 @@ +/* This file is part of Eclat. + Copyright (C) 2015 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_describe_vpc_attribute(eclat_command_env_t *env, int argc, char **argv) +{ + int i; + struct ec2_request *q = env->request; + const char *attrname; + static char *attrs[] = { + "enableDnsSupport", + "enableDnsHostnames", + NULL + }; + + generic_proginfo->args_doc = "VPC-ID [ATTR]"; + available_attrs = attrs; + generic_proginfo->print_help_hook = list_attrs; + generic_parse_options(env->cmd, + "describe VPC attributes", + argc, argv, &i); + argv += i; + argc -= i; + + switch (argc) { |