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) def save(force = false)
requires :volume_id requires :volume_id
raise IdentifierTaken.new('Resaving may cause a duplicate snapshot to be created') if persisted? 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_name => display_name,
:display_description => display_description, :display_description => display_description,
:force => force :force => force
@ -38,7 +38,7 @@ module Fog
def destroy def destroy
requires :identity requires :identity
connection.delete_snapshot(identity) service.delete_snapshot(identity)
true true
end end
end end

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Rackspace::BlockStorage::Snapshot model Fog::Rackspace::BlockStorage::Snapshot
def all def all
data = connection.list_snapshots.body['snapshots'] data = service.list_snapshots.body['snapshots']
load(data) load(data)
end end
def get(snapshot_id) def get(snapshot_id)
data = connection.get_snapshot(snapshot_id).body['snapshot'] data = service.get_snapshot(snapshot_id).body['snapshot']
new(data) new(data)
rescue Fog::Rackspace::BlockStorage::NotFound rescue Fog::Rackspace::BlockStorage::NotFound
nil nil

View file

@ -32,18 +32,18 @@ module Fog
end end
def snapshots def snapshots
connection.snapshots.select { |s| s.volume_id == identity } service.snapshots.select { |s| s.volume_id == identity }
end end
def create_snapshot(options={}) def create_snapshot(options={})
requires :identity requires :identity
connection.snapshots.create(options.merge(:volume_id => identity)) service.snapshots.create(options.merge(:volume_id => identity))
end end
def save def save
requires :size requires :size
raise IdentifierTaken.new('Resaving may cause a duplicate volume to be created') if persisted? 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_name => display_name,
:display_description => display_description, :display_description => display_description,
:volume_type => volume_type, :volume_type => volume_type,
@ -55,7 +55,7 @@ module Fog
def destroy def destroy
requires :identity requires :identity
connection.delete_volume(identity) service.delete_volume(identity)
true true
end end
end end

View file

@ -9,16 +9,16 @@ module Fog
model Fog::Rackspace::BlockStorage::VolumeType model Fog::Rackspace::BlockStorage::VolumeType
def all def all
data = connection.list_volume_types.body['volume_types'] data = service.list_volume_types.body['volume_types']
load(data) load(data)
end end
def get(volume_type_id) 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) new(data)
rescue Fog::Rackspace::BlockStorage::NotFound rescue Fog::Rackspace::BlockStorage::NotFound
nil nil
end end
end end
end end
end end

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Rackspace::BlockStorage::Volume model Fog::Rackspace::BlockStorage::Volume
def all def all
data = connection.list_volumes.body['volumes'] data = service.list_volumes.body['volumes']
load(data) load(data)
end end
def get(volume_id) def get(volume_id)
data = connection.get_volume(volume_id).body['volume'] data = service.get_volume(volume_id).body['volume']
new(data) new(data)
rescue Fog::Rackspace::BlockStorage::NotFound rescue Fog::Rackspace::BlockStorage::NotFound
nil nil

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Compute::Rackspace::Flavor model Fog::Compute::Rackspace::Flavor
def all def all
data = connection.list_flavors_detail.body['flavors'] data = service.list_flavors_detail.body['flavors']
load(data) load(data)
end end
def get(flavor_id) def get(flavor_id)
data = connection.get_flavor_details(flavor_id).body['flavor'] data = service.get_flavor_details(flavor_id).body['flavor']
new(data) new(data)
rescue Fog::Compute::Rackspace::NotFound rescue Fog::Compute::Rackspace::NotFound
nil nil

View file

@ -24,7 +24,7 @@ module Fog
def destroy def destroy
requires :id requires :id
connection.delete_image(id) service.delete_image(id)
true true
end end
@ -36,7 +36,7 @@ module Fog
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
requires :server_id requires :server_id
data = connection.create_image(server_id, 'name' => name) data = service.create_image(server_id, 'name' => name)
merge_attributes(data.body['image']) merge_attributes(data.body['image'])
true true
end end

View file

@ -12,7 +12,7 @@ module Fog
attribute :server attribute :server
def all def all
data = connection.list_images_detail.body['images'] data = service.list_images_detail.body['images']
models = load(data) models = load(data)
if server if server
self.replace(self.select {|image| image.server_id == server.id}) self.replace(self.select {|image| image.server_id == server.id})
@ -22,7 +22,7 @@ module Fog
end end
def get(image_id) def get(image_id)
data = connection.get_image_details(image_id).body['image'] data = service.get_image_details(image_id).body['image']
new(data) new(data)
rescue Fog::Compute::Rackspace::NotFound rescue Fog::Compute::Rackspace::NotFound
nil nil

View file

@ -28,23 +28,23 @@ module Fog
def destroy def destroy
requires :id requires :id
connection.delete_server(id) service.delete_server(id)
true true
end end
def flavor def flavor
requires :flavor_id requires :flavor_id
connection.flavors.get(flavor_id) service.flavors.get(flavor_id)
end end
def image def image
requires :image_id requires :image_id
connection.images.get(image_id) service.images.get(image_id)
end end
def images def images
requires :id requires :id
connection.images(:server => self) service.images(:server => self)
end end
def private_ip_address def private_ip_address
@ -61,7 +61,7 @@ module Fog
def reboot(type = 'SOFT') def reboot(type = 'SOFT')
requires :id requires :id
connection.reboot_server(id, type) service.reboot_server(id, type)
true true
end end
@ -74,7 +74,7 @@ module Fog
'personality' => personality 'personality' => personality
} }
options = options.reject {|key, value| value.nil?} 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']) merge_attributes(data.body['server'])
true true
end end

View file

@ -10,7 +10,7 @@ module Fog
model Fog::Compute::Rackspace::Server model Fog::Compute::Rackspace::Server
def all def all
data = connection.list_servers_detail.body['servers'] data = service.list_servers_detail.body['servers']
load(data) load(data)
end end
@ -22,7 +22,7 @@ module Fog
end end
def get(server_id) 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) new(server)
end end
rescue Fog::Compute::Rackspace::NotFound rescue Fog::Compute::Rackspace::NotFound

View file

@ -12,14 +12,14 @@ module Fog
def save def save
requires :server, :identity, :device 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']) merge_attributes(data.body['volumeAttachment'])
true true
end end
def destroy def destroy
requires :server, :identity requires :server, :identity
connection.delete_attachment(server.identity, identity) service.delete_attachment(server.identity, identity)
true true
end end

View file

@ -11,12 +11,12 @@ module Fog
attr_accessor :server attr_accessor :server
def all def all
data = connection.list_attachments(server.id).body['volumeAttachments'] data = service.list_attachments(server.id).body['volumeAttachments']
load(data) load(data)
end end
def get(volume_id) 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) data && new(data)
end end
end end

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Compute::RackspaceV2::Flavor model Fog::Compute::RackspaceV2::Flavor
def all def all
data = connection.list_flavors.body['flavors'] data = service.list_flavors.body['flavors']
load(data) load(data)
end end
def get(flavor_id) def get(flavor_id)
data = connection.get_flavor(flavor_id).body['flavor'] data = service.get_flavor(flavor_id).body['flavor']
new(data) new(data)
rescue Fog::Compute::RackspaceV2::NotFound rescue Fog::Compute::RackspaceV2::NotFound
nil nil

View file

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

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Compute::RackspaceV2::Image model Fog::Compute::RackspaceV2::Image
def all def all
data = connection.list_images.body['images'] data = service.list_images.body['images']
load(data) load(data)
end end
def get(image_id) def get(image_id)
data = connection.get_image(image_id).body['image'] data = service.get_image(image_id).body['image']
new(data) new(data)
rescue Fog::Compute::RackspaceV2::NotFound rescue Fog::Compute::RackspaceV2::NotFound
nil nil

View file

