mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
raise an error if trying to re-save a model
This commit is contained in:
parent
7f48b10559
commit
e923e3c959
8 changed files with 27 additions and 18 deletions
|
@ -32,6 +32,7 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
data = connection.allocate_address
|
||||
@public_ip = data.body['publicIp']
|
||||
if @server
|
||||
|
|
|
@ -125,6 +125,7 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :image_id
|
||||
|
||||
options = {
|
||||
|
|
|
@ -30,6 +30,7 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :volume_id
|
||||
|
||||
data = connection.create_snapshot(@volume_id, @description).body
|
||||
|
|
|
@ -36,15 +36,8 @@ module Fog
|
|||
state == 'available'
|
||||
end
|
||||
|
||||
def server=(new_server)
|
||||
if new_server
|
||||
attach(new_server)
|
||||
else
|
||||
detach
|
||||
end
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :availability_zone, :size
|
||||
|
||||
data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
|
||||
|
@ -56,6 +49,14 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def server=(new_server)
|
||||
if new_server
|
||||
attach(new_server)
|
||||
else
|
||||
detach
|
||||
end
|
||||
end
|
||||
|
||||
def snapshots
|
||||
requires :id
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :flavor_id, :image_id
|
||||
options = if !password && !public_key
|
||||
raise(ArgumentError, "password or public_key is required for this operation")
|
||||
|
|
|
@ -33,6 +33,7 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :server_id
|
||||
|
||||
data = connection.create_image(@server_id, 'name' => name)
|
||||
|
|
|
@ -47,16 +47,6 @@ module Fog
|
|||
connection.images(:server => self)
|
||||
end
|
||||
|
||||
def ready?
|
||||
@status == 'ACTIVE'
|
||||
end
|
||||
|
||||
def reboot(type = 'SOFT')
|
||||
requires :id
|
||||
connection.reboot_server(@id, type)
|
||||
true
|
||||
end
|
||||
|
||||
def private_key_path
|
||||
File.expand_path(@private_key_path ||= Fog.credentials[:private_key_path])
|
||||
end
|
||||
|
@ -73,7 +63,18 @@ module Fog
|
|||
@public_key ||= File.read(public_key_path)
|
||||
end
|
||||
|
||||
def ready?
|
||||
@status == 'ACTIVE'
|
||||
end
|
||||
|
||||
def reboot(type = 'SOFT')
|
||||
requires :id
|
||||
connection.reboot_server(@id, type)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :flavor_id, :image_id, :name
|
||||
options = {
|
||||
'metadata' => @metadata,
|
||||
|
|
|
@ -70,7 +70,9 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :flavor_id, :image_id, :name
|
||||
|
||||
data = connection.create_slice(@flavor_id, @image_id, @name)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
|
|
Loading…
Add table
Reference in a new issue