Class: Fog::Compute::XenServer::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/xenserver/compute.rb,
lib/fog/xenserver/requests/compute/scan_sr.rb,
lib/fog/xenserver/requests/compute/start_vm.rb,
lib/fog/xenserver/requests/compute/create_sr.rb,
lib/fog/xenserver/requests/compute/eject_vbd.rb,
lib/fog/xenserver/requests/compute/create_vbd.rb,
lib/fog/xenserver/requests/compute/create_vdi.rb,
lib/fog/xenserver/requests/compute/create_vif.rb,
lib/fog/xenserver/requests/compute/destroy_sr.rb,
lib/fog/xenserver/requests/compute/get_record.rb,
lib/fog/xenserver/requests/compute/insert_vbd.rb,
lib/fog/xenserver/requests/compute/unplug_pbd.rb,
lib/fog/xenserver/requests/compute/unplug_vbd.rb,
lib/fog/xenserver/requests/compute/create_vlan.rb,
lib/fog/xenserver/requests/compute/destroy_vdi.rb,
lib/fog/xenserver/requests/compute/destroy_vif.rb,
lib/fog/xenserver/requests/compute/enable_host.rb,
lib/fog/xenserver/requests/compute/get_records.rb,
lib/fog/xenserver/requests/compute/reboot_host.rb,
lib/fog/xenserver/requests/compute/clone_server.rb,
lib/fog/xenserver/requests/compute/destroy_vlan.rb,
lib/fog/xenserver/requests/compute/disable_host.rb,
lib/fog/xenserver/requests/compute/set_affinity.rb,
lib/fog/xenserver/requests/compute/start_server.rb,
lib/fog/xenserver/requests/compute/create_server.rb,
lib/fog/xenserver/requests/compute/reboot_server.rb,
lib/fog/xenserver/requests/compute/set_attribute.rb,
lib/fog/xenserver/requests/compute/shutdown_host.rb,
lib/fog/xenserver/requests/compute/create_network.rb,
lib/fog/xenserver/requests/compute/destroy_record.rb,
lib/fog/xenserver/requests/compute/destroy_server.rb,
lib/fog/xenserver/requests/compute/destroy_network.rb,
lib/fog/xenserver/requests/compute/shutdown_server.rb,
lib/fog/xenserver/requests/compute/snapshot_revert.rb,
lib/fog/xenserver/requests/compute/snapshot_server.rb,
lib/fog/xenserver/requests/compute/provision_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/fog/xenserver/compute.rb', line 121

def initialize(options={})
  @host                 = options[:xenserver_url]
  @username             = options[:xenserver_username]
  @password             = options[:xenserver_password]
  @defaults             = options[:xenserver_defaults] || {}
  @timeout              = options[:xenserver_timeout] || 30
  @redirect_to_master   = options[:xenserver_redirect_to_master] || false
  @connection           = Fog::XenServer::Connection.new(@host, @timeout)

  if @redirect_to_master == false
    @connection  = Fog::XenServer::Connection.new(@host, @timeout)
  elsif @redirect_to_master == true
    host_master  = @connection.find_pool_master(@username, @password)
    if host_master && host_master!= @host
      @host = host_master
      @connection  = Fog::XenServer::Connection.new(@host, @timeout)
    end
  end
  @connection.authenticate(@username, @password)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



119
120
121
# File 'lib/fog/xenserver/compute.rb', line 119

def connection
  @connection
end

Instance Method Details

