mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|compute] Updates reference to service
This commit is contained in:
parent
b42d4731e5
commit
1cb5a45b3e
29 changed files with 113 additions and 114 deletions
|
@ -22,7 +22,7 @@ module Fog
|
|||
def destroy
|
||||
requires :public_ip
|
||||
|
||||
connection.release_address(allocation_id || public_ip)
|
||||
service.release_address(allocation_id || public_ip)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -35,12 +35,12 @@ module Fog
|
|||
end
|
||||
|
||||
def server
|
||||
connection.servers.get(server_id)
|
||||
service.servers.get(server_id)
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
data = connection.allocate_address(domain).body
|
||||
data = service.allocate_address(domain).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
if @server
|
||||
|
@ -57,7 +57,7 @@ module Fog
|
|||
else
|
||||
@server = nil
|
||||
self.server_id = new_server.id
|
||||
connection.associate_address(server_id, public_ip, network_interface_id, allocation_id)
|
||||
service.associate_address(server_id, public_ip, network_interface_id, allocation_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ module Fog
|
|||
@server = nil
|
||||
self.server_id = nil
|
||||
if persisted?
|
||||
connection.disassociate_address(public_ip)
|
||||
service.disassociate_address(public_ip)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ module Fog
|
|||
filters = {'public-ip' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_addresses(filters).body
|
||||
data = service.describe_addresses(filters).body
|
||||
load(
|
||||
data['addressesSet'].map do |address|
|
||||
address.reject {|key, value| value.nil? || value.empty? }
|
||||
|
@ -81,7 +81,7 @@ module Fog
|
|||
|
||||
def get(public_ip)
|
||||
if public_ip
|
||||
self.class.new(:connection => connection).all('public-ip' => public_ip).first
|
||||
self.class.new(:service => service).all('public-ip' => public_ip).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
#
|
||||
def associate(vpc_id)
|
||||
requires :id
|
||||
connection.attach_dhcp_option(id, vpc_id)
|
||||
service.attach_dhcp_option(id, vpc_id)
|
||||
#reload
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_dhcp_options(id)
|
||||
service.delete_dhcp_options(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :dhcp_configuration_set
|
||||
data = connection.create_dhcp_options(dhcp_configuration_set).body['dhcpOptionsSet'].first
|
||||
data = service.create_dhcp_options(dhcp_configuration_set).body['dhcpOptionsSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -59,7 +59,7 @@ module Fog
|
|||
filters = {'dhcp-options-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_dhcp_options(filters).body
|
||||
data = service.describe_dhcp_options(filters).body
|
||||
load(data['dhcpOptionsSet'])
|
||||
end
|
||||
|
||||
|
@ -80,7 +80,7 @@ module Fog
|
|||
|
||||
def get(dhcp_options_id)
|
||||
if dhcp_options_id
|
||||
self.class.new(:connection => connection).all('dhcp-options-id' => dhcp_options_id).first
|
||||
self.class.new(:service => service).all('dhcp-options-id' => dhcp_options_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ module Fog
|
|||
#
|
||||
|
||||
def get(flavor_id)
|
||||
self.class.new(:connection => connection).all.detect {|flavor| flavor.id == flavor_id}
|
||||
self.class.new(:service => service).all.detect {|flavor| flavor.id == flavor_id}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -27,11 +27,11 @@ module Fog
|
|||
attribute :name
|
||||
|
||||
def deregister(delete_snapshot = false)
|
||||
connection.deregister_image(id)
|
||||
service.deregister_image(id)
|
||||
|
||||
if(delete_snapshot && root_device_type == "ebs")
|
||||
block_device = block_device_mapping.detect {|block_device| block_device['deviceName'] == root_device_name}
|
||||
connection.snapshots.new(:id => block_device['snapshotId']).destroy
|
||||
service.snapshots.new(:id => block_device['snapshotId']).destroy
|
||||
else
|
||||
true
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
attribute :filters
|
||||
|
||||
model Fog::Compute::AWS::Image
|
||||
|
||||
|
||||
# Creates a new Amazon machine image
|
||||
#
|
||||
# AWS.images.new
|
||||
|
@ -38,7 +38,7 @@ module Fog
|
|||
# tags=nil
|
||||
# >
|
||||
#
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
|
@ -46,13 +46,13 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_images(filters).body
|
||||
data = service.describe_images(filters).body
|
||||
load(data['imagesSet'])
|
||||
end
|
||||
|
||||
|
||||
def get(image_id)
|
||||
if image_id
|
||||
self.class.new(:connection => connection).all('image-id' => image_id).first
|
||||
self.class.new(:service => service).all('image-id' => image_id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
#
|
||||
def attach(vpc_id)
|
||||
requires :id
|
||||
connection.attach_internet_gateway(id, vpc_id)
|
||||
service.attach_internet_gateway(id, vpc_id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ module Fog
|
|||
#
|
||||
def detach(vpc_id)
|
||||
requires :id
|
||||
connection.detach_internet_gateway(id, vpc_id)
|
||||
service.detach_internet_gateway(id, vpc_id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -54,7 +54,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_internet_gateway(id)
|
||||
service.delete_internet_gateway(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -68,7 +68,7 @@ module Fog
|
|||
# requestId and a internetGateway object
|
||||
#
|
||||
def save
|
||||
data = connection.create_internet_gateway.body['internetGatewaySet'].first
|
||||
data = service.create_internet_gateway.body['internetGatewaySet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -59,7 +59,7 @@ module Fog
|
|||
filters = {'internet-gateway-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_internet_gateways(filters).body
|
||||
data = service.describe_internet_gateways(filters).body
|
||||
load(data['internetGatewaySet'])
|
||||
end
|
||||
|
||||
|
@ -80,7 +80,7 @@ module Fog
|
|||
|
||||
def get(internet_gateway_id)
|
||||
if internet_gateway_id
|
||||
self.class.new(:connection => connection).all('internet-gateway-id' => internet_gateway_id).first
|
||||
self.class.new(:service => service).all('internet-gateway-id' => internet_gateway_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
def destroy
|
||||
requires :name
|
||||
|
||||
connection.delete_key_pair(name)
|
||||
service.delete_key_pair(name)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -24,9 +24,9 @@ module Fog
|
|||
requires :name
|
||||
|
||||
data = if public_key
|
||||
connection.import_key_pair(name, public_key).body
|
||||
service.import_key_pair(name, public_key).body
|
||||
else
|
||||
connection.create_key_pair(name).body
|
||||
service.create_key_pair(name).body
|
||||
end
|
||||
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
||||
merge_attributes(new_attributes)
|
||||
|
@ -35,7 +35,7 @@ module Fog
|
|||
end
|
||||
|
||||
def write(path="#{ENV['HOME']}/.ssh/fog_#{Fog.credential.to_s}_#{name}.pem")
|
||||
|
||||
|
||||
if writable?
|
||||
split_private_key = private_key.split(/\n/)
|
||||
File.open(path, "w") do |f|
|
||||
|
|
|
@ -55,7 +55,7 @@ module Fog
|
|||
filters = {'key-name' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_key_pairs(filters).body
|
||||
data = service.describe_key_pairs(filters).body
|
||||
load(data['keySet'])
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ module Fog
|
|||
|
||||
def get(key_name)
|
||||
if key_name
|
||||
self.class.new(:connection => connection).all('key-name' => key_name).first
|
||||
self.class.new(:service => service).all('key-name' => key_name).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
|||
class NetworkInterface < Fog::Model
|
||||
|
||||
identity :network_interface_id, :aliases => 'networkInterfaceId'
|
||||
attribute :state
|
||||
attribute :state
|
||||
attribute :request_id, :aliases => 'requestId'
|
||||
attribute :network_interface_id, :aliases => 'networkInterfaceId'
|
||||
attribute :subnet_id, :aliases => 'subnetId'
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
def destroy
|
||||
requires :network_interface_id
|
||||
|
||||
connection.delete_network_interface(network_interface_id)
|
||||
service.delete_network_interface(network_interface_id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -58,7 +58,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :subnet_id
|
||||
data = connection.create_network_interface(subnet_id).body['networkInterface']
|
||||
data = service.create_network_interface(subnet_id).body['networkInterface']
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -88,7 +88,7 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_network_interfaces(filters).body
|
||||
data = service.describe_network_interfaces(filters).body
|
||||
load(data['networkInterfaceSet'])
|
||||
end
|
||||
|
||||
|
@ -126,7 +126,7 @@ module Fog
|
|||
|
||||
def get(nic_id)
|
||||
if nic_id
|
||||
self.class.new(:connection => connection).all('network-interface-id' => nic_id).first
|
||||
self.class.new(:service => service).all('network-interface-id' => nic_id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
|
||||
requires_one :name, :group_id
|
||||
|
||||
connection.authorize_security_group_ingress(
|
||||
service.authorize_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'SourceSecurityGroupName' => group,
|
||||
|
@ -101,7 +101,7 @@ module Fog
|
|||
]
|
||||
end
|
||||
|
||||
connection.authorize_security_group_ingress(
|
||||
service.authorize_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'IpPermissions' => [ ip_permission ]
|
||||
|
@ -121,9 +121,9 @@ module Fog
|
|||
requires_one :name, :group_id
|
||||
|
||||
if group_id.nil?
|
||||
connection.delete_security_group(name)
|
||||
service.delete_security_group(name)
|
||||
else
|
||||
connection.delete_security_group(nil, group_id)
|
||||
service.delete_security_group(nil, group_id)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ module Fog
|
|||
|
||||
requires_one :name, :group_id
|
||||
|
||||
connection.revoke_security_group_ingress(
|
||||
service.revoke_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'SourceSecurityGroupName' => group,
|
||||
|
@ -215,7 +215,7 @@ module Fog
|
|||
]
|
||||
end
|
||||
|
||||
connection.revoke_security_group_ingress(
|
||||
service.revoke_security_group_ingress(
|
||||
name,
|
||||
'GroupId' => group_id,
|
||||
'IpPermissions' => [ ip_permission ]
|
||||
|
@ -235,7 +235,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :description, :name
|
||||
data = connection.create_security_group(name, description, vpc_id).body
|
||||
data = service.create_security_group(name, description, vpc_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -63,7 +63,7 @@ module Fog
|
|||
filters = {'group-name' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_security_groups(filters).body
|
||||
data = service.describe_security_groups(filters).body
|
||||
load(data['securityGroupInfo'])
|
||||
end
|
||||
|
||||
|
@ -87,7 +87,7 @@ module Fog
|
|||
|
||||
def get(group_name)
|
||||
if group_name
|
||||
self.class.new(:connection => connection).all('group-name' => group_name).first
|
||||
self.class.new(:service => service).all('group-name' => group_name).first
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,7 +110,7 @@ module Fog
|
|||
|
||||
def get_by_id(group_id)
|
||||
if group_id
|
||||
self.class.new(:connection => connection).all('group-id' => group_id).first
|
||||
self.class.new(:service => service).all('group-id' => group_id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,19 +84,19 @@ module Fog
|
|||
def addresses
|
||||
requires :id
|
||||
|
||||
connection.addresses(:server => self)
|
||||
service.addresses(:server => self)
|
||||
end
|
||||
|
||||
def console_output
|
||||
requires :id
|
||||
|
||||
connection.get_console_output(id)
|
||||
service.get_console_output(id)
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.terminate_instances(id)
|
||||
service.terminate_instances(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -110,13 +110,13 @@ module Fog
|
|||
end
|
||||
|
||||
def flavor
|
||||
@flavor ||= connection.flavors.all.detect {|flavor| flavor.id == flavor_id}
|
||||
@flavor ||= service.flavors.all.detect {|flavor| flavor.id == flavor_id}
|
||||
end
|
||||
|
||||
def key_pair
|
||||
requires :key_name
|
||||
|
||||
connection.key_pairs.all(key_name).first
|
||||
service.key_pairs.all(key_name).first
|
||||
end
|
||||
|
||||
def key_pair=(new_keypair)
|
||||
|
@ -129,7 +129,7 @@ module Fog
|
|||
|
||||
def reboot
|
||||
requires :id
|
||||
connection.reboot_instances(id)
|
||||
service.reboot_instances(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -170,14 +170,14 @@ module Fog
|
|||
options.delete('SubnetId')
|
||||
end
|
||||
|
||||
data = connection.run_instances(image_id, 1, 1, options)
|
||||
data = service.run_instances(image_id, 1, 1, options)
|
||||
merge_attributes(data.body['instancesSet'].first)
|
||||
|
||||
if tags = self.tags
|
||||
# expect eventual consistency
|
||||
Fog.wait_for { self.reload rescue nil }
|
||||
for key, value in (self.tags = tags)
|
||||
connection.tags.create(
|
||||
service.tags.create(
|
||||
:key => key,
|
||||
:resource_id => self.identity,
|
||||
:value => value
|
||||
|
@ -209,19 +209,19 @@ module Fog
|
|||
|
||||
def start
|
||||
requires :id
|
||||
connection.start_instances(id)
|
||||
service.start_instances(id)
|
||||
true
|
||||
end
|
||||
|
||||
def stop(force = false)
|
||||
requires :id
|
||||
connection.stop_instances(id, force)
|
||||
service.stop_instances(id, force)
|
||||
true
|
||||
end
|
||||
|
||||
def volumes
|
||||
requires :id
|
||||
connection.volumes(:server => self)
|
||||
service.volumes(:server => self)
|
||||
end
|
||||
|
||||
#I tried to call it monitoring= and be smart with attributes[]
|
||||
|
@ -231,9 +231,9 @@ module Fog
|
|||
if persisted?
|
||||
case new_monitor
|
||||
when true
|
||||
response = connection.monitor_instances(identity)
|
||||
response = service.monitor_instances(identity)
|
||||
when false
|
||||
response = connection.unmonitor_instances(identity)
|
||||
response = service.unmonitor_instances(identity)
|
||||
else
|
||||
raise ArgumentError.new("only Boolean allowed here")
|
||||
end
|
||||
|
|
|
@ -61,7 +61,7 @@ module Fog
|
|||
filters = {'instance-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_instances(filters).body
|
||||
data = service.describe_instances(filters).body
|
||||
load(
|
||||
data['reservationSet'].map do |reservation|
|
||||
reservation['instancesSet'].map do |instance|
|
||||
|
@ -72,13 +72,13 @@ module Fog
|
|||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
server = connection.servers.new(new_attributes)
|
||||
server = service.servers.new(new_attributes)
|
||||
|
||||
unless new_attributes[:key_name]
|
||||
# first or create fog_#{credential} keypair
|
||||
name = Fog.respond_to?(:credential) && Fog.credential || :default
|
||||
unless server.key_pair = connection.key_pairs.get("fog_#{name}")
|
||||
server.key_pair = connection.key_pairs.create(
|
||||
unless server.key_pair = service.key_pairs.get("fog_#{name}")
|
||||
server.key_pair = service.key_pairs.create(
|
||||
:name => "fog_#{name}",
|
||||
:public_key => server.public_key
|
||||
)
|
||||
|
@ -86,7 +86,7 @@ module Fog
|
|||
end
|
||||
|
||||
# make sure port 22 is open in the first security group
|
||||
security_group = connection.security_groups.get(server.groups.first)
|
||||
security_group = service.security_groups.get(server.groups.first)
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
|
@ -145,7 +145,7 @@ module Fog
|
|||
|
||||
def get(server_id)
|
||||
if server_id
|
||||
self.class.new(:connection => connection).all('instance-id' => server_id).first
|
||||
self.class.new(:service => service).all('instance-id' => server_id).first
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_snapshot(id)
|
||||
service.delete_snapshot(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Fog
|
|||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
requires :volume_id
|
||||
|
||||
data = connection.create_snapshot(volume_id, description).body
|
||||
data = service.create_snapshot(volume_id, description).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
@ -40,7 +40,7 @@ module Fog
|
|||
|
||||
def volume
|
||||
requires :id
|
||||
connection.describe_volumes(volume_id)
|
||||
service.describe_volumes(volume_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -23,17 +23,17 @@ module Fog
|
|||
filters = {'snapshot-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_snapshots(filters.merge!(options)).body
|
||||
data = service.describe_snapshots(filters.merge!(options)).body
|
||||
load(data['snapshotSet'])
|
||||
if volume
|
||||
self.replace(self.select {|snapshot| snapshot.volume_id == volume.id})
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def get(snapshot_id)
|
||||
if snapshot_id
|
||||
self.class.new(:connection => connection).all('snapshot-id' => snapshot_id).first
|
||||
self.class.new(:service => service).all('snapshot-id' => snapshot_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'fog/compute/models/server'
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
|
||||
class SpotRequest < Fog::Compute::Server
|
||||
|
||||
identity :id, :aliases => 'spotInstanceRequestId'
|
||||
|
@ -37,7 +37,6 @@ module Fog
|
|||
|
||||
attr_writer :iam_instance_profile_name, :iam_instance_profile_arn
|
||||
|
||||
|
||||
def initialize(attributes={})
|
||||
self.groups ||= ["default"]
|
||||
self.flavor_id ||= 't1.micro'
|
||||
|
@ -66,14 +65,14 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.cancel_spot_instance_requests(id)
|
||||
service.cancel_spot_instance_requests(id)
|
||||
true
|
||||
end
|
||||
|
||||
def key_pair
|
||||
requires :key_name
|
||||
|
||||
connection.key_pairs.all(key_name).first
|
||||
service.key_pairs.all(key_name).first
|
||||
end
|
||||
|
||||
def key_pair=(new_keypair)
|
||||
|
@ -104,7 +103,7 @@ module Fog
|
|||
'ValidFrom' => valid_from,
|
||||
'ValidUntil' => valid_until }
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
|
||||
# If subnet is defined then this is a Virtual Private Cloud.
|
||||
# subnet & security group cannot co-exist. Attempting to specify
|
||||
# both subnet and groups will cause an error. Instead please make
|
||||
|
@ -115,7 +114,7 @@ module Fog
|
|||
options.delete('LaunchSpecification.SubnetId')
|
||||
end
|
||||
|
||||
data = connection.request_spot_instances(image_id, flavor_id, price, options).body
|
||||
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
|
||||
|
@ -128,4 +127,4 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,9 @@ module Fog
|
|||
module Compute
|
||||
class AWS
|
||||
class SpotRequests < Fog::Collection
|
||||
|
||||
|
||||
attribute :filters
|
||||
|
||||
|
||||
model Fog::Compute::AWS::SpotRequest
|
||||
|
||||
def initialize(attributes)
|
||||
|
@ -21,7 +21,7 @@ module Fog
|
|||
filters = {'spot-instance-request-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_spot_instance_requests(filters).body
|
||||
data = service.describe_spot_instance_requests(filters).body
|
||||
load(
|
||||
data['spotInstanceRequestSet'].map do |spot_instance_request|
|
||||
spot_instance_request['LaunchSpecification.Placement.AvailabilityZone'] = spot_instance_request['launchedAvailabilityZone']
|
||||
|
@ -29,19 +29,19 @@ module Fog
|
|||
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
|
||||
spot_instance_request
|
||||
end.flatten
|
||||
)
|
||||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
spot_request = connection.spot_requests.new(new_attributes)
|
||||
spot_request = service.spot_requests.new(new_attributes)
|
||||
|
||||
unless new_attributes[:key_name]
|
||||
# first or create fog_#{credential} keypair
|
||||
name = Fog.respond_to?(:credential) && Fog.credential || :default
|
||||
unless spot_request.key_pair = connection.key_pairs.get("fog_#{name}")
|
||||
spot_request.key_pair = connection.key_pairs.create(
|
||||
unless spot_request.key_pair = service.key_pairs.get("fog_#{name}")
|
||||
spot_request.key_pair = service.key_pairs.create(
|
||||
:name => "fog_#{name}",
|
||||
:public_key => spot_request.public_key
|
||||
)
|
||||
|
@ -49,7 +49,7 @@ module Fog
|
|||
end
|
||||
|
||||
# make sure port 22 is open in the first security group
|
||||
security_group = connection.security_groups.get(spot_request.groups.first)
|
||||
security_group = service.security_groups.get(spot_request.groups.first)
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
|
@ -62,10 +62,10 @@ module Fog
|
|||
|
||||
spot_request.save
|
||||
Fog.wait_for { spot_request.reload.ready? rescue nil }
|
||||
server = connection.servers.get(spot_request.instance_id)
|
||||
server = service.servers.get(spot_request.instance_id)
|
||||
if spot_request.tags
|
||||
for key, value in spot_request.tags
|
||||
connection.tags.create(
|
||||
service.tags.create(
|
||||
:key => key,
|
||||
:resource_id => spot_request.instance_id,
|
||||
:value => value
|
||||
|
@ -79,7 +79,7 @@ module Fog
|
|||
|
||||
def get(spot_request_id)
|
||||
if spot_request_id
|
||||
self.class.new(:connection => connection).all('spot-instance-request-id' => spot_request_id).first
|
||||
self.class.new(:service => service).all('spot-instance-request-id' => spot_request_id).first
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
|||
class Subnet < Fog::Model
|
||||
|
||||
identity :subnet_id, :aliases => 'subnetId'
|
||||
attribute :state
|
||||
attribute :state
|
||||
attribute :vpc_id, :aliases => 'vpcId'
|
||||
attribute :cidr_block, :aliases => 'cidrBlock'
|
||||
attribute :available_ip_address_count, :aliases => 'availableIpAddressCount'
|
||||
|
@ -27,7 +27,7 @@ module Fog
|
|||
def destroy
|
||||
requires :subnet_id
|
||||
|
||||
connection.delete_subnet(subnet_id)
|
||||
service.delete_subnet(subnet_id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ module Fog
|
|||
|
||||
def save
|
||||
requires :vpc_id, :cidr_block
|
||||
data = connection.create_subnet(vpc_id, cidr_block).body['subnetSet'].first
|
||||
data = service.create_subnet(vpc_id, cidr_block).body['subnetSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -63,7 +63,7 @@ module Fog
|
|||
filters = {'subnet-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_subnets(filters).body
|
||||
data = service.describe_subnets(filters).body
|
||||
load(data['subnetSet'])
|
||||
end
|
||||
|
||||
|
@ -88,7 +88,7 @@ module Fog
|
|||
|
||||
def get(subnet_id)
|
||||
if subnet_id
|
||||
self.class.new(:connection => connection).all('subnet-id' => subnet_id).first
|
||||
self.class.new(:service => service).all('subnet-id' => subnet_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :key, :resource_id
|
||||
connection.delete_tags(resource_id, key => value)
|
||||
service.delete_tags(resource_id, key => value)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :key, :resource_id
|
||||
connection.create_tags(resource_id, key => value)
|
||||
service.create_tags(resource_id, key => value)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ module Fog
|
|||
|
||||
def all(filters = filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_tags(filters).body
|
||||
data = service.describe_tags(filters).body
|
||||
load(data['tagSet'])
|
||||
end
|
||||
|
||||
|
||||
def get(key)
|
||||
if key
|
||||
self.class.new(:connection => connection).all('key' => key)
|
||||
self.class.new(:service => service).all('key' => key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_volume(id)
|
||||
service.delete_volume(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ module Fog
|
|||
requires :iops
|
||||
end
|
||||
|
||||
data = connection.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops).body
|
||||
data = service.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
|
||||
|
@ -55,7 +55,7 @@ module Fog
|
|||
# expect eventual consistency
|
||||
Fog.wait_for { self.reload rescue nil }
|
||||
for key, value in (self.tags = tags)
|
||||
connection.tags.create(
|
||||
service.tags.create(
|
||||
:key => key,
|
||||
:resource_id => self.identity,
|
||||
:value => value
|
||||
|
@ -71,7 +71,7 @@ module Fog
|
|||
|
||||
def server
|
||||
requires :server_id
|
||||
connection.servers('instance-id' => server_id)
|
||||
service.servers('instance-id' => server_id)
|
||||
end
|
||||
|
||||
def server=(new_server)
|
||||
|
@ -84,12 +84,12 @@ module Fog
|
|||
|
||||
def snapshots
|
||||
requires :id
|
||||
connection.snapshots(:volume => self)
|
||||
service.snapshots(:volume => self)
|
||||
end
|
||||
|
||||
def snapshot(description)
|
||||
requires :id
|
||||
connection.create_snapshot(id, description)
|
||||
service.create_snapshot(id, description)
|
||||
end
|
||||
|
||||
def force_detach
|
||||
|
@ -110,7 +110,7 @@ module Fog
|
|||
requires :device
|
||||
@server = nil
|
||||
self.server_id = new_server.id
|
||||
connection.attach_volume(server_id, id, device)
|
||||
service.attach_volume(server_id, id, device)
|
||||
reload
|
||||
end
|
||||
end
|
||||
|
@ -119,7 +119,7 @@ module Fog
|
|||
@server = nil
|
||||
self.server_id = nil
|
||||
if persisted?
|
||||
connection.detach_volume(id, 'Force' => force)
|
||||
service.detach_volume(id, 'Force' => force)
|
||||
reload
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ module Fog
|
|||
filters = {'volume-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_volumes(filters).body
|
||||
data = service.describe_volumes(filters).body
|
||||
load(data['volumeSet'])
|
||||
if server
|
||||
self.replace(self.select {|volume| volume.server_id == server.id})
|
||||
|
@ -102,7 +102,7 @@ module Fog
|
|||
|
||||
def get(volume_id)
|
||||
if volume_id
|
||||
self.class.new(:connection => connection).all('volume-id' => volume_id).first
|
||||
self.class.new(:service => service).all('volume-id' => volume_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module Fog
|
|||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_vpc(id)
|
||||
service.delete_vpc(id)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -50,7 +50,7 @@ module Fog
|
|||
def save
|
||||
requires :cidr_block
|
||||
|
||||
data = connection.create_vpc(cidr_block).body['vpcSet'].first
|
||||
data = service.create_vpc(cidr_block).body['vpcSet'].first
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
|
|
@ -61,7 +61,7 @@ module Fog
|
|||
filters = {'vpc-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_vpcs(filters).body
|
||||
data = service.describe_vpcs(filters).body
|
||||
load(data['vpcSet'])
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,7 @@ module Fog
|
|||
|
||||
def get(vpc_id)
|
||||
if vpc_id
|
||||
self.class.new(:connection => connection).all('vpc-id' => vpc_id).first
|
||||
self.class.new(:service => service).all('vpc-id' => vpc_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue