class Fog::AWS::Compute::SpotRequest
Attributes
iam_instance_profile_arn[W]
iam_instance_profile_name[W]
Public Class Methods
new(attributes={})
click to toggle source
Calls superclass method
# File lib/fog/aws/models/compute/spot_request.rb, line 40 def initialize(attributes={}) self.groups ||= self.security_group_ids || ["default"] self.flavor_id ||= 't1.micro' self.image_id ||= begin self.username ||= 'ubuntu' # Old 'connection' is renamed as service and should be used instead prepare_service_value(attributes) case @service.instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS) when 'ap-northeast-1' 'ami-5e0fa45f' when 'ap-southeast-1' 'ami-f092eca2' when 'eu-west-1' 'ami-3d1f2b49' when 'us-east-1' 'ami-3202f25b' when 'us-west-1' 'ami-f5bfefb0' end end super end
Public Instance Methods
destroy()
click to toggle source
# File lib/fog/aws/models/compute/spot_request.rb, line 65 def destroy requires :id service.cancel_spot_instance_requests(id) true end
key_pair()
click to toggle source
# File lib/fog/aws/models/compute/spot_request.rb, line 72 def key_pair requires :key_name service.key_pairs.all(key_name).first end
key_pair=(new_keypair)
click to toggle source
# File lib/fog/aws/models/compute/spot_request.rb, line 78 def key_pair=(new_keypair) self.key_name = new_keypair && new_keypair.name end
ready?()
click to toggle source
# File lib/fog/aws/models/compute/spot_request.rb, line 82 def ready? state == 'active' end
save()
click to toggle source
# File lib/fog/aws/models/compute/spot_request.rb, line 86 def save requires :image_id, :flavor_id, :price options = { 'AvailabilityZoneGroup' => availability_zone_group, 'InstanceCount' => instance_count, 'LaunchGroup' => launch_group, 'LaunchSpecification.BlockDeviceMapping' => block_device_mapping, 'LaunchSpecification.KeyName' => key_name, 'LaunchSpecification.Monitoring.Enabled' => monitoring, 'LaunchSpecification.Placement.AvailabilityZone' => availability_zone, 'LaunchSpecification.SecurityGroupId' => security_group_ids || groups, 'LaunchSpecification.EbsOptimized' => ebs_optimized, 'LaunchSpecification.UserData' => user_data, 'LaunchSpecification.SubnetId' => subnet_id, 'LaunchSpecification.IamInstanceProfile.Arn' => @iam_instance_profile_arn, 'LaunchSpecification.IamInstanceProfile.Name' => @iam_instance_profile_name, 'Type' => request_type, 'ValidFrom' => valid_from, 'ValidUntil' => valid_until } options.delete_if {|key, value| value.nil?} data = service.request_spot_instances(image_id, flavor_id, price, options).body spot_instance_request = data['spotInstanceRequestSet'].first spot_instance_request['launchSpecification'].each do |name,value| spot_instance_request['LaunchSpecification.' + name[0,1].upcase + name[1..-1]] = value end spot_instance_request.merge(:groups => spot_instance_request['LaunchSpecification.GroupSet']) spot_instance_request.merge(options) merge_attributes( spot_instance_request ) end