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

[ibm] Updates reference to service

This commit is contained in:
Paul Thornthwaite 2012-12-22 23:26:06 +00:00
parent b8a36cc688
commit e41395674e
13 changed files with 39 additions and 39 deletions

View file

@ -37,7 +37,7 @@ module Fog
def save
requires :offering_id, :location
data = connection.create_address(location, offering_id,
data = service.create_address(location, offering_id,
:vlan_id => vlan_id,
:ip => ip)
merge_attributes(data.body)
@ -54,7 +54,7 @@ module Fog
def destroy
requires :id
connection.delete_address(id).body['success']
service.delete_address(id).body['success']
end
end
end

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Compute::IBM::Address
def all
load(connection.list_addresses.body['addresses'])
load(service.list_addresses.body['addresses'])
end
def get(address_id)
begin
address = connection.list_addresses.body
address = service.list_addresses.body
new(address['addresses'].find{|address| address['id'] == address_id.to_s })
rescue Fog::Compute::IBM::NotFound
nil

View file

@ -42,7 +42,7 @@ module Fog
def save
requires :id, :volume_id
data = connection.create_image(id, volume_id)
data = service.create_image(id, volume_id)
merge_attributes(data.body)
data.body['success']
end
@ -56,12 +56,12 @@ module Fog
end
def clone(name, description)
connection.clone_image(id, name, description).body['ImageID']
service.clone_image(id, name, description).body['ImageID']
end
def destroy
requires :id
connection.delete_image(id).body['success']
service.delete_image(id).body['success']
end
end

View file

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

View file

@ -12,13 +12,13 @@ module Fog
def save
requires :name
data = connection.create_key(name, public_key)
data = service.create_key(name, public_key)
merge_attributes(data.body)
data.body['keyName'] == name
end
def destroy
data = connection.delete_key(identity)
data = service.delete_key(identity)
data.body['success']
end

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Compute::IBM::Key
def all
load(connection.list_keys.body['keys'])
load(service.list_keys.body['keys'])
end
def get(key_id)
begin
new(connection.get_key(key_id).body)
new(service.get_key(key_id).body)
rescue Fog::Compute::IBM::NotFound
nil
end
@ -26,7 +26,7 @@ module Fog
end
def default=(key_name)
connection.modify_key(key_name, 'default' => true)
service.modify_key(key_name, 'default' => true)
end
end

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Compute::IBM::Location
def all
load(connection.list_locations.body['locations'])
load(service.list_locations.body['locations'])
end
def get(location_id)
begin
new(connection.get_location(location_id).body)
new(service.get_location(location_id).body)
rescue Fog::Compute::IBM::NotFound
nil
end

View file

@ -59,7 +59,7 @@ module Fog
def save
requires :name, :image_id, :instance_type, :location_id
data = connection.create_instance(name, image_id, instance_type, location_id,
data = service.create_instance(name, image_id, instance_type, location_id,
:key_name => key_name,
:vlan_id => vlan_id,
:secondary_ip => secondary_ip)
@ -82,17 +82,17 @@ module Fog
def reboot
requires :id
connection.modify_instance(id, 'state' => 'restart').body['success']
service.modify_instance(id, 'state' => 'restart').body['success']
end
def destroy
requires :id
connection.delete_instance(id).body['success']
service.delete_instance(id).body['success']
end
def rename(name)
requires :id
if connection.modify_instance(id, 'name' => name).body["success"]
if service.modify_instance(id, 'name' => name).body["success"]
attributes[:name] = name
else
return false
@ -102,7 +102,7 @@ module Fog
def allocate_ip(wait_for_ready=true)
requires :location_id
new_ip = connection.addresses.new(:location => location_id)
new_ip = service.addresses.new(:location => location_id)
new_ip.save
new_ip.wait_for(Fog::IBM.timeout) { ready? } if wait_for_ready
secondary_ip << new_ip
@ -112,7 +112,7 @@ module Fog
def addresses
addys = secondary_ip.map {|ip| Fog::Compute[:ibm].addresses.new(ip) }
# Set an ID, in case someone tries to save
addys << connection.addresses.new(attributes[:primary_ip].merge(
addys << service.addresses.new(attributes[:primary_ip].merge(
:id => "0",
:location => location_id,
:state => 3
@ -122,13 +122,13 @@ module Fog
def attach(volume_id)
requires :id
data = connection.modify_instance(id, {'type' => 'attach', 'storageID' => volume_id})
data = service.modify_instance(id, {'type' => 'attach', 'storageID' => volume_id})
data.body
end
def detach(volume_id)
requires :id
data = connection.modify_instance(id, {'type' => 'detach', 'storageID' => volume_id})
data = service.modify_instance(id, {'type' => 'detach', 'storageID' => volume_id})
data.body
end
@ -143,7 +143,7 @@ module Fog
# Sets expiration time - Pass an instance of Time.
def expire_at(time)
expiry_time = (time.tv_sec * 1000).to_i
data = connection.modify_instance(id, 'expirationTime' => expiry_time)
data = service.modify_instance(id, 'expirationTime' => expiry_time)
if data.body['expirationTime'] == expiry_time
attributes[:expires_at] = expiry_time
true
@ -159,12 +159,12 @@ module Fog
def image
requires :image_id
connection.images.get(image_id)
service.images.get(image_id)
end
def location
requires :location_id
connection.locations.get(location_id)
service.locations.get(location_id)
end
def public_hostname
@ -182,7 +182,7 @@ module Fog
:name => name + " as of " + Time.now.strftime("%Y-%m-%d %H:%M"),
:description => ""
}.merge(opts)
connection.create_image(id, options[:name], options[:description]).body
service.create_image(id, options[:name], options[:description]).body
end
alias :create_image :to_image
end

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Compute::IBM::Server
def all
load(connection.list_instances.body['instances'])
load(service.list_instances.body['instances'])
end
def get(server_id)
begin
new(connection.get_instance(server_id).body)
new(service.get_instance(server_id).body)
rescue Fog::Compute::IBM::NotFound
nil
end

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Compute::IBM::Vlan
def all
load(connection.list_vlans.body['vlan'])
load(service.list_vlans.body['vlan'])
end
def get(vlan_id)
begin
vlan = connection.list_vlans.body
vlan = service.list_vlans.body
new(vlan['vlan'].find{|vlan| vlan['id'] == vlan_id.to_s })
rescue Fog::Compute::IBM::NotFound
nil

View file

@ -10,7 +10,7 @@ module Fog
model Fog::Storage::IBM::Offering
def all
load(connection.list_offerings.body['volumes'])
load(service.list_offerings.body['volumes'])
end
end

View file

@ -46,12 +46,12 @@ module Fog
def attach(instance_id)
requires :id
connection.attach_volume(instance_id, id).body['success']
service.attach_volume(instance_id, id).body['success']
end
def detach(instance_id)
requires :id
connection.detach_volume(instance_id, id).body['success']
service.detach_volume(instance_id, id).body['success']
end
def created_at
@ -60,7 +60,7 @@ module Fog
def destroy
requires :id
connection.delete_volume(id)
service.delete_volume(id)
true
end
@ -83,7 +83,7 @@ module Fog
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
requires :name, :offering_id, :format, :location_id, :size
data = connection.create_volume(name, offering_id, format, location_id, size)
data = service.create_volume(name, offering_id, format, location_id, size)
merge_attributes(data.body)
true
end

View file

@ -10,12 +10,12 @@ module Fog
model Fog::Storage::IBM::Volume
def all
load(connection.list_volumes.body['volumes'])
load(service.list_volumes.body['volumes'])
end
def get(volume_id)
begin
new(connection.get_volume(volume_id).body)
new(service.get_volume(volume_id).body)
rescue Fog::Storage::IBM::NotFound
nil
end