summaryrefslogtreecommitdiffabout
path: root/src/mkinst-cl.opt
blob: e137af22102decc55d9923c6b38655ce831a7941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/* 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 <sys/stat.h>
#include <stdio.h>

static char *ami;
static char *instance_count = "1";
static struct grecs_list *secgrp, *devmap, *iface, *privip;
static char *keypair;
static char *user_data;
static char *type;
static char *zone;
static char *kernel;
static char *ramdisk;
static char *shutdown_behavior;
static char *placement_group;
static char *tenancy;
static char *subnet;
static char *private_ip;
static char *secipcount;
static char *profile_name;

static int monitor;
static int disable_term;
static int ebs_opt;

static void
read_user_data(const char *file)
{
	struct stat st;
	FILE *fp;
	
	if (stat(file, &st))
		die(EX_USAGE, "cannot stat file %s: %s", file,
		    strerror(errno));

	/* FIXME: Use limits.h to check st.st_size */
	user_data = grecs_malloc(st.st_size+1);
	fp = fopen(file, "r");
	if (!fp)
		die(EX_UNAVAILABLE, "cannot open file %s: %s", file,
		    strerror(errno));
	if (fread(user_data, st.st_size, 1, fp) != 1)
		die(EX_UNAVAILABLE, "error reading from %s: %s", file,
		    strerror(errno));
	fclose(fp);
	user_data[st.st_size] = 0;
}

ECLAT_CL_BEGIN([<launch new instances>],
	       [<AMI-ID>])

OPTION(,n,[<N>],
       [<number of instances to launch>])
BEGIN
	/* FIXME: check if it's a valid number */
	instance_count = optarg;
END

OPTION(security-group,g,[<STRING>],
       [<The name of the security group>])
BEGIN
	if (!secgrp)
		secgrp = grecs_list_create();
	grecs_list_append(secgrp, optarg);
END

OPTION(keypair,k,[<ID>],
       [<Key pair name>])
BEGIN
	keypair = optarg;
END

OPTION(data,d,[<STRING>],
       [<user data to pass to the instance>])
BEGIN
	user_data = optarg;
END

OPTION(data-file,f,[<FILE>],
       [<read user data from FILE>])
BEGIN
	read_user_data(optarg);
END

OPTION(type,t,[<TYPE>],
       [<instance type>])
ALIAS(instance-type)
BEGIN
	type = optarg;
END

OPTION(zone,z,[<ZONE>],
       [<set availablility zone>])
ALIAS(availability-zone)
BEGIN
	zone = optarg;
END

OPTION(kernel,,[<ID>],
       [<select kernel ID>])
BEGIN
	kernel = optarg;
END

OPTION(ramdisk,,[<ID>],
       [<select ramdisk ID>])
BEGIN
	ramdisk = optarg;
END	

OPTION(devmap,m,[<DEV=SPEC>],
       [<set block device mapping>])
ALIAS(block-device-mapping)
BEGIN
	if (!devmap)
		devmap = grecs_list_create();
	grecs_list_append(devmap, optarg);
END

OPTION(monitor,,,
       [<enable monitoring>])
BEGIN
	monitor = 1;
END	

OPTION(disable-api-termination,,,
       [<disable API termination>])
BEGIN
	disable_term = 1;
END

OPTION(shutdown,,[<stop|terminate>],
       [<what to do on shutdown>])
ALIAS(instance-initiated-shutdown-behavior)       
BEGIN
	shutdown_behavior = optarg;
END

OPTION(placement-group,,[<NAME>],
       [<name of the placement group>])
BEGIN       
	placement_group = optarg;
END

OPTION(tenancy,,[<STRING>],
       [<placement tenancy>])
BEGIN
	tenancy = optarg;
END	

OPTION(subnet,s,[<ID>],
       [<subnet to launch the instance into>])
BEGIN
	subnet = optarg;
END	

OPTION(private-ip-address,,[<IP>],
       [<assign a specific private IP to the VPC instance>])
BEGIN
	private_ip = optarg;
END

dnl [--client-token token]

OPTION(network-interface,a,[<IFACE>],
       [<specify the network attachment for a VPC instance>])
ALIAS(iface)
BEGIN
	if (!iface)
		iface = grecs_list_create();
	grecs_list_append(iface, optarg);
END

OPTION(secondary-ip,,[<IP>],
       [<assign the IP as a secondary private IP address>])
ALIAS(secondary-private-ip-address)
BEGIN
	if (!privip)
		privip = grecs_list_create();
	grecs_list_append(privip, privip);
END

OPTION(number-secondary-ip,,[<N>],
       [<number of secondary IP addresses to assign>])
ALIAS(secondary-private-ip-address-count)
BEGIN
	secipcount = optarg;
END

OPTION(iam-profile,p,[<NAME>],
       [<IAM instance profile to associate with the launched instances>])
BEGIN
	profile_name = optarg;
END	

OPTION(ebs-optimized,,,
       [<optimize the instances for EBS I/O>])
BEGIN
	ebs_opt = 1;
END

ECLAT_CL_END

ECLAT_CL_PARSER(parse_options, [<int argc, char *argv[]>],[<
{
	int idx;

	GETOPT(argc, argv, idx, exit(EX_USAGE))
	if (idx != argc-1)
		die(EX_USAGE, "bad number of arguments");
	translate_ids(1, argv+idx, "ImageId");
	ami = argv[idx];
}
>])

Return to:

Send suggestions and report system problems to the System administrator.