#clone_server(server_name, template_ref) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/xenserver/requests/compute/clone_server.rb', line 5

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?
  raise ArgumentError.new("Invalid template_ref") if server_name.nil?

  ref = @connection.request(
      {:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.clone'},
      template_ref, server_name
  )
end

#create_network(name, config = {}) ⇒ Object

Create a Network



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/xenserver/requests/compute/create_network.rb', line 9

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 = {
      :name_label => name,
      # Description is mandatory in XenAPI but we default to empty
      :name_description => config[:description] || '',
      # Mandatory, but can be empty
      :other_config => {}
    }.merge config
  end

  @connection.request(
    {
      :parser => Fog::Parsers::XenServer::Base.new,
      :method => 'network.create'
    },
    default_config
  )
end

#create_server(name_label, template = nil, networks = [], extra_args = {}) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/fog/xenserver/requests/compute/create_server.rb', line 86

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

    if template.kind_of? String
      template_string = template
      # try template by UUID
      template = servers.templates.find { |s| s.uuid == template_string }
      if template.nil?
        # Try with the template name just in case
        template = servers.get get_vm_by_name(template_string)
      end
    end

    if template.nil?
      raise "Invalid template"
    end

    raise "Template #{template_string} does not exist" if template.allowed_operations.nil?
    raise 'Clone Operation not Allowed' unless template.allowed_operations.include?('clone')

    # Clone the VM template
    ref = clone_server name_label, template.reference
    # Add additional NICs
    networks.each do |n|
      create_vif ref, n.reference
    end
    if !extra_args[:auto_start] == false
      @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
      start_vm( ref )
    end
  end

  ref
end

#create_server_raw(config = {}) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fog/xenserver/requests/compute/create_server.rb', line 19

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]
  config.delete :__affinity
  raise ArgumentError.new("Invalid :name_label attribute") \
    if !config[:name_label]
  raise ArgumentError.new("Invalid :affinity attribute") \
    if not config[:affinity]
  config[:affinity] = config[:affinity].reference \
    if config[:affinity].kind_of? Fog::Compute::XenServer::Host
  config.reduce({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
  %w{ VCPUs_at_startup
      VCPUs_max
      VCPUs_params
      PV_bootloader_args
      PV_bootloader
      PV_kernel
      PV_ramdisk
      PV_legacy_args
      HVM_boot_policy
      HVM_boot_params
  }.each do |k|
    if config[k.downcase.to_sym]
      config[k.to_sym] = config[k.downcase.to_sym]
      config.delete k.downcase.to_sym
    end
  end
  vm_record = {
      :name_label =>              '',
      :name_description =>        'description',
      :user_version =>            '0',
      :affinity =>                '',
      :is_a_template =>           true,
      :auto_power_on =>           false,
      :memory_static_max =>       '536870912',
      :memory_static_min =>       '536870912',
      :memory_dynamic_max =>      '536870912',
      :memory_dynamic_min =>      '536870912',
      :VCPUs_params =>            {},
      :VCPUs_max =>               '1',
      :VCPUs_at_startup =>        '1',
      :actions_after_shutdown =>  'Destroy',
      :actions_after_reboot =>    'Restart',
      :actions_after_crash =>     'Restart',
      :platform =>                { :'nx' => 'true', :'acpi' => 'true', :'apic' => 'true', :'pae' => 'true', :'viridian' => 'true' },
      :other_config =>            {},
      :pool_name =>               '',
      :PV_bootloader =>           'pygrub', #pvgrub, eliloader
      :PV_kernel =>                '',
      :PV_ramdisk =>              '',
      :PV_args =>                 '-- quiet console=hvc0',
      :PV_bootloader_args =>      '',
      :PV_legacy_args =>          '',
      :HVM_boot_policy =>         '',
      :HVM_boot_params =>         {},
      :PCI_bus =>                 '',
      :recommendations =>         '',
  }.merge config
  ref = @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.create' }, vm_record)
  ref
end

#create_sr(host_ref, name_label, type = '', name_description = '', device_config = {}, physical_size = '0', content_type = 'user', shared = false, sm_config = {}) ⇒ String

Create a storage repository (SR)

{ :device => /dev/sdb } for example needs confirmation) According to Citrix documentation, used only to distinguish ISO libraries from other SRs. Set it to ‘iso’ for storage repositories that store a library of ISOs, ‘user’ or ” (empty) otherwise.

Parameters:

  • host_ref (String)

    host reference

  • name_label (String)

    repository label

  • type (String) (defaults to: '')

    storage repository type

  • name_description (String) (defaults to: '')

    storage repository description

  • device_config (Hash) (defaults to: {})

    used to specify block device path, like

  • physical_size (String) (defaults to: '0')

    ‘0’ will use the whole device (FIXME

  • content_type (String) (defaults to: 'user')

    the type of the SR’s content.

  • shared (String) (defaults to: false)

Returns:

  • (String)

    an OpaqueRef to the storage repository

See Also:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fog/xenserver/requests/compute/create_sr.rb', line 26

def create_sr( host_ref,
    name_label,
    type = '',
    name_description = '',
    device_config    = {},
    physical_size    = '0',
    content_type     = 'user',
    shared           = false,
    sm_config        = {} )

  if host_ref.is_a?(Hash)
    config = host_ref
    extra_params = name_label

    [: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

    [: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.'
    )

    @connection.request(
        {:parser => Fog::Parsers::XenServer::Base.new, :method => 'SR.create'},
        host_ref,
        device_config || {},
        physical_size || '0',
        name_label,
        name_description || '',
        type,
        content_type,
        shared || false,
        sm_config || {}
    )
  end
end

#create_vbd(vm_ref, vdi_ref = '', config = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/xenserver/requests/compute/create_vbd.rb', line 5

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
    config.reject! { |k,v| (k == :server) or (k == :vdi) }
    default_config = {
        :VM => vm_ref,
        :VDI => vdi_ref,
        :empty => false,
        :other_config => {'owner' => ''},
        :userdevice => "0",
        :bootable => true,
        :mode => 'RW',
        :qos_algorithm_type=> '',
        :qos_algorithm_params=> {},
        :qos_supported_algorithms=> [],
        :type => 'Disk'
    }.merge config
  end

  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.create'}, default_config )
end

#create_vdi(config) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/xenserver/requests/compute/create_vdi.rb', line 5

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?

  if config[:storage_repository].nil? && config[:SR].nil? && config[:__sr].nil?
    raise ArgumentError.new('Missing StorageRepository reference.')
  end

  unless config[:storage_repository].nil?
    Fog::Logger.deprecation(
        'The attribute #storage_repository is deprecated. Use #SR instead.'
    )
    config[:SR] = config[:storage_repository].reference
  end

  unless config[:__sr].nil?
    Fog::Logger.deprecation(
        'The attribute #__sr is deprecated. Use #SR instead.'
    )
    config[:SR] = config[:__sr]
  end

  unless config[:name].nil?
    Fog::Logger.deprecation(
        'The attribute #name is deprecated. Use #name_label instead.'
    )
    config[:name_label] = config[:name]
  end

  unless config[:description].nil?
    Fog::Logger.deprecation(
        'The attribute #description is deprecated. Use #name_description 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

#create_vif(vm_ref, network_ref, device = -1)) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/xenserver/requests/compute/create_vif.rb', line 5

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

#create_vif_custom(conf) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/fog/xenserver/requests/compute/create_vif.rb', line 18

def create_vif_custom( conf )
  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

#create_vlan(pif_ref, vlan_id, network_ref = '') ⇒ Object

Create a VLAN



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/xenserver/requests/compute/create_vlan.rb', line 10

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,
    tag,
    network_ref
  )
end

#default_networkObject



157
158
159
# File 'lib/fog/xenserver/compute.rb', line 157

def default_network
  networks.find { |n| n.name == (@defaults[:network] || "Pool-wide network associated with eth0") }
end

#default_templateObject



150
151
152
153
154
155
# File 'lib/fog/xenserver/compute.rb', line 150

def default_template
  return nil if @defaults[:template].nil?
  (servers.custom_templates + servers.builtin_templates).find do |s|
    (s.name == @defaults[:template]) or (s.uuid == @defaults[:template])
  end
end

#default_template=(name) ⇒ Object



146
147
148
# File 'lib/fog/xenserver/compute.rb', line 146

def default_template=(name)
  @defaults[:template] = name
end

#default_vif_config(vm_ref, network_ref, device_number = '-1') ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/xenserver/requests/compute/create_vif.rb', line 26

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' => '',
    '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

#destroy_network(ref) ⇒ Object

Destroy a Network



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/xenserver/requests/compute/destroy_network.rb', line 10

def destroy_network( ref )
  Fog::Logger.deprecation(
      'This method is deprecated. Use #destroy_record instead.'
  )
  @connection.request(
    {
      :parser => Fog::Parsers::XenServer::Base.new,
      :method => 'network.destroy'
    },
    ref
  )
end

#destroy_record(ref, provider_class) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/destroy_record.rb', line 5

def destroy_record(ref, provider_class)
  @connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => "#{provider_class}.destroy" }, ref)
end

#destroy_server(vm_ref, extra_args = {}) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/xenserver/requests/compute/destroy_server.rb', line 5

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

#destroy_sr(sr_ref) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/fog/xenserver/requests/compute/destroy_sr.rb', line 10

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
  )
