Class: Fog::Compute::AWS::SpotRequest
- Defined in:
- lib/fog/aws/models/compute/spot_request.rb
Instance Attribute Summary collapse
-
#iam_instance_profile_arn ⇒ Object
writeonly
Sets the attribute iam_instance_profile_arn.
-
#iam_instance_profile_name ⇒ Object
writeonly
Sets the attribute iam_instance_profile_name.
Attributes inherited from Server
#private_key, #private_key_path, #public_key, #public_key_path, #ssh_options, #ssh_port, #username
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(attributes = {}) ⇒ SpotRequest
constructor
A new instance of SpotRequest.
- #key_pair ⇒ Object
- #key_pair=(new_keypair) ⇒ Object
- #ready? ⇒ Boolean
- #save ⇒ Object
Methods inherited from Server
#scp, #scp_download, #ssh, #ssh_ip_address, #ssh_ip_address=, #sshable?
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ SpotRequest
Returns a new instance of SpotRequest.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 41 def initialize(attributes={}) self.groups ||= ["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 |
Instance Attribute Details
#iam_instance_profile_arn=(value) ⇒ Object (writeonly)
Sets the attribute iam_instance_profile_arn
39 40 41 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 39 def iam_instance_profile_arn=(value) @iam_instance_profile_arn = value end |
#iam_instance_profile_name=(value) ⇒ Object (writeonly)
Sets the attribute iam_instance_profile_name
39 40 41 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 39 def iam_instance_profile_name=(value) @iam_instance_profile_name = value end |
Instance Method Details
#destroy ⇒ Object
66 67 68 69 70 71 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 66 def destroy requires :id service.cancel_spot_instance_requests(id) true end |
#key_pair ⇒ Object
73 74 75 76 77 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 73 def key_pair requires :key_name service.key_pairs.all(key_name).first end |
#key_pair=(new_keypair) ⇒ Object
79 80 81 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 79 def key_pair=(new_keypair) self.key_name = new_keypair && new_keypair.name end |
#ready? ⇒ Boolean
83 84 85 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 83 def ready? state == 'active' end |
#save ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/fog/aws/models/compute/spot_request.rb', line 87 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.SecurityGroupId' => 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 } .delete_if {|key, value| value.nil?} data = service.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 |