From bc26c4e43314da730591d3a7863e1243b602b363 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Sat, 22 Dec 2012 23:24:03 +0000 Subject: [PATCH] [rackspace] Updates reference to service --- .../models/block_storage/snapshot.rb | 4 +- .../models/block_storage/snapshots.rb | 4 +- .../rackspace/models/block_storage/volume.rb | 10 ++-- .../models/block_storage/volume_types.rb | 6 +-- .../rackspace/models/block_storage/volumes.rb | 4 +- lib/fog/rackspace/models/compute/flavors.rb | 4 +- lib/fog/rackspace/models/compute/image.rb | 4 +- lib/fog/rackspace/models/compute/images.rb | 4 +- lib/fog/rackspace/models/compute/server.rb | 12 ++--- lib/fog/rackspace/models/compute/servers.rb | 4 +- .../rackspace/models/compute_v2/attachment.rb | 4 +- .../models/compute_v2/attachments.rb | 4 +- .../rackspace/models/compute_v2/flavors.rb | 4 +- lib/fog/rackspace/models/compute_v2/image.rb | 2 +- lib/fog/rackspace/models/compute_v2/images.rb | 4 +- lib/fog/rackspace/models/compute_v2/server.rb | 36 +++++++------- .../rackspace/models/compute_v2/servers.rb | 4 +- .../rackspace/models/databases/database.rb | 4 +- .../rackspace/models/databases/databases.rb | 2 +- lib/fog/rackspace/models/databases/flavors.rb | 4 +- .../rackspace/models/databases/instance.rb | 20 ++++---- .../rackspace/models/databases/instances.rb | 4 +- lib/fog/rackspace/models/databases/user.rb | 4 +- lib/fog/rackspace/models/databases/users.rb | 2 +- lib/fog/rackspace/models/dns/callback.rb | 2 +- lib/fog/rackspace/models/dns/record.rb | 14 +++--- lib/fog/rackspace/models/dns/records.rb | 4 +- lib/fog/rackspace/models/dns/zone.rb | 8 ++-- lib/fog/rackspace/models/dns/zones.rb | 4 +- .../rackspace/models/identity/credentials.rb | 2 +- lib/fog/rackspace/models/identity/roles.rb | 2 +- lib/fog/rackspace/models/identity/tenants.rb | 2 +- lib/fog/rackspace/models/identity/user.rb | 10 ++-- lib/fog/rackspace/models/identity/users.rb | 6 +-- .../models/load_balancers/access_rule.rb | 6 +-- .../models/load_balancers/access_rules.rb | 2 +- .../models/load_balancers/load_balancer.rb | 48 +++++++++---------- .../models/load_balancers/load_balancers.rb | 4 +- .../rackspace/models/load_balancers/node.rb | 6 +-- .../rackspace/models/load_balancers/nodes.rb | 4 +- .../models/load_balancers/virtual_ip.rb | 4 +- .../models/load_balancers/virtual_ips.rb | 2 +- .../rackspace/models/storage/directories.rb | 4 +- lib/fog/rackspace/models/storage/directory.rb | 24 +++++----- lib/fog/rackspace/models/storage/file.rb | 10 ++-- lib/fog/rackspace/models/storage/files.rb | 4 +- 46 files changed, 163 insertions(+), 163 deletions(-) diff --git a/lib/fog/rackspace/models/block_storage/snapshot.rb b/lib/fog/rackspace/models/block_storage/snapshot.rb index 2d3af9bd5..d98f3a550 100644 --- a/lib/fog/rackspace/models/block_storage/snapshot.rb +++ b/lib/fog/rackspace/models/block_storage/snapshot.rb @@ -27,7 +27,7 @@ module Fog def save(force = false) requires :volume_id raise IdentifierTaken.new('Resaving may cause a duplicate snapshot to be created') if persisted? - data = connection.create_snapshot(volume_id, { + data = service.create_snapshot(volume_id, { :display_name => display_name, :display_description => display_description, :force => force @@ -38,7 +38,7 @@ module Fog def destroy requires :identity - connection.delete_snapshot(identity) + service.delete_snapshot(identity) true end end diff --git a/lib/fog/rackspace/models/block_storage/snapshots.rb b/lib/fog/rackspace/models/block_storage/snapshots.rb index b25d99bc3..2e2385210 100644 --- a/lib/fog/rackspace/models/block_storage/snapshots.rb +++ b/lib/fog/rackspace/models/block_storage/snapshots.rb @@ -9,12 +9,12 @@ module Fog model Fog::Rackspace::BlockStorage::Snapshot def all - data = connection.list_snapshots.body['snapshots'] + data = service.list_snapshots.body['snapshots'] load(data) end def get(snapshot_id) - data = connection.get_snapshot(snapshot_id).body['snapshot'] + data = service.get_snapshot(snapshot_id).body['snapshot'] new(data) rescue Fog::Rackspace::BlockStorage::NotFound nil diff --git a/lib/fog/rackspace/models/block_storage/volume.rb b/lib/fog/rackspace/models/block_storage/volume.rb index 1e11dcb51..5398c507a 100644 --- a/lib/fog/rackspace/models/block_storage/volume.rb +++ b/lib/fog/rackspace/models/block_storage/volume.rb @@ -32,18 +32,18 @@ module Fog end def snapshots - connection.snapshots.select { |s| s.volume_id == identity } + service.snapshots.select { |s| s.volume_id == identity } end - + def create_snapshot(options={}) requires :identity - connection.snapshots.create(options.merge(:volume_id => identity)) + service.snapshots.create(options.merge(:volume_id => identity)) end def save requires :size raise IdentifierTaken.new('Resaving may cause a duplicate volume to be created') if persisted? - data = connection.create_volume(size, { + data = service.create_volume(size, { :display_name => display_name, :display_description => display_description, :volume_type => volume_type, @@ -55,7 +55,7 @@ module Fog def destroy requires :identity - connection.delete_volume(identity) + service.delete_volume(identity) true end end diff --git a/lib/fog/rackspace/models/block_storage/volume_types.rb b/lib/fog/rackspace/models/block_storage/volume_types.rb index ca1dfa5aa..fb5290d0d 100644 --- a/lib/fog/rackspace/models/block_storage/volume_types.rb +++ b/lib/fog/rackspace/models/block_storage/volume_types.rb @@ -9,16 +9,16 @@ module Fog model Fog::Rackspace::BlockStorage::VolumeType def all - data = connection.list_volume_types.body['volume_types'] + data = service.list_volume_types.body['volume_types'] load(data) end def get(volume_type_id) - data = connection.get_volume_type(volume_type_id).body['volume_type'] + data = service.get_volume_type(volume_type_id).body['volume_type'] new(data) rescue Fog::Rackspace::BlockStorage::NotFound nil - end + end end end end diff --git a/lib/fog/rackspace/models/block_storage/volumes.rb b/lib/fog/rackspace/models/block_storage/volumes.rb index 0a246d071..d8c3c29ad 100644 --- a/lib/fog/rackspace/models/block_storage/volumes.rb +++ b/lib/fog/rackspace/models/block_storage/volumes.rb @@ -9,12 +9,12 @@ module Fog model Fog::Rackspace::BlockStorage::Volume def all - data = connection.list_volumes.body['volumes'] + data = service.list_volumes.body['volumes'] load(data) end def get(volume_id) - data = connection.get_volume(volume_id).body['volume'] + data = service.get_volume(volume_id).body['volume'] new(data) rescue Fog::Rackspace::BlockStorage::NotFound nil diff --git a/lib/fog/rackspace/models/compute/flavors.rb b/lib/fog/rackspace/models/compute/flavors.rb index e7b72242c..301a0bca7 100644 --- a/lib/fog/rackspace/models/compute/flavors.rb +++ b/lib/fog/rackspace/models/compute/flavors.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Rackspace::Flavor def all - data = connection.list_flavors_detail.body['flavors'] + data = service.list_flavors_detail.body['flavors'] load(data) end def get(flavor_id) - data = connection.get_flavor_details(flavor_id).body['flavor'] + data = service.get_flavor_details(flavor_id).body['flavor'] new(data) rescue Fog::Compute::Rackspace::NotFound nil diff --git a/lib/fog/rackspace/models/compute/image.rb b/lib/fog/rackspace/models/compute/image.rb index dbe64d947..1e423b84e 100644 --- a/lib/fog/rackspace/models/compute/image.rb +++ b/lib/fog/rackspace/models/compute/image.rb @@ -24,7 +24,7 @@ module Fog def destroy requires :id - connection.delete_image(id) + service.delete_image(id) true end @@ -36,7 +36,7 @@ module Fog raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :server_id - data = connection.create_image(server_id, 'name' => name) + data = service.create_image(server_id, 'name' => name) merge_attributes(data.body['image']) true end diff --git a/lib/fog/rackspace/models/compute/images.rb b/lib/fog/rackspace/models/compute/images.rb index d00862fa9..e2c18cc55 100644 --- a/lib/fog/rackspace/models/compute/images.rb +++ b/lib/fog/rackspace/models/compute/images.rb @@ -12,7 +12,7 @@ module Fog attribute :server def all - data = connection.list_images_detail.body['images'] + data = service.list_images_detail.body['images'] models = load(data) if server self.replace(self.select {|image| image.server_id == server.id}) @@ -22,7 +22,7 @@ module Fog end def get(image_id) - data = connection.get_image_details(image_id).body['image'] + data = service.get_image_details(image_id).body['image'] new(data) rescue Fog::Compute::Rackspace::NotFound nil diff --git a/lib/fog/rackspace/models/compute/server.rb b/lib/fog/rackspace/models/compute/server.rb index 1d61bcba1..e42efe373 100644 --- a/lib/fog/rackspace/models/compute/server.rb +++ b/lib/fog/rackspace/models/compute/server.rb @@ -28,23 +28,23 @@ module Fog def destroy requires :id - connection.delete_server(id) + service.delete_server(id) true end def flavor requires :flavor_id - connection.flavors.get(flavor_id) + service.flavors.get(flavor_id) end def image requires :image_id - connection.images.get(image_id) + service.images.get(image_id) end def images requires :id - connection.images(:server => self) + service.images(:server => self) end def private_ip_address @@ -61,7 +61,7 @@ module Fog def reboot(type = 'SOFT') requires :id - connection.reboot_server(id, type) + service.reboot_server(id, type) true end @@ -74,7 +74,7 @@ module Fog 'personality' => personality } options = options.reject {|key, value| value.nil?} - data = connection.create_server(flavor_id, image_id, options) + data = service.create_server(flavor_id, image_id, options) merge_attributes(data.body['server']) true end diff --git a/lib/fog/rackspace/models/compute/servers.rb b/lib/fog/rackspace/models/compute/servers.rb index 4214913cc..907fff422 100644 --- a/lib/fog/rackspace/models/compute/servers.rb +++ b/lib/fog/rackspace/models/compute/servers.rb @@ -10,7 +10,7 @@ module Fog model Fog::Compute::Rackspace::Server def all - data = connection.list_servers_detail.body['servers'] + data = service.list_servers_detail.body['servers'] load(data) end @@ -22,7 +22,7 @@ module Fog end def get(server_id) - if server = connection.get_server_details(server_id).body['server'] + if server = service.get_server_details(server_id).body['server'] new(server) end rescue Fog::Compute::Rackspace::NotFound diff --git a/lib/fog/rackspace/models/compute_v2/attachment.rb b/lib/fog/rackspace/models/compute_v2/attachment.rb index a6a3193da..d5d72d941 100644 --- a/lib/fog/rackspace/models/compute_v2/attachment.rb +++ b/lib/fog/rackspace/models/compute_v2/attachment.rb @@ -12,14 +12,14 @@ module Fog def save requires :server, :identity, :device - data = connection.attach_volume(server.identity, identity, device) + data = service.attach_volume(server.identity, identity, device) merge_attributes(data.body['volumeAttachment']) true end def destroy requires :server, :identity - connection.delete_attachment(server.identity, identity) + service.delete_attachment(server.identity, identity) true end diff --git a/lib/fog/rackspace/models/compute_v2/attachments.rb b/lib/fog/rackspace/models/compute_v2/attachments.rb index 88eb0297e..f98d3ff4a 100644 --- a/lib/fog/rackspace/models/compute_v2/attachments.rb +++ b/lib/fog/rackspace/models/compute_v2/attachments.rb @@ -11,12 +11,12 @@ module Fog attr_accessor :server def all - data = connection.list_attachments(server.id).body['volumeAttachments'] + data = service.list_attachments(server.id).body['volumeAttachments'] load(data) end def get(volume_id) - data = connection.get_attachment(server.id, volume_id).body['volumeAttachment'] + data = service.get_attachment(server.id, volume_id).body['volumeAttachment'] data && new(data) end end diff --git a/lib/fog/rackspace/models/compute_v2/flavors.rb b/lib/fog/rackspace/models/compute_v2/flavors.rb index fd684caf5..bb56ae439 100644 --- a/lib/fog/rackspace/models/compute_v2/flavors.rb +++ b/lib/fog/rackspace/models/compute_v2/flavors.rb @@ -9,12 +9,12 @@ module Fog model Fog::Compute::RackspaceV2::Flavor def all - data = connection.list_flavors.body['flavors'] + data = service.list_flavors.body['flavors'] load(data) end def get(flavor_id) - data = connection.get_flavor(flavor_id).body['flavor'] + data = service.get_flavor(flavor_id).body['flavor'] new(data) rescue Fog::Compute::RackspaceV2::NotFound nil diff --git a/lib/fog/rackspace/models/compute_v2/image.rb b/lib/fog/rackspace/models/compute_v2/image.rb index 1e30727d7..43fee47bd 100644 --- a/lib/fog/rackspace/models/compute_v2/image.rb +++ b/lib/fog/rackspace/models/compute_v2/image.rb @@ -31,7 +31,7 @@ module Fog def destroy requires :identity - connection.delete_image(identity) + service.delete_image(identity) end end end diff --git a/lib/fog/rackspace/models/compute_v2/images.rb b/lib/fog/rackspace/models/compute_v2/images.rb index 87586e546..650be6a83 100644 --- a/lib/fog/rackspace/models/compute_v2/images.rb +++ b/lib/fog/rackspace/models/compute_v2/images.rb @@ -9,12 +9,12 @@ module Fog model Fog::Compute::RackspaceV2::Image def all - data = connection.list_images.body['images'] + data = service.list_images.body['images'] load(data) end def get(image_id) - data = connection.get_image(image_id).body['image'] + data = service.get_image(image_id).body['image'] new(data) rescue Fog::Compute::RackspaceV2::NotFound nil diff --git a/lib/fog/rackspace/models/compute_v2/server.rb b/lib/fog/rackspace/models/compute_v2/server.rb index 49db837d4..9197ae314 100644 --- a/lib/fog/rackspace/models/compute_v2/server.rb +++ b/lib/fog/rackspace/models/compute_v2/server.rb @@ -41,7 +41,7 @@ module Fog attribute :addresses attribute :flavor_id, :aliases => 'flavor', :squash => 'id' attribute :image_id, :aliases => 'image', :squash => 'id' - + attr_reader :password def save @@ -61,49 +61,49 @@ module Fog options[:metadata] = metadata unless metadata.nil? options[:personality] = personality unless personality.nil? - data = connection.create_server(name, image_id, flavor_id, 1, 1, options) + data = service.create_server(name, image_id, flavor_id, 1, 1, options) merge_attributes(data.body['server']) true end def update requires :identity, :name - data = connection.update_server(identity, name) + data = service.update_server(identity, name) merge_attributes(data.body['server']) true end def destroy requires :identity - connection.delete_server(identity) + service.delete_server(identity) true end def flavor requires :flavor_id - @flavor ||= connection.flavors.get(flavor_id) + @flavor ||= service.flavors.get(flavor_id) end def image requires :image_id - @image ||= connection.images.get(image_id) + @image ||= service.images.get(image_id) end - + def create_image(name, options = {}) requires :identity - response = connection.create_image(identity, name, options) - response.headers["Location"].match(/\/([^\/]+$)/)[1] rescue nil + response = service.create_image(identity, name, options) + response.headers["Location"].match(/\/([^\/]+$)/)[1] rescue nil end def attachments @attachments ||= begin Fog::Compute::RackspaceV2::Attachments.new({ - :connection => connection, + :service => service, :server => self }) end end - + def private_ip_address addresses['private'].select{|a| a["version"] == 4}[0]["addr"] end @@ -118,45 +118,45 @@ module Fog def reboot(type = 'SOFT') requires :identity - connection.reboot_server(identity, type) + service.reboot_server(identity, type) self.state = type == 'SOFT' ? REBOOT : HARD_REBOOT true end def resize(flavor_id) requires :identity - connection.resize_server(identity, flavor_id) + service.resize_server(identity, flavor_id) self.state = RESIZE true end def rebuild(image_id) requires :identity - connection.rebuild_server(identity, image_id) + service.rebuild_server(identity, image_id) self.state = REBUILD true end def confirm_resize requires :identity - connection.confirm_resize_server(identity) + service.confirm_resize_server(identity) true end def revert_resize requires :identity - connection.revert_resize_server(identity) + service.revert_resize_server(identity) true end def change_admin_password(password) requires :identity - connection.change_server_password(identity, password) + service.change_server_password(identity, password) self.state = PASSWORD @password = password true end - + def setup(credentials = {}) requires :public_ip_address, :identity, :public_key, :username Fog::SSH.new(public_ip_address, username, credentials).run([ diff --git a/lib/fog/rackspace/models/compute_v2/servers.rb b/lib/fog/rackspace/models/compute_v2/servers.rb index ad4288e45..40d7c9cd1 100644 --- a/lib/fog/rackspace/models/compute_v2/servers.rb +++ b/lib/fog/rackspace/models/compute_v2/servers.rb @@ -10,7 +10,7 @@ module Fog model Fog::Compute::RackspaceV2::Server def all - data = connection.list_servers.body['servers'] + data = service.list_servers.body['servers'] load(data) end @@ -22,7 +22,7 @@ module Fog end def get(server_id) - data = connection.get_server(server_id).body['server'] + data = service.get_server(server_id).body['server'] new(data) rescue Fog::Compute::RackspaceV2::NotFound nil diff --git a/lib/fog/rackspace/models/databases/database.rb b/lib/fog/rackspace/models/databases/database.rb index 2a6439a47..a9f277b9f 100644 --- a/lib/fog/rackspace/models/databases/database.rb +++ b/lib/fog/rackspace/models/databases/database.rb @@ -11,13 +11,13 @@ module Fog def save requires :identity, :instance - connection.create_database(instance.identity, identity, :character_set => character_set, :collate => collate) + service.create_database(instance.identity, identity, :character_set => character_set, :collate => collate) true end def destroy requires :identity, :instance - connection.delete_database(instance.identity, identity) + service.delete_database(instance.identity, identity) true end diff --git a/lib/fog/rackspace/models/databases/databases.rb b/lib/fog/rackspace/models/databases/databases.rb index 98f5e78d6..a3cc0760b 100644 --- a/lib/fog/rackspace/models/databases/databases.rb +++ b/lib/fog/rackspace/models/databases/databases.rb @@ -23,7 +23,7 @@ module Fog def retrieve_databases requires :instance - data = connection.list_databases(instance.id).body['databases'] + data = service.list_databases(instance.id).body['databases'] end end end diff --git a/lib/fog/rackspace/models/databases/flavors.rb b/lib/fog/rackspace/models/databases/flavors.rb index 6f2a61409..6cd938564 100644 --- a/lib/fog/rackspace/models/databases/flavors.rb +++ b/lib/fog/rackspace/models/databases/flavors.rb @@ -9,12 +9,12 @@ module Fog model Fog::Rackspace::Databases::Flavor def all - data = connection.list_flavors.body['flavors'] + data = service.list_flavors.body['flavors'] load(data) end def get(flavor_id) - data = connection.get_flavor(flavor_id).body['flavor'] + data = service.get_flavor(flavor_id).body['flavor'] new(data) rescue Fog::Rackspace::Databases::NotFound nil diff --git a/lib/fog/rackspace/models/databases/instance.rb b/lib/fog/rackspace/models/databases/instance.rb index d7f10940b..f10575a60 100644 --- a/lib/fog/rackspace/models/databases/instance.rb +++ b/lib/fog/rackspace/models/databases/instance.rb @@ -27,26 +27,26 @@ module Fog def save requires :name, :flavor_id, :volume_size - data = connection.create_instance(name, flavor_id, volume_size) + data = service.create_instance(name, flavor_id, volume_size) merge_attributes(data.body['instance']) true end def destroy requires :identity - connection.delete_instance(identity) + service.delete_instance(identity) true end def flavor requires :flavor_id - @flavor ||= connection.flavors.get(flavor_id) + @flavor ||= service.flavors.get(flavor_id) end def databases @databases ||= begin Fog::Rackspace::Databases::Databases.new({ - :connection => connection, + :service => service, :instance => self }) end @@ -55,7 +55,7 @@ module Fog def users @users ||= begin Fog::Rackspace::Databases::Users.new({ - :connection => connection, + :service => service, :instance => self }) end @@ -67,12 +67,12 @@ module Fog def root_user_enabled? requires :identity - connection.check_root_user(identity).body['rootEnabled'] + service.check_root_user(identity).body['rootEnabled'] end def enable_root_user requires :identity - data = connection.enable_root_user(identity).body['user'] + data = service.enable_root_user(identity).body['user'] @root_user = data['name'] @root_password = data['password'] true @@ -80,21 +80,21 @@ module Fog def restart requires :identity - connection.restart_instance(identity) + service.restart_instance(identity) self.state = REBOOT true end def resize(flavor_id) requires :identity - connection.resize_instance(identity, flavor_id) + service.resize_instance(identity, flavor_id) self.state = RESIZE true end def resize_volume(volume_size) requires :identity - connection.resize_instance_volume(identity, volume_size) + service.resize_instance_volume(identity, volume_size) self.state = RESIZE true end diff --git a/lib/fog/rackspace/models/databases/instances.rb b/lib/fog/rackspace/models/databases/instances.rb index f146b91d3..31a75d5d1 100644 --- a/lib/fog/rackspace/models/databases/instances.rb +++ b/lib/fog/rackspace/models/databases/instances.rb @@ -9,12 +9,12 @@ module Fog model Fog::Rackspace::Databases::Instance def all - data = connection.list_instances.body['instances'] + data = service.list_instances.body['instances'] load(data) end def get(instance_id) - data = connection.get_instance(instance_id).body['instance'] + data = service.get_instance(instance_id).body['instance'] new(data) rescue Fog::Rackspace::Databases::NotFound nil diff --git a/lib/fog/rackspace/models/databases/user.rb b/lib/fog/rackspace/models/databases/user.rb index d39bed39c..f46744782 100644 --- a/lib/fog/rackspace/models/databases/user.rb +++ b/lib/fog/rackspace/models/databases/user.rb @@ -11,13 +11,13 @@ module Fog def save requires :identity, :instance, :password - connection.create_user(instance.identity, identity, password, :databases => databases) + service.create_user(instance.identity, identity, password, :databases => databases) true end def destroy requires :identity, :instance - connection.delete_user(instance.identity, identity) + service.delete_user(instance.identity, identity) true end diff --git a/lib/fog/rackspace/models/databases/users.rb b/lib/fog/rackspace/models/databases/users.rb index 7b72b5f66..ad37777a3 100644 --- a/lib/fog/rackspace/models/databases/users.rb +++ b/lib/fog/rackspace/models/databases/users.rb @@ -23,7 +23,7 @@ module Fog def retrieve_users requires :instance - data = connection.list_users(instance.identity).body['users'] + data = service.list_users(instance.identity).body['users'] end end end diff --git a/lib/fog/rackspace/models/dns/callback.rb b/lib/fog/rackspace/models/dns/callback.rb index 93a17b053..33c0c536f 100644 --- a/lib/fog/rackspace/models/dns/callback.rb +++ b/lib/fog/rackspace/models/dns/callback.rb @@ -10,7 +10,7 @@ module Fog retries = 5 response = nil Fog.wait_for(timeout, interval) do - response = connection.callback job_id + response = service.callback job_id if response.body['status'] == 'COMPLETED' true elsif response.body['status'] == 'ERROR' diff --git a/lib/fog/rackspace/models/dns/record.rb b/lib/fog/rackspace/models/dns/record.rb index 8e9b80a7c..dafa462cf 100644 --- a/lib/fog/rackspace/models/dns/record.rb +++ b/lib/fog/rackspace/models/dns/record.rb @@ -24,7 +24,7 @@ module Fog def destroy requires :zone, :identity - wait_for_job connection.remove_record(@zone.identity, identity).body['jobId'] + wait_for_job service.remove_record(@zone.identity, identity).body['jobId'] true end @@ -59,20 +59,20 @@ module Fog options[:priority] = priority end - response = wait_for_job connection.add_records(@zone.identity, [options]).body['jobId'] + response = wait_for_job service.add_records(@zone.identity, [options]).body['jobId'] - matching_record = response.body['response']['records'].find do |record| + matching_record = response.body['response']['records'].find do |record| if ['A', 'AAAA'].include?(self.type.upcase) # If this is an A or AAAA record, match by normalized IP address value. (record['name'] == self.name) && (record['type'] == self.type) && (IPAddr.new(record['data']) == IPAddr.new(self.value)) else # Other record types are matched by the raw value. (record['name'] == self.name) && (record['type'] == self.type) && (record['data'] == self.value) - end + end end - + merge_attributes(matching_record) - + true end @@ -86,7 +86,7 @@ module Fog options[:priority] = priority if priority options[:ttl] = ttl if ttl - wait_for_job connection.modify_record(@zone.identity, identity, options).body['jobId'] + wait_for_job service.modify_record(@zone.identity, identity, options).body['jobId'] true end diff --git a/lib/fog/rackspace/models/dns/records.rb b/lib/fog/rackspace/models/dns/records.rb index eccfc9eb6..f41dc1962 100644 --- a/lib/fog/rackspace/models/dns/records.rb +++ b/lib/fog/rackspace/models/dns/records.rb @@ -13,13 +13,13 @@ module Fog def all requires :zone - data = connection.list_records(zone.identity) + data = service.list_records(zone.identity) load(data.body['records']) end def get(record_id) requires :zone - data = connection.list_record_details(zone.identity, record_id).body + data = service.list_record_details(zone.identity, record_id).body new(data) #nil or empty string will trigger an argument error rescue ArgumentError diff --git a/lib/fog/rackspace/models/dns/zone.rb b/lib/fog/rackspace/models/dns/zone.rb index 928fc7a09..a1a0c8934 100644 --- a/lib/fog/rackspace/models/dns/zone.rb +++ b/lib/fog/rackspace/models/dns/zone.rb @@ -20,7 +20,7 @@ module Fog attribute :comment def destroy - response = connection.remove_domain(identity) + response = service.remove_domain(identity) wait_for_job response.body['jobId'], Fog.timeout true end @@ -29,7 +29,7 @@ module Fog @records ||= begin Fog::DNS::Rackspace::Records.new( :zone => self, - :connection => connection + :service => service ) end end @@ -49,7 +49,7 @@ module Fog requires :domain, :email data = { :name => domain, :email => email } - response = connection.create_domains([data]) + response = service.create_domains([data]) response = wait_for_job response.body['jobId'] merge_attributes(response.body['response']['domains'].select {|domain| domain['name'] == self.domain}.first) @@ -58,7 +58,7 @@ module Fog def update requires :ttl, :email - response = connection.modify_domain(identity, { :ttl => ttl, :comment => comment, :email => email}) + response = service.modify_domain(identity, { :ttl => ttl, :comment => comment, :email => email}) wait_for_job response.body['jobId'] end end diff --git a/lib/fog/rackspace/models/dns/zones.rb b/lib/fog/rackspace/models/dns/zones.rb index 9b253d7fa..7ea7bfd8b 100644 --- a/lib/fog/rackspace/models/dns/zones.rb +++ b/lib/fog/rackspace/models/dns/zones.rb @@ -10,7 +10,7 @@ module Fog def all clear - data = connection.list_domains.body['domains'] + data = service.list_domains.body['domains'] load(data) end @@ -19,7 +19,7 @@ module Fog return nil end - data = connection.list_domain_details(zone_id).body + data = service.list_domain_details(zone_id).body new(data) rescue Fog::Rackspace::Errors::NotFound nil diff --git a/lib/fog/rackspace/models/identity/credentials.rb b/lib/fog/rackspace/models/identity/credentials.rb index cfd9f23c8..b1c38c714 100644 --- a/lib/fog/rackspace/models/identity/credentials.rb +++ b/lib/fog/rackspace/models/identity/credentials.rb @@ -24,7 +24,7 @@ module Fog private def retrieve_credentials - data = connection.list_credentials(user.identity).body['credentials'] + data = service.list_credentials(user.identity).body['credentials'] end end end diff --git a/lib/fog/rackspace/models/identity/roles.rb b/lib/fog/rackspace/models/identity/roles.rb index 9bdff2a24..c433296f2 100644 --- a/lib/fog/rackspace/models/identity/roles.rb +++ b/lib/fog/rackspace/models/identity/roles.rb @@ -24,7 +24,7 @@ module Fog private def retrieve_roles - data = connection.list_user_roles(user.identity).body['roles'] + data = service.list_user_roles(user.identity).body['roles'] end end end diff --git a/lib/fog/rackspace/models/identity/tenants.rb b/lib/fog/rackspace/models/identity/tenants.rb index 78802d939..269de919e 100644 --- a/lib/fog/rackspace/models/identity/tenants.rb +++ b/lib/fog/rackspace/models/identity/tenants.rb @@ -20,7 +20,7 @@ module Fog private def retrieve_tenants - data = connection.list_tenants.body['tenants'] + data = service.list_tenants.body['tenants'] end end end diff --git a/lib/fog/rackspace/models/identity/user.rb b/lib/fog/rackspace/models/identity/user.rb index c61d67bbe..17192711d 100644 --- a/lib/fog/rackspace/models/identity/user.rb +++ b/lib/fog/rackspace/models/identity/user.rb @@ -16,9 +16,9 @@ module Fog def save requires :username, :email, :enabled unless persisted? - data = connection.create_user(username, email, enabled, :password => password) + data = service.create_user(username, email, enabled, :password => password) else - data = connection.update_user(identity, username, email, enabled, :password => password) + data = service.update_user(identity, username, email, enabled, :password => password) end merge_attributes(data.body['user']) true @@ -26,14 +26,14 @@ module Fog def destroy requires :identity - connection.delete_user(identity) + service.delete_user(identity) true end def roles @roles ||= begin Fog::Rackspace::Identity::Roles.new({ - :connection => connection, + :service => service, :user => self }) end @@ -42,7 +42,7 @@ module Fog def credentials @credentials ||= begin Fog::Rackspace::Identity::Credentials.new({ - :connection => connection, + :service => service, :user => self }) end diff --git a/lib/fog/rackspace/models/identity/users.rb b/lib/fog/rackspace/models/identity/users.rb index 37112b0da..526629f37 100644 --- a/lib/fog/rackspace/models/identity/users.rb +++ b/lib/fog/rackspace/models/identity/users.rb @@ -9,12 +9,12 @@ module Fog model Fog::Rackspace::Identity::User def all - data = connection.list_users.body['users'] + data = service.list_users.body['users'] load(data) end def get(user_id) - data = connection.get_user_by_id(user_id).body['user'] + data = service.get_user_by_id(user_id).body['user'] new(data) rescue Excon::Errors::NotFound nil @@ -23,7 +23,7 @@ module Fog end def get_by_name(user_name) - data = connection.get_user_by_name(user_name).body['user'] + data = service.get_user_by_name(user_name).body['user'] new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/rackspace/models/load_balancers/access_rule.rb b/lib/fog/rackspace/models/load_balancers/access_rule.rb index b1cfb03fb..34f86ae8d 100644 --- a/lib/fog/rackspace/models/load_balancers/access_rule.rb +++ b/lib/fog/rackspace/models/load_balancers/access_rule.rb @@ -12,17 +12,17 @@ module Fog def destroy requires :identity, :load_balancer - connection.delete_access_rule(load_balancer.identity, identity) + service.delete_access_rule(load_balancer.identity, identity) true end def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :load_balancer, :address, :type - connection.create_access_rule(load_balancer.id, address, type) + service.create_access_rule(load_balancer.id, address, type) #Unfortunately, access rules creation doesn't return an ID, we require a subsequent list call and comparison - data = connection.list_access_rules(load_balancer.id).body['accessList'].select do |ar| + data = service.list_access_rules(load_balancer.id).body['accessList'].select do |ar| ar['address'] == address && ar['type'] == type end.first merge_attributes(data) diff --git a/lib/fog/rackspace/models/load_balancers/access_rules.rb b/lib/fog/rackspace/models/load_balancers/access_rules.rb index 7da4acfd5..bc9ea26b9 100644 --- a/lib/fog/rackspace/models/load_balancers/access_rules.rb +++ b/lib/fog/rackspace/models/load_balancers/access_rules.rb @@ -21,7 +21,7 @@ module Fog private def all_raw requires :load_balancer - data = connection.list_access_rules(load_balancer.id).body['accessList'] + data = service.list_access_rules(load_balancer.id).body['accessList'] end end end diff --git a/lib/fog/rackspace/models/load_balancers/load_balancer.rb b/lib/fog/rackspace/models/load_balancers/load_balancer.rb index 6fa244c65..c50fec505 100644 --- a/lib/fog/rackspace/models/load_balancers/load_balancer.rb +++ b/lib/fog/rackspace/models/load_balancers/load_balancer.rb @@ -38,7 +38,7 @@ module Fog def access_rules @access_rules ||= begin Fog::Rackspace::LoadBalancers::AccessRules.new({ - :connection => connection, + :service => service, :load_balancer => self}) end end @@ -50,7 +50,7 @@ module Fog def nodes @nodes ||= begin Fog::Rackspace::LoadBalancers::Nodes.new({ - :connection => connection, + :service => service, :load_balancer => self}) end end @@ -61,25 +61,25 @@ module Fog def ssl_termination requires :identity - ssl_termination = connection.get_ssl_termination(identity).body['sslTermination'] + ssl_termination = service.get_ssl_termination(identity).body['sslTermination'] rescue Fog::Rackspace::LoadBalancers::NotFound nil end def enable_ssl_termination(securePort, privatekey, certificate, options = {}) requires :identity - connection.set_ssl_termination(identity, securePort, privatekey, certificate, options) + service.set_ssl_termination(identity, securePort, privatekey, certificate, options) end def disable_ssl_termination requires :identity - connection.remove_ssl_termination(identity) + service.remove_ssl_termination(identity) end def virtual_ips @virtual_ips ||= begin Fog::Rackspace::LoadBalancers::VirtualIps.new({ - :connection => connection, + :service => service, :load_balancer => self}) end end @@ -107,73 +107,73 @@ module Fog def enable_connection_logging requires :identity - connection.set_connection_logging identity, true + service.set_connection_logging identity, true attributes[:connection_logging] = true end def disable_connection_logging requires :identity - connection.set_connection_logging identity, false + service.set_connection_logging identity, false attributes[:connection_logging] = false end def health_monitor requires :identity - monitor = connection.get_monitor(identity).body['healthMonitor'] + monitor = service.get_monitor(identity).body['healthMonitor'] monitor.count == 0 ? nil : monitor end def enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {}) requires :identity - connection.set_monitor(identity, type, delay, timeout, attempsBeforeDeactivation, options) + service.set_monitor(identity, type, delay, timeout, attempsBeforeDeactivation, options) true end def disable_health_monitor requires :identity - connection.remove_monitor(identity) + service.remove_monitor(identity) true end def connection_throttling requires :identity - throttle = connection.get_connection_throttling(identity).body['connectionThrottle'] + throttle = service.get_connection_throttling(identity).body['connectionThrottle'] throttle.count == 0 ? nil : throttle end def enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval) requires :identity - connection.set_connection_throttling(identity, max_connections, min_connections, max_connection_rate, rate_interval) + service.set_connection_throttling(identity, max_connections, min_connections, max_connection_rate, rate_interval) true end def disable_connection_throttling requires :identity - connection.remove_connection_throttling(identity) + service.remove_connection_throttling(identity) true end def session_persistence requires :identity - persistence = connection.get_session_persistence(identity).body['sessionPersistence'] + persistence = service.get_session_persistence(identity).body['sessionPersistence'] persistence.count == 0 ? nil : persistence end def enable_session_persistence(type) requires :identity - connection.set_session_persistence(identity, type) + service.set_session_persistence(identity, type) true end def disable_session_persistence requires :identity - connection.remove_session_persistence(identity) + service.remove_session_persistence(identity) true end def destroy requires :identity - connection.delete_load_balancer(identity) + service.delete_load_balancer(identity) true end @@ -192,22 +192,22 @@ module Fog def usage(options = {}) requires :identity - connection.get_load_balancer_usage(identity, options).body + service.get_load_balancer_usage(identity, options).body end def error_page requires :identity - connection.get_error_page(identity).body['errorpage']['content'] + service.get_error_page(identity).body['errorpage']['content'] end def error_page=(content) requires :identity - connection.set_error_page identity, content + service.set_error_page identity, content end def reset_error_page requires :identity - connection.remove_error_page identity + service.remove_error_page identity end private @@ -220,7 +220,7 @@ module Fog options = {} end - data = connection.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash, options) + data = service.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash, options) merge_attributes(data.body['loadBalancer']) end @@ -231,7 +231,7 @@ module Fog :algorithm => algorithm, :protocol => protocol, :port => port} - connection.update_load_balancer(identity, options) + service.update_load_balancer(identity, options) #TODO - Should this bubble down to nodes? Without tracking changes this would be very inefficient. # For now, individual nodes will have to be saved individually after saving an LB diff --git a/lib/fog/rackspace/models/load_balancers/load_balancers.rb b/lib/fog/rackspace/models/load_balancers/load_balancers.rb index ae2930cdc..21aad405d 100644 --- a/lib/fog/rackspace/models/load_balancers/load_balancers.rb +++ b/lib/fog/rackspace/models/load_balancers/load_balancers.rb @@ -10,12 +10,12 @@ module Fog model Fog::Rackspace::LoadBalancers::LoadBalancer def all - data = connection.list_load_balancers.body['loadBalancers'] + data = service.list_load_balancers.body['loadBalancers'] load(data) end def get(load_balancer_id) - if load_balancer = connection.get_load_balancer(load_balancer_id).body['loadBalancer'] + if load_balancer = service.get_load_balancer(load_balancer_id).body['loadBalancer'] new(load_balancer) end rescue Fog::Rackspace::LoadBalancers::NotFound diff --git a/lib/fog/rackspace/models/load_balancers/node.rb b/lib/fog/rackspace/models/load_balancers/node.rb index 216f55e30..9a77ef802 100644 --- a/lib/fog/rackspace/models/load_balancers/node.rb +++ b/lib/fog/rackspace/models/load_balancers/node.rb @@ -15,7 +15,7 @@ module Fog def destroy requires :identity, :load_balancer - connection.delete_node(load_balancer.identity, identity) + service.delete_node(load_balancer.identity, identity) true end @@ -38,7 +38,7 @@ module Fog unless weight.nil? options[:weight] = weight end - data = connection.create_node(load_balancer.id, address, port, condition, options) + data = service.create_node(load_balancer.id, address, port, condition, options) merge_attributes(data.body['nodes'][0]) end @@ -50,7 +50,7 @@ module Fog unless weight.nil? options[:weight] = weight end - connection.update_node(load_balancer.id, identity, options) + service.update_node(load_balancer.id, identity, options) end end end diff --git a/lib/fog/rackspace/models/load_balancers/nodes.rb b/lib/fog/rackspace/models/load_balancers/nodes.rb index 2e7bcdad2..e9cffb200 100644 --- a/lib/fog/rackspace/models/load_balancers/nodes.rb +++ b/lib/fog/rackspace/models/load_balancers/nodes.rb @@ -11,13 +11,13 @@ module Fog def all requires :load_balancer - data = connection.list_nodes(load_balancer.id).body['nodes'] + data = service.list_nodes(load_balancer.id).body['nodes'] load(data) end def get(node_id) requires :load_balancer - if node = connection.get_node(load_balancer.id, node_id).body['node'] + if node = service.get_node(load_balancer.id, node_id).body['node'] new(node) end rescue Fog::Rackspace::LoadBalancers::NotFound diff --git a/lib/fog/rackspace/models/load_balancers/virtual_ip.rb b/lib/fog/rackspace/models/load_balancers/virtual_ip.rb index 8ceb6154a..94e14ec27 100644 --- a/lib/fog/rackspace/models/load_balancers/virtual_ip.rb +++ b/lib/fog/rackspace/models/load_balancers/virtual_ip.rb @@ -13,14 +13,14 @@ module Fog def destroy requires :identity, :load_balancer - connection.delete_virtual_ip(load_balancer.identity, identity) + service.delete_virtual_ip(load_balancer.identity, identity) true end def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :load_balancer, :type - data = connection.create_virtual_ip(load_balancer.id, type) + data = service.create_virtual_ip(load_balancer.id, type) merge_attributes(data.body) true end diff --git a/lib/fog/rackspace/models/load_balancers/virtual_ips.rb b/lib/fog/rackspace/models/load_balancers/virtual_ips.rb index 71cbcf450..07abb3353 100644 --- a/lib/fog/rackspace/models/load_balancers/virtual_ips.rb +++ b/lib/fog/rackspace/models/load_balancers/virtual_ips.rb @@ -24,7 +24,7 @@ module Fog private def all_raw requires :load_balancer - connection.list_virtual_ips(load_balancer.id).body['virtualIps'] + service.list_virtual_ips(load_balancer.id).body['virtualIps'] end end end diff --git a/lib/fog/rackspace/models/storage/directories.rb b/lib/fog/rackspace/models/storage/directories.rb index ce5d233d6..56248888a 100644 --- a/lib/fog/rackspace/models/storage/directories.rb +++ b/lib/fog/rackspace/models/storage/directories.rb @@ -10,7 +10,7 @@ module Fog model Fog::Storage::Rackspace::Directory def all - data = connection.get_containers.body + data = service.get_containers.body load(data) end @@ -19,7 +19,7 @@ module Fog # > fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url # => 'http://cdn.lunenburg.org/hayley-dancing.mov' def get(key, options = {}) - data = connection.get_container(key, options) + data = service.get_container(key, options) directory = new(:key => key, :cdn_cname => options[:cdn_cname]) for key, value in data.headers if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key) diff --git a/lib/fog/rackspace/models/storage/directory.rb b/lib/fog/rackspace/models/storage/directory.rb index a5bbf8433..af2d850c2 100644 --- a/lib/fog/rackspace/models/storage/directory.rb +++ b/lib/fog/rackspace/models/storage/directory.rb @@ -15,8 +15,8 @@ module Fog def destroy requires :key - connection.delete_container(key) - connection.cdn.post_container(key, 'X-CDN-Enabled' => 'False') + service.delete_container(key) + service.cdn.post_container(key, 'X-CDN-Enabled' => 'False') true rescue Excon::Errors::NotFound false @@ -26,7 +26,7 @@ module Fog @files ||= begin Fog::Storage::Rackspace::Files.new( :directory => self, - :connection => connection + :service => service ) end end @@ -38,9 +38,9 @@ module Fog def public_url requires :key @public_url ||= begin - begin response = connection.cdn.head_container(key) + begin response = service.cdn.head_container(key) if response.headers['X-Cdn-Enabled'] == 'True' - if connection.rackspace_cdn_ssl == true + if service.rackspace_cdn_ssl == true response.headers['X-Cdn-Ssl-Uri'] else cdn_cname || response.headers['X-Cdn-Uri'] @@ -54,19 +54,19 @@ module Fog def save requires :key - connection.put_container(key) + service.put_container(key) - if connection.cdn && @public + if service.cdn && @public # if public and CDN connection then update cdn to public uri_header = 'X-CDN-URI' - if connection.rackspace_cdn_ssl == true + if service.rackspace_cdn_ssl == true uri_header = 'X-CDN-SSL-URI' end - @public_url = connection.cdn.put_container(key, 'X-CDN-Enabled' => 'True').headers[uri_header] - elsif connection.cdn && !@public - connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False') + @public_url = service.cdn.put_container(key, 'X-CDN-Enabled' => 'True').headers[uri_header] + elsif service.cdn && !@public + service.cdn.put_container(key, 'X-CDN-Enabled' => 'False') @public_url = nil - elsif !connection.cdn && @public + elsif !service.cdn && @public # if public but no CDN connection then error raise(Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided")) end diff --git a/lib/fog/rackspace/models/storage/file.rb b/lib/fog/rackspace/models/storage/file.rb index 82117f190..6b090b530 100644 --- a/lib/fog/rackspace/models/storage/file.rb +++ b/lib/fog/rackspace/models/storage/file.rb @@ -36,14 +36,14 @@ module Fog options['Content-Type'] ||= content_type if content_type options['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin options['Origin'] ||= origin if origin - connection.copy_object(directory.key, key, target_directory_key, target_file_key, options) - target_directory = connection.directories.new(:key => target_directory_key) + service.copy_object(directory.key, key, target_directory_key, target_file_key, options) + target_directory = service.directories.new(:key => target_directory_key) target_directory.files.get(target_file_key) end def destroy requires :directory, :key - connection.delete_object(directory.key, key) + service.delete_object(directory.key, key) true end @@ -76,7 +76,7 @@ module Fog options['Origin'] = origin if origin options.merge!(metadata_to_headers) - data = connection.put_object(directory.key, key, body, options) + data = service.put_object(directory.key, key, body, options) update_attributes_from(data) refresh_metadata @@ -125,7 +125,7 @@ module Fog def metadata_attributes if last_modified - headers = connection.head_object(directory.key, self.key).headers + headers = service.head_object(directory.key, self.key).headers headers.reject! {|k, v| !metadata_attribute?(k)} else {} diff --git a/lib/fog/rackspace/models/storage/files.rb b/lib/fog/rackspace/models/storage/files.rb index 238744965..f79e3c13f 100644 --- a/lib/fog/rackspace/models/storage/files.rb +++ b/lib/fog/rackspace/models/storage/files.rb @@ -54,7 +54,7 @@ module Fog def get(key, &block) requires :directory - data = connection.get_object(directory.key, key, &block) + data = service.get_object(directory.key, key, &block) file_data = data.headers.merge({ :body => data.body, :key => key @@ -73,7 +73,7 @@ module Fog def head(key, options = {}) requires :directory - data = connection.head_object(directory.key, key) + data = service.head_object(directory.key, key) file_data = data.headers.merge({ :key => key })