end

#destroy_vdi(vdi_ref, extra_args = {}) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/xenserver/requests/compute/destroy_vdi.rb', line 5

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

#destroy_vif(ref, extra_args = {}) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/xenserver/requests/compute/destroy_vif.rb', line 5

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

#destroy_vlan(ref) ⇒ Object

Destroy a VLAN



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/xenserver/requests/compute/destroy_vlan.rb', line 9

def destroy_vlan( ref )
  Fog::Logger.deprecation(
      'This method is deprecated. Use #destroy_record instead.'
  )
  @connection.request(
    {
      :parser => Fog::Parsers::XenServer::Base.new,
      :method => 'VLAN.destroy'
    },
    ref
  )
end

#disable_host(ref) ⇒ Object

Puts the host into a state in which no new VMs can be started. Currently active VMs on the host continue to execute.



11
12
13
# File 'lib/fog/xenserver/requests/compute/disable_host.rb', line 11

def disable_host( ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "host.disable"}, ref)
end

#eject_vbd(ref, extra_args = {}) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/eject_vbd.rb', line 5

def eject_vbd(ref, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.eject'}, ref)
end

#enable_host(ref) ⇒ Object

Puts the host into a state in which VMs can be started.



10
11
12
# File 'lib/fog/xenserver/requests/compute/enable_host.rb', line 10

def enable_host( ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "host.enable"}, ref)
end