@ -41,7 +41,7 @@ module Fog
attribute :addresses attribute :addresses
attribute :flavor_id, :aliases => 'flavor', :squash => 'id' attribute :flavor_id, :aliases => 'flavor', :squash => 'id'
attribute :image_id, :aliases => 'image', :squash => 'id' attribute :image_id, :aliases => 'image', :squash => 'id'
attr_reader :password attr_reader :password
def save def save
@ -61,49 +61,49 @@ module Fog
options[:metadata] = metadata unless metadata.nil? options[:metadata] = metadata unless metadata.nil?
options[:personality] = personality unless personality.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']) merge_attributes(data.body['server'])
true true
end end
def update def update
requires :identity, :name requires :identity, :name
data = connection.update_server(identity, name) data = service.update_server(identity, name)
merge_attributes(data.body['server']) merge_attributes(data.body['server'])
true true
end end
def destroy def destroy
requires :identity requires :identity
connection.delete_server(identity) service.delete_server(identity)
true true
end end
def flavor def flavor
requires :flavor_id requires :flavor_id
@flavor ||= connection.flavors.get(flavor_id) @flavor ||= service.flavors.get(flavor_id)
end end
def image def image
requires :image_id requires :image_id
@image ||= connection.images.get(image_id) @image ||= service.images.get(image_id)
end end
def create_image(name, options = {}) def create_image(name, options = {})
requires :identity requires :identity
response = connection.create_image(identity, name, options) response = service.create_image(identity, name, options)
response.headers["Location"].match(/\/([^\/]+$)/)[1] rescue nil response.headers["Location"].match(/\/([^\/]+$)/)[1] rescue nil
end end
def attachments def attachments
@attachments ||= begin @attachments ||= begin
Fog::Compute::RackspaceV2::Attachments.new({ Fog::Compute::RackspaceV2::Attachments.new({
:connection => connection, :service => service,
:server => self :server => self
}) })
end end
end end
def private_ip_address def private_ip_address
addresses['private'].select{|a| a["version"] == 4}[0]["addr"] addresses['private'].select{|a| a["version"] == 4}[0]["addr"]
end end
@ -118,45 +118,45 @@ module Fog
def reboot(type = 'SOFT') def reboot(type = 'SOFT')
requires :identity requires :identity
connection.reboot_server(identity, type) service.reboot_server(identity, type)
self.state = type == 'SOFT' ? REBOOT : HARD_REBOOT self.state = type == 'SOFT' ? REBOOT : HARD_REBOOT
true true
end end
def resize(flavor_id) def resize(flavor_id)
requires :identity requires :identity
connection.resize_server(identity, flavor_id) service.resize_server(identity, flavor_id)
self.state = RESIZE self.state = RESIZE
true true
end end
def rebuild(image_id) def rebuild(image_id)
requires :identity requires :identity
connection.rebuild_server(identity, image_id) service.rebuild_server(identity, image_id)
self.state = REBUILD self.state = REBUILD
true true
end end
def confirm_resize def confirm_resize
requires :identity requires :identity
connection.confirm_resize_server(identity) service.confirm_resize_server(identity)
true true
end end
def revert_resize def revert_resize
requires :identity requires :identity
connection.revert_resize_server(identity) service.revert_resize_server(identity)
true true
end end
def change_admin_password(password) def change_admin_password(password)
requires :identity requires :identity
connection.change_server_password(identity, password) service.change_server_password(identity, password)
self.state = PASSWORD self.state = PASSWORD
@password = password @password = password
true true
end end
def setup(credentials = {}) def setup(credentials = {})
requires :public_ip_address, :identity, :public_key, :username requires :public_ip_address, :identity, :public_key, :username
Fog::SSH.new(public_ip_address, username, credentials).run([ Fog::SSH.new(public_ip_address, username, credentials).run([

View file

@ -10,7 +10,7 @@ module Fog
model Fog::Compute::RackspaceV2::Server model Fog::Compute::RackspaceV2::Server
def all def all
data = connection.list_servers.body['servers'] data = service.list_servers.body['servers']
load(data) load(data)
end end
@ -22,7 +22,7 @@ module Fog
end end
def get(server_id) def get(server_id)
data = connection.get_server(server_id).body['server'] data = service.get_server(server_id).body['server']
new(data) new(data)
rescue Fog::Compute::RackspaceV2::NotFound rescue Fog::Compute::RackspaceV2::NotFound
nil nil

View file

@ -11,13 +11,13 @@ module Fog
def save def save
requires :identity, :instance 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 true
end end
def destroy def destroy
requires :identity, :instance requires :identity, :instance
connection.delete_database(instance.identity, identity) service.delete_database(instance.identity, identity)
true true
end end

View file

@ -23,7 +23,7 @@ module Fog
def retrieve_databases def retrieve_databases
requires :instance requires :instance
data = connection.list_databases(instance.id).body['databases'] data = service.list_databases(instance.id).body['databases']
end end
end end
end end

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Rackspace::Databases::Flavor model Fog::Rackspace::Databases::Flavor
def all def all
data = connection.list_flavors.body['flavors'] data = service.list_flavors.body['flavors']
load(data) load(data)
end end
def get(flavor_id) def get(flavor_id)
data = connection.get_flavor(flavor_id).body['flavor'] data = service.get_flavor(flavor_id).body['flavor']
new(data) new(data)
rescue Fog::Rackspace::Databases::NotFound rescue Fog::Rackspace::Databases::NotFound
nil nil

View file

@ -27,26 +27,26 @@ module Fog
def save def save
requires :name, :flavor_id, :volume_size 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']) merge_attributes(data.body['instance'])
true true
end end
def destroy def destroy
requires :identity requires :identity
connection.delete_instance(identity) service.delete_instance(identity)
true true
end end
def flavor def flavor
requires :flavor_id requires :flavor_id
@flavor ||= connection.flavors.get(flavor_id) @flavor ||= service.flavors.get(flavor_id)
end end
def databases def databases
@databases ||= begin @databases ||= begin
Fog::Rackspace::Databases::Databases.new({ Fog::Rackspace::Databases::Databases.new({
:connection => connection, :service => service,
:instance => self :instance => self
}) })
end end
@ -55,7 +55,7 @@ module Fog
def users def users
@users ||= begin @users ||= begin
Fog::Rackspace::Databases::Users.new({ Fog::Rackspace::Databases::Users.new({
:connection => connection, :service => service,
:instance => self :instance => self
}) })
end end
@ -67,12 +67,12 @@ module Fog
def root_user_enabled? def root_user_enabled?
requires :identity requires :identity
connection.check_root_user(identity).body['rootEnabled'] service.check_root_user(identity).body['rootEnabled']
end end
def enable_root_user def enable_root_user
requires :identity requires :identity
data = connection.enable_root_user(identity).body['user'] data = service.enable_root_user(identity).body['user']
@root_user = data['name'] @root_user = data['name']
@root_password = data['password'] @root_password = data['password']
true true
@ -80,21 +80,21 @@ module Fog
def restart def restart
requires :identity requires :identity
connection.restart_instance(identity) service.restart_instance(identity)
self.state = REBOOT self.state = REBOOT
true true
end end
def resize(flavor_id) def resize(flavor_id)
requires :identity requires :identity
connection.resize_instance(identity, flavor_id) service.resize_instance(identity, flavor_id)
self.state = RESIZE self.state = RESIZE
true true
end end
def resize_volume(volume_size) def resize_volume(volume_size)
requires :identity requires :identity
connection.resize_instance_volume(identity, volume_size) service.resize_instance_volume(identity, volume_size)
self.state = RESIZE self.state = RESIZE
true true
end end

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Rackspace::Databases::Instance model Fog::Rackspace::Databases::Instance
def all def all
data = connection.list_instances.body['instances'] data = service.list_instances.body['instances']
load(data) load(data)
end end
def get(instance_id) def get(instance_id)
data = connection.get_instance(instance_id).body['instance'] data = service.get_instance(instance_id).body['instance']
new(data) new(data)
rescue Fog::Rackspace::Databases::NotFound rescue Fog::Rackspace::Databases::NotFound
nil nil

View file

@ -11,13 +11,13 @@ module Fog
def save def save
requires :identity, :instance, :password requires :identity, :instance, :password
connection.create_user(instance.identity, identity, password, :databases => databases) service.create_user(instance.identity, identity, password, :databases => databases)
true true
end end
def destroy def destroy
requires :identity, :instance requires :identity, :instance
connection.delete_user(instance.identity, identity) service.delete_user(instance.identity, identity)
true true
end end

View file

@ -23,7 +23,7 @@ module Fog
def retrieve_users def retrieve_users
requires :instance requires :instance
data = connection.list_users(instance.identity).body['users'] data = service.list_users(instance.identity).body['users']
end end
end end
end end

View file

@ -10,7 +10,7 @@ module Fog
retries = 5 retries = 5
response = nil response = nil
Fog.wait_for(timeout, interval) do Fog.wait_for(timeout, interval) do
response = connection.callback job_id response = service.callback job_id
if response.body['status'] == 'COMPLETED' if response.body['status'] == 'COMPLETED'
true true
elsif response.body['status'] == 'ERROR' elsif response.body['status'] == 'ERROR'

View file

@ -24,7 +24,7 @@ module Fog
def destroy def destroy
requires :zone, :identity 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 true
end end
@ -59,20 +59,20 @@ module Fog
options[:priority] = priority options[:priority] = priority
end 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 ['A', 'AAAA'].include?(self.type.upcase)
# If this is an A or AAAA record, match by normalized IP address value. # 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)) (record['name'] == self.name) && (record['type'] == self.type) && (IPAddr.new(record['data']) == IPAddr.new(self.value))
else else
# Other record types are matched by the raw value. # Other record types are matched by the raw value.
(record['name'] == self.name) && (record['type'] == self.type) && (record['data'] == self.value) (record['name'] == self.name) && (record['type'] == self.type) && (record['data'] == self.value)
end end
end end
merge_attributes(matching_record) merge_attributes(matching_record)
true true
end end
@ -86,7 +86,7 @@ module Fog
options[:priority] = priority if priority options[:priority] = priority if priority
options[:ttl] = ttl if ttl 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 true
end end

View file

@ -13,13 +13,13 @@ module Fog
def all def all
requires :zone requires :zone
data = connection.list_records(zone.identity) data = service.list_records(zone.identity)
load(data.body['records']) load(data.body['records'])
end end
def get(record_id) def get(record_id)
requires :zone requires :zone
data = connection.list_record_details(zone.identity, record_id).body data = service.list_record_details(zone.identity, record_id).body
new(data) new(data)
#nil or empty string will trigger an argument error #nil or empty string will trigger an argument error
rescue ArgumentError rescue ArgumentError

View file

@ -20,7 +20,7 @@ module Fog
attribute :comment attribute :comment
def destroy def destroy
response = connection.remove_domain(identity) response = service.remove_domain(identity)
wait_for_job response.body['jobId'], Fog.timeout wait_for_job response.body['jobId'], Fog.timeout
true true
end end
@ -29,7 +29,7 @@ module Fog
@records ||= begin @records ||= begin
Fog::DNS::Rackspace::Records.new( Fog::DNS::Rackspace::Records.new(
:zone => self, :zone => self,
:connection => connection :service => service
) )
end end
end end
@ -49,7 +49,7 @@ module Fog
requires :domain, :email requires :domain, :email
data = { :name => domain, :email => email } data = { :name => domain, :email => email }
response = connection.create_domains([data]) response = service.create_domains([data])
response = wait_for_job response.body['jobId'] response = wait_for_job response.body['jobId']
merge_attributes(response.body['response']['domains'].select {|domain| domain['name'] == self.domain}.first) merge_attributes(response.body['response']['domains'].select {|domain| domain['name'] == self.domain}.first)
@ -58,7 +58,7 @@ module Fog
def update def update
requires :ttl, :email 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'] wait_for_job response.body['jobId']
end end
end end

View file

@ -10,7 +10,7 @@ module Fog
def all def all
clear clear
data = connection.list_domains.body['domains'] data = service.list_domains.body['domains']
load(data) load(data)
end end
@ -19,7 +19,7 @@ module Fog
return nil return nil
end end
data = connection.list_domain_details(zone_id).body data = service.list_domain_details(zone_id).body
new(data) new(data)
rescue Fog::Rackspace::Errors::NotFound rescue Fog::Rackspace::Errors::NotFound
nil nil

View file

@ -24,7 +24,7 @@ module Fog
private private
def retrieve_credentials def retrieve_credentials
data = connection.list_credentials(user.identity).body['credentials'] data = service.list_credentials(user.identity).body['credentials']
end end
end end
end end

View file

@ -24,7 +24,7 @@ module Fog
private private
def retrieve_roles def retrieve_roles
data = connection.list_user_roles(user.identity).body['roles'] data = service.list_user_roles(user.identity).body['roles']
end end
end end
end end

View file

@ -20,7 +20,7 @@ module Fog
private private
def retrieve_tenants def retrieve_tenants
data = connection.list_tenants.body['tenants'] data = service.list_tenants.body['tenants']
end end
end end
end end

View file

@ -16,9 +16,9 @@ module Fog
def save def save
requires :username, :email, :enabled requires :username, :email, :enabled
unless persisted? unless persisted?
data = connection.create_user(username, email, enabled, :password => password) data = service.create_user(username, email, enabled, :password => password)
else else
data = connection.update_user(identity, username, email, enabled, :password => password) data = service.update_user(identity, username, email, enabled, :password => password)
end end
merge_attributes(data.body['user']) merge_attributes(data.body['user'])
true true
@ -26,14 +26,14 @@ module Fog
def destroy def destroy
requires :identity requires :identity
connection.delete_user(identity) service.delete_user(identity)
true true
end end
def roles def roles
@roles ||= begin @roles ||= begin
Fog::Rackspace::Identity::Roles.new({ Fog::Rackspace::Identity::Roles.new({
:connection => connection, :service => service,
:user => self :user => self
}) })
end end
@ -42,7 +42,7 @@ module Fog
def credentials def credentials
@credentials ||= begin @credentials ||= begin
Fog::Rackspace::Identity::Credentials.new({ Fog::Rackspace::Identity::Credentials.new({
:connection => connection, :service => service,
:user => self :user => self
}) })
end end

View file

@ -9,12 +9,12 @@ module Fog
model Fog::Rackspace::Identity::User model Fog::Rackspace::Identity::User
def all def all
data = connection.list_users.body['users'] data = service.list_users.body['users']
load(data) load(data)
end end
def get(user_id) 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) new(data)
rescue Excon::Errors::NotFound rescue Excon::Errors::NotFound
nil nil
@ -23,7 +23,7 @@ module Fog
end end
def get_by_name(user_name) 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) new(data)
rescue Excon::Errors::NotFound rescue Excon::Errors::NotFound
nil nil

View file

@ -12,17 +12,17 @@ module Fog
def destroy def destroy
requires :identity, :load_balancer requires :identity, :load_balancer
connection.delete_access_rule(load_balancer.identity, identity) service.delete_access_rule(load_balancer.identity, identity)
true true
end end
def save def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
requires :load_balancer, :address, :type 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 #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 ar['address'] == address && ar['type'] == type
end.first end.first
merge_attributes(data) merge_attributes(data)

View file

@ -21,7 +21,7 @@ module Fog
private private
def all_raw def all_raw
requires :load_balancer 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 end
end end

View file

@ -38,7 +38,7 @@ module Fog
def access_rules def access_rules
@access_rules ||= begin @access_rules ||= begin
Fog::Rackspace::LoadBalancers::AccessRules.new({ Fog::Rackspace::LoadBalancers::AccessRules.new({
:connection => connection, :service => service,
:load_balancer => self}) :load_balancer => self})
end end
end end
@ -50,7 +50,7 @@ module Fog
def nodes def nodes
@nodes ||= begin @nodes ||= begin
Fog::Rackspace::LoadBalancers::Nodes.new({ Fog::Rackspace::LoadBalancers::Nodes.new({
:connection => connection, :service => service,
:load_balancer => self}) :load_balancer => self})
end end
end end
@ -61,25 +61,25 @@ module Fog
def ssl_termination def ssl_termination
requires :identity 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 rescue Fog::Rackspace::LoadBalancers::NotFound
nil nil
end end
def enable_ssl_termination(securePort, privatekey, certificate, options = {}) def enable_ssl_termination(securePort, privatekey, certificate, options = {})
requires :identity requires :identity
connection.set_ssl_termination(identity, securePort, privatekey, certificate, options) service.set_ssl_termination(identity, securePort, privatekey, certificate, options)
end end
def disable_ssl_termination def disable_ssl_termination
requires :identity requires :identity
connection.remove_ssl_termination(identity) service.remove_ssl_termination(identity)
end end
def virtual_ips def virtual_ips
@virtual_ips ||= begin @virtual_ips ||= begin
Fog::Rackspace::LoadBalancers::VirtualIps.new({ Fog::Rackspace::LoadBalancers::VirtualIps.new({
:connection => connection, :service => service,
:load_balancer => self}) :load_balancer => self})
end end
end end
@ -107,73 +107,73 @@ module Fog
def enable_connection_logging def enable_connection_logging
requires :identity requires :identity
connection.set_connection_logging identity, true service.set_connection_logging identity, true
attributes[:connection_logging] = true attributes[:connection_logging] = true
end end
def disable_connection_logging def disable_connection_logging
requires :identity requires :identity
connection.set_connection_logging identity, false service.set_connection_logging identity, false
attributes[:connection_logging] = false attributes[:connection_logging] = false
end end
def health_monitor def health_monitor
requires :identity requires :identity
monitor = connection.get_monitor(identity).body['healthMonitor'] monitor = service.get_monitor(identity).body['healthMonitor']
monitor.count == 0 ? nil : monitor monitor.count == 0 ? nil : monitor
end end
def enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {}) def enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {})
requires :identity requires :identity
connection.set_monitor(identity, type, delay, timeout, attempsBeforeDeactivation, options) service.set_monitor(identity, type, delay, timeout, attempsBeforeDeactivation, options)
true true
end end
def disable_health_monitor def disable_health_monitor
requires :identity requires :identity
connection.remove_monitor(identity) service.remove_monitor(identity)
true true
end end
def connection_throttling def connection_throttling
requires :identity requires :identity
throttle = connection.get_connection_throttling(identity).body['connectionThrottle'] throttle = service.get_connection_throttling(identity).body['connectionThrottle']
throttle.count == 0 ? nil : throttle throttle.count == 0 ? nil : throttle
end end
def enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval) def enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval)
requires :identity 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 true
end end
def disable_connection_throttling def disable_connection_throttling
requires :identity requires :identity
connection.remove_connection_throttling(identity) service.remove_connection_throttling(identity)
true true
end end
def session_persistence def session_persistence
requires :identity requires :identity
persistence = connection.get_session_persistence(identity).body['sessionPersistence'] persistence = service.get_session_persistence(identity).body['sessionPersistence']
persistence.count == 0 ? nil : persistence persistence.count == 0 ? nil : persistence
end end
def enable_session_persistence(type) def enable_session_persistence(type)
requires :identity requires :identity
connection.set_session_persistence(identity, type) service.set_session_persistence(identity, type)
true true
end end
def disable_session_persistence def disable_session_persistence
requires :identity requires :identity
connection.remove_session_persistence(identity) service.remove_session_persistence(identity)
true true
end end
def destroy def destroy
requires :identity requires :identity
connection.delete_load_balancer(identity) service.delete_load_balancer(identity)
true true
end end
@ -192,22 +192,22 @@ module Fog
def usage(options = {}) def usage(options = {})
requires :identity requires :identity
connection.get_load_balancer_usage(identity, options).body service.get_load_balancer_usage(identity, options).body
end end
def error_page def error_page
requires :identity requires :identity
connection.get_error_page(identity).body['errorpage']['content'] service.get_error_page(identity).body['errorpage']['content']
end end
def error_page=(content) def error_page=(content)
requires :identity requires :identity
connection.set_error_page identity, content service.set_error_page identity, content
end end
def reset_error_page def reset_error_page
requires :identity requires :identity
connection.remove_error_page identity service.remove_error_page identity
end end
private private
@ -220,7 +220,7 @@ module Fog
options = {} options = {}
end 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']) merge_attributes(data.body['loadBalancer'])
end end
@ -231,7 +231,7 @@ module Fog
:algorithm => algorithm, :algorithm => algorithm,
:protocol => protocol, :protocol => protocol,
:port => port} :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. #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 # 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 model Fog::Rackspace::LoadBalancers::LoadBalancer
def all def all
data = connection.list_load_balancers.body['loadBalancers'] data = service.list_load_balancers.body['loadBalancers']
load(data) load(data)
end end
def get(load_balancer_id) 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) new(load_balancer)
end end
rescue Fog::Rackspace::LoadBalancers::NotFound rescue Fog::Rackspace::LoadBalancers::NotFound

