Class: Fog::Compute::AWS::SpotRequest
- Defined in:
- lib/fog/aws/models/compute/spot_request.rb
Instance Attribute Summary collapse
-
#username ⇒ Object
writeonly
Sets the attribute username.
Attributes inherited from Model
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ SpotRequest
constructor
A new instance of SpotRequest.
- #ready? ⇒ Boolean
- #save ⇒ Object
Methods inherited from Model
#inspect, #reload, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ SpotRequest
Returns a new instance of SpotRequest.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 37 def initialize(attributes={}) self.groups ||= ["default"] self.flavor_id ||= 't1.micro' self.image_id ||= begin self.username = 'ubuntu' case attributes[:connection].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 |
Instance Attribute Details
#username=(value) ⇒ Object (writeonly)
Sets the attribute username
35 36 37 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 35 def username=(value) @username = value end |
Instance Method Details
#ready? ⇒ Boolean
86 87 88 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 86 def ready? state == 'active' end |
#save ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 58 def save requires :image_id, :flavor_id, :price = { '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.SecurityGroup' => groups, 'LaunchSpecification.UserData' => user_data, 'Type' => request_type, 'ValidFrom' => valid_from, 'ValidUntil' => valid_until } .delete_if {|key, value| value.nil?} data = connection.request_spot_instances(image_id, flavor_id, price, ).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() merge_attributes( spot_instance_request ) end |