X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Famazon_ec2.pm;h=c1082a8aa4893a1e56d90ef81d7965c33f55ea85;hp=0e65ca00cfb78543b56ab99bceca2ef663903e15;hb=aeb90ade381fc3d5477db0334048c2af623fccfe;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924 diff --git a/FS/FS/part_export/amazon_ec2.pm b/FS/FS/part_export/amazon_ec2.pm index 0e65ca00c..c1082a8aa 100644 --- a/FS/FS/part_export/amazon_ec2.pm +++ b/FS/FS/part_export/amazon_ec2.pm @@ -8,10 +8,12 @@ use FS::Record qw( qsearchs ); use FS::svc_external; tie my %options, 'Tie::IxHash', - 'access_key' => { label => 'AWS access key', }, - 'secret_key' => { label => 'AWS secret key', }, - 'ami' => { label => 'AMI', 'default' => 'ami-ff46a796', }, - 'keyname' => { label => 'Keypair name', }, + 'access_key' => { label => 'AWS access key', }, + 'secret_key' => { label => 'AWS secret key', }, + 'ami' => { label => 'AMI', 'default' => 'ami-ff46a796', }, + 'keyname' => { label => 'Keypair name', }, + 'region' => { label => 'Region', }, + 'InstanceType' => { label => 'Instance Type', }, #option to turn off (or on) ip address allocation ; @@ -20,6 +22,7 @@ tie my %options, 'Tie::IxHash', 'desc' => 'Export to Amazon EC2', 'options' => \%options, + 'no_machine' => 1, 'notes' => <<'END' Create instances in the Amazon EC2 (Elastic compute cloud). Install Net::Amazon::EC2 perl module. Advisable to set svc_external-skip_manual config @@ -37,6 +40,7 @@ sub _export_insert { $svc_external->svcnum, $self->option('ami'), $self->option('keyname'), + $self->option('InstanceType'), ); ref($err_or_queue) ? '' : $err_or_queue; } @@ -95,31 +99,35 @@ sub amazon_ec2_queue { }; $queue->insert( $self->option('access_key'), $self->option('secret_key'), + $self->option('region'), @_ ) or $queue; } sub amazon_ec2_new { - my( $access_key, $secret_key, @rest ) = @_; + my( $access_key, $secret_key, $region, @rest ) = @_; eval 'use Net::Amazon::EC2;'; die $@ if $@; my $ec2 = new Net::Amazon::EC2 'AWSAccessKeyId' => $access_key, - 'SecretAccessKey' => $secret_key; - + 'SecretAccessKey' => $secret_key, + 'region' => $region || 'us-east-1', + ; ( $ec2, @rest ); } sub amazon_ec2_insert { #subroutine, not method - my( $ec2, $svcnum, $ami, $keyname ) = amazon_ec2_new(@_); - - my $reservation_info = $ec2->run_instances( 'ImageId' => $ami, - 'KeyName' => $keyname, - 'MinCount' => 1, - 'MaxCount' => 1, - ); + my( $ec2, $svcnum, $ami, $keyname, $InstanceType ) = amazon_ec2_new(@_); + + my $reservation_info = $ec2->run_instances( + 'ImageId' => $ami, + 'KeyName' => $keyname, + 'InstanceType' => $InstanceType || 'm1.small', + 'MinCount' => 1, + 'MaxCount' => 1, + ); my $instance_id = $reservation_info->instances_set->[0]->instance_id;