View file

@ -15,7 +15,7 @@ module Fog
def destroy def destroy
requires :identity, :load_balancer requires :identity, :load_balancer
connection.delete_node(load_balancer.identity, identity) service.delete_node(load_balancer.identity, identity)
true true
end end
@ -38,7 +38,7 @@ module Fog
unless weight.nil? unless weight.nil?
options[:weight] = weight options[:weight] = weight
end 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]) merge_attributes(data.body['nodes'][0])
end end
@ -50,7 +50,7 @@ module Fog
unless weight.nil? unless weight.nil?
options[:weight] = weight options[:weight] = weight
end end
connection.update_node(load_balancer.id, identity, options) service.update_node(load_balancer.id, identity, options)
end end
end end
end end

View file

@ -11,13 +11,13 @@ module Fog
def all def all
requires :load_balancer requires :load_balancer
data = connection.list_nodes(load_balancer.id).body['nodes'] data = service.list_nodes(load_balancer.id).body['nodes']
load(data) load(data)
end end
def get(node_id) def get(node_id)
requires :load_balancer 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) new(node)
end end
rescue Fog::Rackspace::LoadBalancers::NotFound rescue Fog::Rackspace::LoadBalancers::NotFound

View file

@ -13,14 +13,14 @@ module Fog
def destroy def destroy
requires :identity, :load_balancer requires :identity, :load_balancer
connection.delete_virtual_ip(load_balancer.identity, identity) service.delete_virtual_ip(load_balancer.identity, identity)
true true
end end
def save def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
requires :load_balancer, :type 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) merge_attributes(data.body)
true true
end end

