| 1 | package VM::EC2::Spot::LaunchSpecification; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::Spot::LaunchSpecification - Object describing an Amazon EC2 spot instance launch specification | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | See L<VM::EC2/SPOT INSTANCES>, and L<VM::EC2::Spot::InstanceRequest>. | ||
| 10 | |||
| 11 | =head1 DESCRIPTION | ||
| 12 | |||
| 13 | This object represents an Amazon EC2 spot instance launch | ||
| 14 | specification, which is returned by a VM::EC2::Spot::InstanceRequest | ||
| 15 | object's launchSpecification() method. It provides information about | ||
| 16 | the spot instance request. | ||
| 17 | |||
| 18 | =head1 METHODS | ||
| 19 | |||
| 20 | These object methods are supported: | ||
| 21 | |||
| 22 | imageId -- the ID of the image to be used for the request | ||
| 23 | keyName -- the ssh keyname for instances created by the request | ||
| 24 | groupSet -- a list of VM::EC2::Group objects representing the launch | ||
| 25 | groups for spot instances created under this request. | ||
| 26 | addressingType -- Deprecated and undocumented, but present in the EC2 API | ||
| 27 | instanceType -- type of instances created by the request | ||
| 28 | placement -- availability zone for instances created by the request | ||
| 29 | kernelId -- kernel ID to be used for instances launched by the request | ||
| 30 | ramdiskId -- ramdisk ID to be used for instances launched by the request | ||
| 31 | blockDeviceMapping -- List of VM::EC2::BlockDevice::Mapping objects describing | ||
| 32 | the block devices to be attached to instances launched by the | ||
| 33 | request. | ||
| 34 | monitoring -- A true value if detailed monitoring was requested for these | ||
| 35 | instances. | ||
| 36 | subnetId -- Subnet ID in which to place instances launched under this | ||
| 37 | request (VPC only). | ||
| 38 | |||
| 39 | =head1 SEE ALSO | ||
| 40 | |||
| 41 | L<VM::EC2> | ||
| 42 | L<VM::EC2::Generic> | ||
| 43 | L<VM::EC2::Spot::InstanceRequest> | ||
| 44 | L<VM::EC2::Error> | ||
| 45 | |||
| 46 | =head1 AUTHOR | ||
| 47 | |||
| 48 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 49 | |||
| 50 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||
| 51 | |||
| 52 | This package and its accompanying libraries is free software; you can | ||
| 53 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 54 | version 1, or at your option, any later version) or the Artistic | ||
| 55 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 56 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | use strict; | ||
| 61 | use VM::EC2::Group; | ||
| 62 | use base 'VM::EC2::Generic'; | ||
| 63 | |||
| 64 | sub valid_fields { | ||
| 65 | return qw(imageId keyName groupSet addressingType instanceType | ||
| 66 | placement kernelId ramdiskId blockDeviceMapping monitoring | ||
| 67 | subnetId); | ||
| 68 | } | ||
| 69 | |||
| 70 | sub blockDeviceMapping { | ||
| 71 | my $self = shift; | ||
| 72 | my $mapping = $self->SUPER::blockDeviceMapping or return; | ||
| 73 | my @mapping = map { VM::EC2::BlockDevice::Mapping->new($_,$self->ec2)} @{$mapping->{item}}; | ||
| 74 | foreach (@mapping) { $_->instance($self) } | ||
| 75 | return @mapping; | ||
| 76 | } | ||
| 77 | |||
| 78 | sub monitoring { | ||
| 79 | my $self = shift; | ||
| 80 | my $monitoring = $self->SUPER::monitoring or return; | ||
| 81 | return $monitoring->{enabled} eq 'true'; | ||
| 82 | } | ||
| 83 | |||
| 84 | sub groupSet { | ||
| 85 | my $self = shift; | ||
| 86 | my $groupSet = $self->SUPER::groupSet; | ||
| 87 | return map {VM::EC2::Group->new($_,$self->aws,$self->xmlns,$self->requestId)} | ||
| 88 | @{$groupSet->{item}}; | ||
| 89 | } | ||
| 90 | |||
| 91 | 1; |