Class: Fog::Compute::Ovirt::Real
- Inherits:
-
Object
- Object
- Fog::Compute::Ovirt::Real
- 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
- #add_interface(id, options = {}) ⇒ Object
- #add_volume(id, options = {}) ⇒ Object
- #api_version ⇒ Object
- #create_vm(attrs) ⇒ Object
- #datacenters(filter = {}) ⇒ Object
- #destroy_interface(id, options) ⇒ Object
- #destroy_vm(options = {}) ⇒ Object
- #destroy_volume(id, options) ⇒ Object
- #get_cluster(id) ⇒ Object
- #get_quota(id) ⇒ Object
- #get_template(id) ⇒ Object
- #get_virtual_machine(id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_clusters(filters = {}) ⇒ Object
- #list_networks(cluster_id) ⇒ Object
- #list_quotas(filters = {}) ⇒ Object
- #list_template_interfaces(vm_id) ⇒ Object
- #list_template_volumes(template_id) ⇒ Object
- #list_templates(filters = {}) ⇒ Object
- #list_virtual_machines(filters = {}) ⇒ Object
- #list_vm_interfaces(vm_id) ⇒ Object
- #list_vm_volumes(vm_id) ⇒ Object
- #storage_domains(filter = {}) ⇒ Object
- #update_interface(id, options) ⇒ Object
- #update_vm(attrs) ⇒ Object
- #vm_action(options = {}) ⇒ Object
- #vm_ticket(id, options = {}) ⇒ Object
Methods included from Shared
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fog/ovirt/compute.rb', line 100 def initialize(={}) require 'rbovirt' username = [:ovirt_username] password = [:ovirt_password] server = [:ovirt_server] port = [:ovirt_port] || 8080 api_path = [:ovirt_api_path] || '/api' url = [:ovirt_url] || "#{@scheme}://#{server}:#{port}#{api_path}" datacenter = [:ovirt_datacenter] @client = OVIRT::Client.new(username, password, url, datacenter) end |
Instance Method Details
#add_interface(id, options = {}) ⇒ Object
6 7 8 9 10 |
# File 'lib/fog/ovirt/requests/compute/add_interface.rb', line 6 def add_interface(id, = {}) raise ArgumentError, "instance id is a required parameter" unless id client.add_interface(id, ) end |
#add_volume(id, options = {}) ⇒ Object
6 7 8 9 10 |
# File 'lib/fog/ovirt/requests/compute/add_volume.rb', line 6 def add_volume(id, = {}) raise ArgumentError, "instance id is a required parameter" unless id [:size]=[:size_gb].to_i*DISK_SIZE_TO_GB if [:size_gb] client.add_volume(id, ) end |
#api_version ⇒ Object
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
6 7 8 9 10 11 |
# File 'lib/fog/ovirt/requests/compute/destroy_interface.rb', line 6 def destroy_interface(id, ) raise ArgumentError, "instance id is a required parameter" unless id raise ArgumentError, "interface id is a required parameter for destroy-interface" unless .has_key? :id client.destroy_interface(id, [:id]) end |
#destroy_vm(options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/fog/ovirt/requests/compute/destroy_vm.rb', line 6 def destroy_vm( = {}) raise ArgumentError, "instance id is a required parameter" unless .has_key? :id client.destroy_vm([:id]) end |
#destroy_volume(id, options) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/ovirt/requests/compute/destroy_volume.rb', line 6 def destroy_volume(id, ) raise ArgumentError, "instance id is a required parameter" unless id raise ArgumentError, "volume id is a required parameter for destroy-volume" unless .has_key? :id client.destroy_volume(id, [: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
6 7 8 9 10 11 |
# File 'lib/fog/ovirt/requests/compute/update_interface.rb', line 6 def update_interface(id, ) raise ArgumentError, "instance id is a required parameter" unless id raise ArgumentError, "interface id is a required parameter for update-interface" unless .has_key? :id client.update_interface(id, ) 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
6 7 8 9 10 11 |
# File 'lib/fog/ovirt/requests/compute/vm_action.rb', line 6 def vm_action( = {}) raise ArgumentError, "instance id is a required parameter" unless .has_key? :id raise ArgumentError, "action is a required parameter" unless .has_key? :action client.vm_action [:id], [: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, = {}) client.set_ticket(id, ) end |