OptionSet options = parse(args);
String accessId = getAccessId(options);
String secretKey = getSecretKey(options);
String regionUrl = getRegionUrl(options);
Ec2Connection ec2Connection = new TypicaEc2Connection(accessId, secretKey, null, regionUrl);
List<String> hostNames = new ArrayList<String>();
File hostNamesFile = getInputFile(options, "hostnames");
if(hostNamesFile == null)
printUsage();
if(hostNamesFile != null) {
List<HostNamePair> hostNamePairs = getHostNamesPairsFromFile(hostNamesFile);
for(HostNamePair hostNamePair: hostNamePairs)
hostNames.add(hostNamePair.getExternalHostName());
ec2Connection.deleteInstancesByHostName(hostNames);
}
}