lib/fog/xenserver/requests/compute/create_vif.rb in fog-1.26.0 vs lib/fog/xenserver/requests/compute/create_vif.rb in fog-1.27.0

- old
+ new

@@ -3,21 +3,31 @@ class XenServer class Real 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? - 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) + 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, 'network' => network_ref, 'MAC' => '',