#get_by_name(name, provider_class) ⇒ Object



15
16
17
# File 'lib/fog/xenserver/requests/compute/get_record.rb', line 15

def get_by_name(name, provider_class)
  @connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => "#{provider_class}.get_by_name_label" }, name)
end

#get_by_uuid(uuid, provider_class) ⇒ Object



19
20
21
# File 'lib/fog/xenserver/requests/compute/get_record.rb', line 19

def get_by_uuid(uuid, provider_class)
  @connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => "#{provider_class}.get_by_uuid" }, uuid)
end

#get_record(ref, klass, options = {}) ⇒ Object



7
8
9
# File 'lib/fog/xenserver/requests/compute/get_record.rb', line 7

def get_record( ref, klass, options = {} )
  get_record_by_ref ref, klass, options
end

#get_record_by_ref(ref, klass, options = {}) ⇒ Object



11
12
13
# File 'lib/fog/xenserver/requests/compute/get_record.rb', line 11

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

#get_records(klass, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/fog/xenserver/requests/compute/get_records.rb', line 7

def get_records( klass, options = {} )
  begin
    res = @connection.request(:parser => Fog::Parsers::XenServer::GetRecords.new, :method => "#{klass}.get_all_records")
    res
  rescue Fog::XenServer::RequestFailed => e
    []
  end
