Sha256: 34603a7a12c4b8cd8825c05fa75ce4cac9d13ac5a960655c7b804c24e7d644f7

Contents?: true

Size: 1.8 KB

Versions: 77

Compression:

Stored size: 1.8 KB

Contents

module Fog
  module Compute
    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)
          @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)
          @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VIF.create'}, conf )
        end

        def default_vif_config( vm_ref, network_ref, device_number = '-1' )
          conf = {
            'MAC_autogenerated' => 'True',
            'VM' => vm_ref,
            'network' => network_ref,
            'MAC' => '',
            'MTU' => '0',
            'other_config' => {},
            'qos_algorithm_type' => 'ratelimit',
            'qos_algorithm_params' => {}
          }
          if device_number.to_i >= 0
            conf['device'] = device_number
          else
            highest_dev = 0
            server = servers.get vm_ref
            server.vifs.each do |vif|
              dev = vif.device.to_i
              highest_dev = dev if dev > highest_dev
            end
            conf['device'] = (highest_dev + 1).to_s
          end
          conf
        end
      end
      
      class Mock
        
        def create_vif( vm_ref, network_ref )
          Fog::Mock.not_implemented
        end
        
      end

    end
  end
end

Version data entries

77 entries across 77 versions & 12 rubygems

Version Path
fog-maestrodev-1.20.0.20140305101839 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/xenserver/requests/compute/create_vif.rb
fog-1.20.0 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/xenserver/requests/compute/create_vif.rb
fog-1.19.0 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/xenserver/requests/compute/create_vif.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/xenserver/requests/compute/create_vif.rb