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/get_quota.rb,
lib/fog/ovirt/requests/compute/update_vm.rb,
lib/fog/ovirt/requests/compute/vm_action.rb,
lib/fog/ovirt/requests/compute/vm_ticket.rb,
lib/fog/ovirt/requests/compute/add_volume.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/list_quotas.rb,
lib/fog/ovirt/requests/compute/get_template.rb,
lib/fog/ovirt/requests/compute/add_interface.rb,
lib/fog/ovirt/requests/compute/list_clusters.rb,
lib/fog/ovirt/requests/compute/list_networks.rb,
lib/fog/ovirt/requests/compute/destroy_volume.rb,
lib/fog/ovirt/requests/compute/list_templates.rb,
lib/fog/ovirt/requests/compute/get_api_version.rb,
lib/fog/ovirt/requests/compute/list_vm_volumes.rb,
lib/fog/ovirt/requests/compute/storage_domains.rb,
lib/fog/ovirt/requests/compute/update_interface.rb,
lib/fog/ovirt/requests/compute/destroy_interface.rb,
lib/fog/ovirt/requests/compute/list_vm_interfaces.rb,
lib/fog/ovirt/requests/compute/get_virtual_machine.rb,
lib/fog/ovirt/requests/compute/list_template_volumes.rb,
lib/fog/ovirt/requests/compute/list_virtual_machines.rb,
lib/fog/ovirt/requests/compute/list_template_interfaces.rb

Constant Summary collapse

DISK_SIZE_TO_GB =
1073741824

Instance Method Summary collapse

Methods included from Shared

#ovirt_attrs

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/fog/ovirt/compute.rb', line 102

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 Method Details

#add_interface(id, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


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

def add_interface(id, options = {})
  raise ArgumentError, "instance id is a required parameter" unless id

  client.add_interface(id, options)
end

#add_volume(id, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


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

def add_volume(id, options = {})
  raise ArgumentError, "instance id is a required parameter" unless id
  options[:size]=options[:size_gb].to_i*DISK_SIZE_TO_GB if options[:size_gb]
  client.add_volume(id, options)
end

#api_versionObject



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

def api_version
  client.api_version
end

#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_interface(id, options) ⇒ Object

Raises:

  • (ArgumentError)


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

def destroy_interface(id, options)
  raise ArgumentError, "instance id is a required parameter" unless id
  raise ArgumentError, "interface id is a required parameter for destroy-interface" unless options.has_key? :id

  client.destroy_interface(id, options[:id])
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

#destroy_volume(id, options) ⇒ Object

Raises:

  • (ArgumentError)


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

def destroy_volume(id, options)
  raise ArgumentError, "instance id is a required parameter" unless id
  raise ArgumentError, "volume id is a required parameter for destroy-volume" unless options.has_key? :id

  client.destroy_volume(id, 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_quota(id) ⇒ Object



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

def get_quota(id)
  ovirt_attrs client.quota(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_networks(cluster_id) ⇒ Object



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

def list_networks(cluster_id)
  client.networks(:cluster_id => cluster_id)
end

#list_quotas(filters = {}) ⇒ Object



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

def list_quotas(filters = {})
  client.quotas(filters).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#list_template_interfaces(vm_id) ⇒ Object



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

def list_template_interfaces(vm_id)
  client.template_interfaces(vm_id).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#list_template_volumes(template_id) ⇒ Object



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

def list_template_volumes(template_id)
  client.template_volumes(template_id).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

#list_vm_interfaces(vm_id) ⇒ Object



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

def list_vm_interfaces(vm_id)
  client.vm_interfaces(vm_id).map {|ovirt_obj| ovirt_attrs ovirt_obj}
end

#list_vm_volumes(vm_id) ⇒ Object



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

def list_vm_volumes(vm_id)
  client.vm_volumes(vm_id).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)
end

#update_interface(id, options) ⇒ Object

Raises:

  • (ArgumentError)


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

def update_interface(id, options)
  raise ArgumentError, "instance id is a required parameter" unless id
  raise ArgumentError, "interface id is a required parameter for update-interface" unless options.has_key? :id

  client.update_interface(id, options)
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

#vm_ticket(id, options = {}) ⇒ Object



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

def vm_ticket(id, options = {})
  client.set_ticket(id, options)
end