end

#get_vm_by_name(label) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/xenserver/requests/compute/create_server.rb', line 5

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

#get_vm_by_uuid(uuid) ⇒ Object



12
13
14
15
16
17
# File 'lib/fog/xenserver/requests/compute/create_server.rb', line 12

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

#insert_vbd(ref, vdi_ref, extra_args = {}) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/insert_vbd.rb', line 5

def insert_vbd(ref, vdi_ref, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.insert'}, ref, vdi_ref)
end

#provision_server(ref) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/provision_server.rb', line 5

def provision_server( ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
end

#reboot_host(ref) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/reboot_host.rb', line 5

def reboot_host( ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "host.reboot"}, ref)
end

#reboot_server(ref, stype = 'clean') ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/reboot_server.rb', line 5

def reboot_server( ref, stype = 'clean' )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "VM.#{stype}_reboot"}, ref)
end

#reloadObject



142
143
144
# File 'lib/fog/xenserver/compute.rb', line 142

def reload
  @connection.authenticate(@username, @password)
end

#revert_server(snapshot_ref, extra_args = {}) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/snapshot_revert.rb', line 5

def revert_server( snapshot_ref, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.revert'}, snapshot_ref)
end

#scan_sr(ref, extra_args = {}) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/scan_sr.rb', line 5

def scan_sr( ref, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'SR.scan'}, ref)
end

#set_affinity(host_ref) ⇒ Object



7
8
9
# File 'lib/fog/xenserver/requests/compute/set_affinity.rb', line 7

def set_affinity( host_ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.set_affinity'}, host_ref)
end

#set_attribute(klass, ref, attr_name, *value) ⇒ Object



7
8
9
# File 'lib/fog/xenserver/requests/compute/set_attribute.rb', line 7

def set_attribute( klass, ref, attr_name, *value )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "#{klass}.set_#{attr_name.gsub('-','_')}"}, ref, *value)
end

#shutdown_host(ref) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/shutdown_host.rb', line 5

def shutdown_host( ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "host.shutdown"}, ref)
end

#shutdown_server(vm_ref, stype = 'clean') ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/shutdown_server.rb', line 5

def shutdown_server( vm_ref, stype = 'clean' )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => "VM.#{stype}_shutdown"}, vm_ref)
end

#snapshot_revert(snapshot_ref, extra_args = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/fog/xenserver/requests/compute/snapshot_revert.rb', line 9

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

#snapshot_server(vm_ref, name, extra_args = {}) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/snapshot_server.rb', line 5

def snapshot_server( vm_ref , name, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.snapshot'}, vm_ref, name)
end

#start_server(vm_ref) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/start_server.rb', line 5

def start_server( vm_ref )
  start_vm( vm_ref )
end

#start_vm(vm_ref) ⇒ Object

bit.ly/8ZPyCN VM.start( session, VM_ref, start_paused, force)



7
8
9
# File 'lib/fog/xenserver/requests/compute/start_vm.rb', line 7

def start_vm( vm_ref )
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.start'}, vm_ref, false, false)
end

#unplug_force_vbd(ref, extra_args = {}) ⇒ Object



9
10
11
# File 'lib/fog/xenserver/requests/compute/unplug_vbd.rb', line 9

def unplug_force_vbd(ref, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.unplug_force'}, ref)
end

#unplug_pbd(ref) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/xenserver/requests/compute/unplug_pbd.rb', line 5

def unplug_pbd( ref )
  @connection.request(
    {:parser => Fog::Parsers::XenServer::Base.new, :method => 'PBD.unplug'},
    ref
  )
end

#unplug_vbd(vbd_ref, extra_args = {}) ⇒ Object



5
6
7
# File 'lib/fog/xenserver/requests/compute/unplug_vbd.rb', line 5

def unplug_vbd( vbd_ref, extra_args = {})
  @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.unplug'}, vbd_ref)
end