mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[xenserver] added new methods to StorageRepository model
- destroy/save operations - generic set_attribute method
This commit is contained in:
parent
64612868da
commit
e8594c484b
1 changed files with 43 additions and 0 deletions
|
@ -40,6 +40,49 @@ module Fog
|
|||
reload
|
||||
end
|
||||
|
||||
def destroy
|
||||
connection.destroy_sr reference
|
||||
end
|
||||
|
||||
def save
|
||||
requires :name
|
||||
requires :type
|
||||
|
||||
# host is not a model attribute (not in XAPI at least),
|
||||
# but we need it here
|
||||
host = attributes[:host]
|
||||
raise ArgumentError.new('host is required for this operation') unless
|
||||
host
|
||||
|
||||
# Not sure if this is always required, so not raising exception if nil
|
||||
device_config = attributes[:device_config]
|
||||
|
||||
# create_sr request provides sane defaults if some attributes are
|
||||
# missing
|
||||
attr = connection.get_record(
|
||||
connection.create_sr( host.reference,
|
||||
name,
|
||||
type,
|
||||
description,
|
||||
device_config,
|
||||
physical_size,
|
||||
content_type,
|
||||
shared || false,
|
||||
sm_config),
|
||||
'SR'
|
||||
)
|
||||
merge_attributes attr
|
||||
true
|
||||
end
|
||||
|
||||
def set_attribute(name, *val)
|
||||
data = connection.set_attribute( 'SR', reference, name, *val )
|
||||
# Do not reload automatically for performance reasons
|
||||
# We can set multiple attributes at the same time and
|
||||
# then reload manually
|
||||
#reload
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue