/* 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 . */
#include
#include
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([],
[])
OPTION(,n,[],
[])
BEGIN
/* FIXME: check if it's a valid number */
instance_count = optarg;
END
OPTION(security-group,g,[],
[])
BEGIN
if (!secgrp)
secgrp = grecs_list_create();
grecs_list_append(secgrp, optarg);
END
OPTION(keypair,k,[],
[])
BEGIN
keypair = optarg;
END
OPTION(data,d,[],
[])
BEGIN
user_data = optarg;
END
OPTION(data-file,f,[],
[])
BEGIN
read_user_data(optarg);
END
OPTION(type,t,[],
[])
ALIAS(instance-type)
BEGIN
type = optarg;
END
OPTION(zone,z,[],
[])
ALIAS(availability-zone)
BEGIN
zone = optarg;
END
OPTION(kernel,,[],
[