X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Famazon_ec2.pm;fp=FS%2FFS%2Fpart_export%2Famazon_ec2.pm;h=c1082a8aa4893a1e56d90ef81d7965c33f55ea85;hp=06e2c238e3ef396c88bf5d83f0b8308035ac58fa;hb=aeb90ade381fc3d5477db0334048c2af623fccfe;hpb=d9edf24e9d3e1fd87a23359a7679ef6d6637c00d diff --git a/FS/FS/part_export/amazon_ec2.pm b/FS/FS/part_export/amazon_ec2.pm index 06e2c238e..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 ; @@ -38,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; } @@ -96,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;