View file

@ -24,7 +24,7 @@ module Fog
private private
def all_raw def all_raw
requires :load_balancer requires :load_balancer
connection.list_virtual_ips(load_balancer.id).body['virtualIps'] service.list_virtual_ips(load_balancer.id).body['virtualIps']
end end
end end
end end

View file

@ -10,7 +10,7 @@ module Fog
model Fog::Storage::Rackspace::Directory model Fog::Storage::Rackspace::Directory
def all def all
data = connection.get_containers.body data = service.get_containers.body
load(data) load(data)
end end
@ -19,7 +19,7 @@ module Fog
# > fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url # > fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url
# => 'http://cdn.lunenburg.org/hayley-dancing.mov' # => 'http://cdn.lunenburg.org/hayley-dancing.mov'
def get(key, options = {}) 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]) directory = new(:key => key, :cdn_cname => options[:cdn_cname])
for key, value in data.headers for key, value in data.headers
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key) if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)

View file

@ -15,8 +15,8 @@ module Fog
def destroy def destroy
requires :key requires :key
connection.delete_container(key) service.delete_container(key)
connection.cdn.post_container(key, 'X-CDN-Enabled' => 'False') service.cdn.post_container(key, 'X-CDN-Enabled' => 'False')
true true
rescue Excon::Errors::NotFound rescue Excon::Errors::NotFound
false false
@ -26,7 +26,7 @@ module Fog
@files ||= begin @files ||= begin
Fog::Storage::Rackspace::Files.new( Fog::Storage::Rackspace::Files.new(
:directory => self, :directory => self,
:connection => connection :service => service
) )
end end
end end
@ -38,9 +38,9 @@ module Fog
def public_url def public_url
requires :key requires :key
@public_url ||= begin @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 response.headers['X-Cdn-Enabled'] == 'True'
if connection.rackspace_cdn_ssl == true if service.rackspace_cdn_ssl == true
response.headers['X-Cdn-Ssl-Uri'] response.headers['X-Cdn-Ssl-Uri']
else else
cdn_cname || response.headers['X-Cdn-Uri'] cdn_cname || response.headers['X-Cdn-Uri']
@ -54,19 +54,19 @@ module Fog
def save def save
requires :key 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 # if public and CDN connection then update cdn to public
uri_header = 'X-CDN-URI' uri_header = 'X-CDN-URI'
if connection.rackspace_cdn_ssl == true if service.rackspace_cdn_ssl == true
uri_header = 'X-CDN-SSL-URI' uri_header = 'X-CDN-SSL-URI'
end end
@public_url = connection.cdn.put_container(key, 'X-CDN-Enabled' => 'True').headers[uri_header] @public_url = service.cdn.put_container(key, 'X-CDN-Enabled' => 'True').headers[uri_header]
elsif connection.cdn && !@public elsif service.cdn && !@public
connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False') service.cdn.put_container(key, 'X-CDN-Enabled' => 'False')
@public_url = nil @public_url = nil
elsif !connection.cdn && @public elsif !service.cdn && @public
# if public but no CDN connection then error # 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")) raise(Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided"))
end end

