1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace] Updates reference to service

This commit is contained in:
Paul Thornthwaite 2012-12-22 23:24:03 +00:00
parent 9c6e17bd6c
commit bc26c4e433
46 changed files with 163 additions and 163 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -9,12 +9,12 @@ 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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -31,7 +31,7 @@ module Fog
def destroy
requires :identity
connection.delete_image(identity)
service.delete_image(identity)
end
end
end

View file

@ -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

View file

@ -61,44 +61,44 @@ 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 = 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
@ -118,40 +118,40 @@ 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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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,7 +59,7 @@ 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|
if ['A', 'AAAA'].include?(self.type.upcase)
@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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
{}

View file

@ -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
})