Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0213e2aff2
Fetching contributors…

Cannot retrieve contributors at this time

92 lines (63 sloc) 2.223 kb
use strict;
use warnings;
package Dist::Zilla::App::Command::provision;
BEGIN {
$Dist::Zilla::App::Command::provision::VERSION = '0.1';
}
# ABSTRACT: provision a new Oyster VM
use Dist::Zilla::App -command;
use Moose;
use Config::Any;
use Hash::Merge 'merge';
Hash::Merge::set_behavior( 'RIGHT_PRECEDENT' );
use Oyster::Provision;
use Data::Dumper;
sub abstract { 'provision a new Oyster VM' }
sub opt_spec {
[ 'name=s' => 'the name of the VM to create' ],
[ 'config=s' => 'the name of the config file to use, default ./oyster.conf' ],
}
sub execute {
my ($self, $opt, $arg) = @_;
my $zilla = $self->zilla;
my $name = $opt->name
or die "No name provided - please provide a --name to provision\n";
my @config_files = ($opt->config or './oyster.conf');
my $cfg = Config::Any->load_files({ files => \@config_files, use_ext => 0 });
($cfg) = values %{ $cfg->[0] }; # FIX with ::JFDI or similar
my $Provision = $cfg->{Provision} or die "No <Provision> section";
my @hashes = grep $_, $Provision->{Default}, $Provision->{$name}
or die "No section for <Provision> <$name>, and no <default>";
warn Dumper(\@hashes);
my %hash = @hashes > 1 ? %{ merge( @hashes ) } : %{ $hashes[0] };
my $type = delete $hash{type} || 'Oyster::Provision::Backend::Rackspace';
$hash{provision_class} = $type =~/^Oyster::Provision::Backend::/ ? $type : "Oyster::Provision::Backend::$type";
$hash{pub_ssh} ||= "$ENV{HOME}/.ssh/id_rsa.pub";
$hash{size} ||= 1; # id 1 - ram 256 MiB - disk 10 GiB
$hash{image} ||= 69; # id 69 - Ubuntu 10.10 (meerkat)
$hash{name} ||= $name;
warn Dumper(\%hash);
my $server = Oyster::Provision->new(
name => $name,
config => \%hash,
%hash,
);
$server->create;
print "Instance $name created! ($server)\n";
}
1;
__END__
=pod
=head1 NAME
Dist::Zilla::App::Command::provision - provision a new Oyster VM
=head1 VERSION
version 0.1
=head1 SYNOPSIS
TODO
=head1 AUTHOR
CONTRIBUTORS
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by CONTRIBUTORS
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Jump to Line
Something went wrong with that request. Please try again.