View file

@ -36,14 +36,14 @@ module Fog
options['Content-Type'] ||= content_type if content_type options['Content-Type'] ||= content_type if content_type
options['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin options['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin
options['Origin'] ||= origin if origin options['Origin'] ||= origin if origin
connection.copy_object(directory.key, key, target_directory_key, target_file_key, options) service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
target_directory = connection.directories.new(:key => target_directory_key) target_directory = service.directories.new(:key => target_directory_key)
target_directory.files.get(target_file_key) target_directory.files.get(target_file_key)
end end
def destroy def destroy
requires :directory, :key requires :directory, :key
connection.delete_object(directory.key, key) service.delete_object(directory.key, key)
true true
end end
@ -76,7 +76,7 @@ module Fog
options['Origin'] = origin if origin options['Origin'] = origin if origin
options.merge!(metadata_to_headers) 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) update_attributes_from(data)
refresh_metadata refresh_metadata
@ -125,7 +125,7 @@ module Fog
def metadata_attributes def metadata_attributes
if last_modified 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)} headers.reject! {|k, v| !metadata_attribute?(k)}
else else
{} {}

View file

@ -54,7 +54,7 @@ module Fog
def get(key, &block) def get(key, &block)
requires :directory requires :directory
data = connection.get_object(directory.key, key, &block) data = service.get_object(directory.key, key, &block)
file_data = data.headers.merge({ file_data = data.headers.merge({
:body => data.body, :body => data.body,
:key => key :key => key
@ -73,7 +73,7 @@ module Fog
def head(key, options = {}) def head(key, options = {})
requires :directory requires :directory
data = connection.head_object(directory.key, key) data = service.head_object(directory.key, key)
file_data = data.headers.merge({ file_data = data.headers.merge({
:key => key :key => key
}) })