Class: Fog::Compute::Ovirt::Real

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/fog/ovirt/compute.rb,
lib/fog/ovirt/requests/compute/create_vm.rb,
lib/fog/ovirt/requests/compute/update_vm.rb,
lib/fog/ovirt/requests/compute/vm_action.rb,
lib/fog/ovirt/requests/compute/destroy_vm.rb,
lib/fog/ovirt/requests/compute/datacenters.rb,
lib/fog/ovirt/requests/compute/get_cluster.rb,
lib/fog/ovirt/requests/compute/get_template.rb,
lib/fog/ovirt/requests/compute/list_clusters.rb,
lib/fog/ovirt/requests/compute/list_templates.rb,
lib/fog/ovirt/requests/compute/storage_domains.rb,
lib/fog/ovirt/requests/compute/get_virtual_machine.rb,
lib/fog/ovirt/requests/compute/list_virtual_machines.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared

#ovirt_attrs

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fog/ovirt/compute.rb', line 78

def initialize(options={})
  require 'rbovirt'
  username   = options[:ovirt_username]
  password   = options[:ovirt_password]
  server     = options[:ovirt_server]
  port       = options[:ovirt_port]       || 8080
  api_path   = options[:ovirt_api_path]   || '/api'
  url        = options[:ovirt_url]        || "#{@scheme}://#{server}:#{port}#{api_path}"
  datacenter = options[:ovirt_datacenter]

  @client = OVIRT::Client.new(username, password, url, datacenter)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



76
77
78
# File 'lib/fog/ovirt/compute.rb', line 76

def client
  @client
end

Instance Method Details

#create_vm(attrs) ⇒ Object



6
7
8
# File 'lib/fog/ovirt/requests/compute/create_vm.rb', line 6

def create_vm(attrs)
  client.create_vm(attrs)
end

#datacenters(filter = {}) ⇒ Object



6
7
8
# File 'lib/fog/ovirt/requests/compute/datacenters.rb', line 6

def datacenters filter={}
  client.datacenters(filter).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#destroy_vm(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/fog/ovirt/requests/compute/destroy_vm.rb', line 6

def destroy_vm(options = {})
  raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
  client.destroy_vm(options[:id])
end

#get_cluster(id) ⇒ Object



5
6
7
# File 'lib/fog/ovirt/requests/compute/get_cluster.rb', line 5

def get_cluster(id)
  ovirt_attrs client.cluster(id)
end

#get_template(id) ⇒ Object



5
6
7
# File 'lib/fog/ovirt/requests/compute/get_template.rb', line 5

def get_template(id)
  ovirt_attrs client.template(id)
end

#get_virtual_machine(id) ⇒ Object



5
6
7
# File 'lib/fog/ovirt/requests/compute/get_virtual_machine.rb', line 5

def get_virtual_machine(id)
  ovirt_attrs client.vm(id)
end

#list_clusters(filters = {}) ⇒ Object



5
6
7
# File 'lib/fog/ovirt/requests/compute/list_clusters.rb', line 5

def list_clusters(filters = {})
  client.clusters(filters).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#list_templates(filters = {}) ⇒ Object



5
6
7
# File 'lib/fog/ovirt/requests/compute/list_templates.rb', line 5

def list_templates(filters = {})
  client.templates(filters).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#list_virtual_machines(filters = {}) ⇒ Object



5
6
7
# File 'lib/fog/ovirt/requests/compute/list_virtual_machines.rb', line 5

def list_virtual_machines(filters = {})
  client.vms(filters).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#storage_domains(filter = {}) ⇒ Object



6
7
8
# File 'lib/fog/ovirt/requests/compute/storage_domains.rb', line 6

def storage_domains filter={}
  client.storagedomains(filter).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#update_vm(attrs) ⇒ Object



6
7
8
# File 'lib/fog/ovirt/requests/compute/update_vm.rb', line 6

def update_vm(attrs)
  client.update_vm(attrs)
end

#vm_action(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
# File 'lib/fog/ovirt/requests/compute/vm_action.rb', line 6

def vm_action(options = {})
  raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
  raise ArgumentError, "action is a required parameter" unless options.has_key? :action

  client.vm_action options[:id], options[:action]
end