mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3357 from plribeiro3000/deprecate-xenserver-methods
Deprecation of methods in Xenserver
This commit is contained in:
commit
aafb83629f
20 changed files with 284 additions and 128 deletions
|
@ -85,6 +85,7 @@ module Fog
|
|||
request :destroy_vif
|
||||
request :clone_server
|
||||
request :destroy_server
|
||||
request :destroy_record
|
||||
request :unplug_vbd
|
||||
request :eject_vbd
|
||||
request :insert_vbd
|
||||
|
|
|
@ -24,6 +24,9 @@ module Fog
|
|||
attribute :blobs
|
||||
|
||||
def refresh
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #reload instead.'
|
||||
)
|
||||
data = service.get_record( reference, 'network' )
|
||||
merge_attributes( data )
|
||||
true
|
||||
|
|
|
@ -124,6 +124,9 @@ module Fog
|
|||
end
|
||||
|
||||
def refresh
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #reload instead.'
|
||||
)
|
||||
data = service.get_record( reference, 'VM' )
|
||||
merge_attributes( data )
|
||||
true
|
||||
|
|
|
@ -5,6 +5,9 @@ module Fog
|
|||
def clone_server( server_name, template_ref )
|
||||
# Clone the VM template
|
||||
if template_ref.kind_of? Fog::Compute::XenServer::Server
|
||||
Fog::Logger.deprecation(
|
||||
'Passing an object to #clone_server is deprecated. Pass the reference instead.'
|
||||
)
|
||||
template_ref = template_ref.reference
|
||||
end
|
||||
raise ArgumentError.new("Invalid template_ref") if template_ref.nil?
|
||||
|
|
|
@ -7,6 +7,14 @@ module Fog
|
|||
# @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=network
|
||||
#
|
||||
def create_network( name, config = {} )
|
||||
if name.is_a?(Hash)
|
||||
default_config = name
|
||||
default_config.reject! { |_k,v| v.nil? }
|
||||
else
|
||||
Fog::Logger.deprecation(
|
||||
'This api is deprecated. The only expected param is a hash with the attributes.'
|
||||
)
|
||||
|
||||
config.reject! { |k,v| v.nil? }
|
||||
|
||||
default_config = {
|
||||
|
@ -16,6 +24,7 @@ module Fog
|
|||
# Mandatory, but can be empty
|
||||
:other_config => {}
|
||||
}.merge config
|
||||
end
|
||||
|
||||
@connection.request(
|
||||
{
|
||||
|
|
|
@ -3,14 +3,24 @@ module Fog
|
|||
class XenServer
|
||||
class Real
|
||||
def get_vm_by_name(label)
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #get_by_name instead.'
|
||||
)
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.get_by_name_label' }, label)
|
||||
end
|
||||
|
||||
def get_vm_by_uuid(uuid)
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #get_by_uuid instead.'
|
||||
)
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.get_by_uuid' }, uuid)
|
||||
end
|
||||
|
||||
def create_server_raw(config = {})
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. To create a server from scratch, use #create_server.'
|
||||
)
|
||||
|
||||
config[:name_label] = config[:name] if config[:name]
|
||||
config.delete :name
|
||||
config[:affinity] = config[:__affinity] if config[:__affinity]
|
||||
|
@ -74,6 +84,15 @@ module Fog
|
|||
end
|
||||
|
||||
def create_server( name_label, template = nil, networks = [], extra_args = {})
|
||||
if name_label.is_a?(Hash)
|
||||
config = name_label.reject! { |_k,v| v.nil? }
|
||||
ref = @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.create' }, config)
|
||||
else
|
||||
Fog::Logger.deprecation(
|
||||
'This api is deprecated. The only expected param is a hash with the attributes.' + "\n" +
|
||||
'To create a server from a template, use #clone_server instead.'
|
||||
)
|
||||
|
||||
if !networks.kind_of? Array
|
||||
raise "Invalid networks argument"
|
||||
end
|
||||
|
@ -105,6 +124,7 @@ module Fog
|
|||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
|
||||
start_vm( ref )
|
||||
end
|
||||
end
|
||||
|
||||
ref
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ module Fog
|
|||
# @return [String] an OpaqueRef to the storage repository
|
||||
def create_sr( host_ref,
|
||||
name_label,
|
||||
type,
|
||||
type = '',
|
||||
name_description = '',
|
||||
device_config = {},
|
||||
physical_size = '0',
|
||||
|
@ -33,6 +33,28 @@ module Fog
|
|||
shared = false,
|
||||
sm_config = {} )
|
||||
|
||||
if host_ref.is_a?(Hash)
|
||||
config = host_ref
|
||||
extra_params = name_label
|
||||
|
||||
%i(physical_size name description type content_type shared sm_config).each do |attribute|
|
||||
raise "Missing Argument in first param: #{attribute}" if config[attribute].nil?
|
||||
end
|
||||
|
||||
%i(host_ref device_config).each do |attribute|
|
||||
raise "Missing Argument in second param: #{attribute}" if extra_params[attribute].nil?
|
||||
end
|
||||
|
||||
@connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => 'SR.create' },
|
||||
extra_params[:host_ref], extra_params[:device_config], config[:physical_size],
|
||||
config[:name], config[:description], config[:type], config[:content_type],
|
||||
config[:shared], config[:sm_config])
|
||||
else
|
||||
Fog::Logger.deprecation(
|
||||
'This api is deprecated. The expected params are two hashes of attributes.' + "\n" +
|
||||
'To create a server from a template, use #clone_server instead.'
|
||||
)
|
||||
|
||||
@connection.request(
|
||||
{:parser => Fog::Parsers::XenServer::Base.new, :method => 'SR.create'},
|
||||
host_ref,
|
||||
|
@ -47,6 +69,7 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_sr( host_ref,
|
||||
|
|
|
@ -2,7 +2,14 @@ module Fog
|
|||
module Compute
|
||||
class XenServer
|
||||
class Real
|
||||
def create_vbd( vm_ref, vdi_ref, config = {} )
|
||||
def create_vbd( vm_ref, vdi_ref = '', config = {} )
|
||||
if vm_ref.is_a?(Hash)
|
||||
default_config = vm_ref.reject! { |_k,v| v.nil? }
|
||||
else
|
||||
Fog::Logger.deprecation(
|
||||
'This api is deprecated. The only expected param is a hash of attributes.'
|
||||
)
|
||||
|
||||
raise ArgumentError.new('Invalid config') if config.nil?
|
||||
vm_ref = vm_ref.reference if vm_ref.kind_of? Fog::Compute::XenServer::Server
|
||||
vdi_ref = vdi_ref.reference if vdi_ref.kind_of? Fog::Compute::XenServer::VDI
|
||||
|
@ -20,6 +27,7 @@ module Fog
|
|||
:qos_supported_algorithms=> [],
|
||||
:type => 'Disk'
|
||||
}.merge config
|
||||
end
|
||||
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.create'}, default_config )
|
||||
end
|
||||
|
|
|
@ -3,16 +3,35 @@ module Fog
|
|||
class XenServer
|
||||
class Real
|
||||
def create_vdi( config )
|
||||
raise ArgumentError.new('Invalid config') if config.nil?
|
||||
raise ArgumentError.new('Missing virtual_size attribute') if config[:virtual_size].nil?
|
||||
raise ArgumentError.new('Missing read_only attribute') if config[:read_only].nil?
|
||||
raise ArgumentError.new('Missing type attribute') if config[:type].nil?
|
||||
raise ArgumentError.new('Missing sharable attribute') if config[:sharable].nil?
|
||||
raise ArgumentError.new('Missing other_config attribute') if config[:other_config].nil?
|
||||
raise ArgumentError.new('Missing storage_repository attribute') if config[:storage_repository].nil?
|
||||
raise ArgumentError.new('Invalid #config') if config.nil?
|
||||
raise ArgumentError.new('Missing #virtual_size attribute') if config[:virtual_size].nil?
|
||||
raise ArgumentError.new('Missing #read_only attribute') if config[:read_only].nil?
|
||||
raise ArgumentError.new('Missing #type attribute') if config[:type].nil?
|
||||
raise ArgumentError.new('Missing #sharable attribute') if config[:sharable].nil?
|
||||
raise ArgumentError.new('Missing #other_config attribute') if config[:other_config].nil?
|
||||
if config[:storage_repository].nil? || config[:SR].nil?
|
||||
raise ArgumentError.new('Missing #storage_repository or #SR attribute')
|
||||
end
|
||||
|
||||
if config[:storage_repository].present?
|
||||
Fog::Logger.deprecation(
|
||||
'The attribute #storage_repository is deprecated. Use #SR instead.'
|
||||
)
|
||||
config[:SR] = config[:storage_repository].reference
|
||||
end
|
||||
if config[:name].present?
|
||||
Fog::Logger.deprecation(
|
||||
'The attribute #name is deprecated. Use #name_label instead.'
|
||||
)
|
||||
config[:name_label] = config[:name]
|
||||
config[:name_description] = config[:description] if config[:description]
|
||||
end
|
||||
if config[:description].present?
|
||||
Fog::Logger.deprecation(
|
||||
'The attribute storage_repository is deprecated. Use SR instead.'
|
||||
)
|
||||
config[:name_description] = config[:description]
|
||||
end
|
||||
|
||||
config.reject! { |k,v| (k == :__sr) or (k == :storage_repository) }
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VDI.create'}, config )
|
||||
end
|
||||
|
|
|
@ -5,18 +5,28 @@ module Fog
|
|||
def create_vif( vm_ref, network_ref, device = -1)
|
||||
raise ArgumentError.new('Invalid vm_ref') if vm_ref.nil?
|
||||
raise ArgumentError.new('Invalid network_ref') if network_ref.nil?
|
||||
if vm_ref.is_a?(Hash)
|
||||
vif_config = vm_ref.reject! { |_k,v| v.nil? }
|
||||
else
|
||||
vm_ref = vm_ref.reference if vm_ref.kind_of? Fog::Model
|
||||
network_ref = network_ref.reference if network_ref.kind_of? Fog::Model
|
||||
vif_config = default_vif_config(vm_ref, network_ref, device.to_s)
|
||||
end
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VIF.create'}, vif_config )
|
||||
end
|
||||
|
||||
def create_vif_custom( conf )
|
||||
raise ArgumentError.new('VIF config is not a Hash') if not conf.kind_of?(Hash)
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #create_vif instead.'
|
||||
)
|
||||
raise ArgumentError.new('VIF config is not a Hash') unless conf.kind_of?(Hash)
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VIF.create'}, conf )
|
||||
end
|
||||
|
||||
def default_vif_config( vm_ref, network_ref, device_number = '-1' )
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecatedx.'
|
||||
)
|
||||
conf = {
|
||||
'MAC_autogenerated' => 'True',
|
||||
'VM' => vm_ref,
|
||||
|
|
|
@ -7,14 +7,27 @@ module Fog
|
|||
#
|
||||
# @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VLAN
|
||||
#
|
||||
def create_vlan( pif_ref, vlan_id, network_ref )
|
||||
def create_vlan( pif_ref, vlan_id, network_ref = '' )
|
||||
if pif_ref.is_a?(Hash)
|
||||
config = pif_ref
|
||||
extra_config = vlan_id
|
||||
|
||||
pif_ref = extra_config[:pif_ref]
|
||||
tag = config[:tag].to_s
|
||||
network_ref = extra_config[:network_ref]
|
||||
else
|
||||
Fog::Logger.deprecation(
|
||||
'This api is deprecated. The only expected params are two hash of attributes.'
|
||||
)
|
||||
tag = vlan_id.to_s
|
||||
end
|
||||
@connection.request(
|
||||
{
|
||||
:parser => Fog::Parsers::XenServer::Base.new,
|
||||
:method => 'VLAN.create'
|
||||
},
|
||||
pif_ref,
|
||||
vlan_id.to_s,
|
||||
tag,
|
||||
network_ref
|
||||
)
|
||||
end
|
||||
|
|
|
@ -8,6 +8,9 @@ module Fog
|
|||
# @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=network
|
||||
#
|
||||
def destroy_network( ref )
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #destroy_record instead.'
|
||||
)
|
||||
@connection.request(
|
||||
{
|
||||
:parser => Fog::Parsers::XenServer::Base.new,
|
||||
|
|
11
lib/fog/xenserver/requests/compute/destroy_record.rb
Normal file
11
lib/fog/xenserver/requests/compute/destroy_record.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
class Real
|
||||
def destroy_record(ref, provider_class)
|
||||
@connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => "#{provider_class}.destroy" }, ref)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,9 @@ module Fog
|
|||
class XenServer
|
||||
class Real
|
||||
def destroy_server( vm_ref , extra_args = {})
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #destroy_record instead.'
|
||||
)
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.destroy'}, vm_ref)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,9 @@ module Fog
|
|||
# http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=SR
|
||||
#
|
||||
def destroy_sr( sr_ref )
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #destroy_record instead.'
|
||||
)
|
||||
@connection.request(
|
||||
{:parser => Fog::Parsers::XenServer::Base.new, :method => 'SR.destroy'},
|
||||
sr_ref
|
||||
|
|
|
@ -3,6 +3,9 @@ module Fog
|
|||
class XenServer
|
||||
class Real
|
||||
def destroy_vdi( vdi_ref, extra_args = {})
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #destroy_record instead.'
|
||||
)
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VDI.destroy'}, vdi_ref)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,9 @@ module Fog
|
|||
class XenServer
|
||||
class Real
|
||||
def destroy_vif( ref, extra_args = {})
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #destroy_record instead.'
|
||||
)
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VIF.destroy'}, ref)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,9 @@ module Fog
|
|||
# @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VLAN
|
||||
#
|
||||
def destroy_vlan( ref )
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #destroy_record instead.'
|
||||
)
|
||||
@connection.request(
|
||||
{
|
||||
:parser => Fog::Parsers::XenServer::Base.new,
|
||||
|
|
|
@ -11,6 +11,14 @@ module Fog
|
|||
def get_record_by_ref( ref, klass, options = {} )
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "#{klass}.get_record"}, ref).merge(:reference => ref)
|
||||
end
|
||||
|
||||
def get_by_name(name, provider_class)
|
||||
@connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => "#{provider_class}.get_by_name_label" }, name)
|
||||
end
|
||||
|
||||
def get_by_uuid(uuid, provider_class)
|
||||
@connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => "#{provider_class}.get_by_uuid" }, uuid)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
|
|
@ -2,13 +2,20 @@ module Fog
|
|||
module Compute
|
||||
class XenServer
|
||||
class Real
|
||||
def snapshot_revert( snapshot_ref, extra_args = {})
|
||||
def revert_server( snapshot_ref, extra_args = {})
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.revert'}, snapshot_ref)
|
||||
end
|
||||
|
||||
def snapshot_revert(snapshot_ref, extra_args = {})
|
||||
Fog::Logger.deprecation(
|
||||
'This method is deprecated. Use #revert_server instead.'
|
||||
)
|
||||
revert_server(snapshot_ref, extra_args)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def snapshot_revert()
|
||||
def revert_server()
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue