Class: Fog::Compute::Ovirt::Mock
- Inherits:
-
Object
- Object
- Fog::Compute::Ovirt::Mock
- 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
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #create_vm(attrs) ⇒ Object
- #datacenters(filters = {}) ⇒ Object
- #destroy_vm(options = {}) ⇒ Object
- #get_cluster(id) ⇒ Object
- #get_template(id) ⇒ Object
- #get_virtual_machine(id) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_clusters(filters = {}) ⇒ Object
- #list_templates(filters = {}) ⇒ Object
- #list_virtual_machines(filters = {}) ⇒ Object
- #storage_domains(filters = {}) ⇒ Object
- #update_vm(attrs) ⇒ Object
- #vm_action(options = {}) ⇒ Object
Methods included from Shared
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
59 60 61 62 63 64 |
# File 'lib/fog/ovirt/compute.rb', line 59 def initialize(={}) require 'rbovirt' username = [:ovirt_username] password = [:ovirt_password] url = [:ovirt_url] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
57 58 59 |
# File 'lib/fog/ovirt/compute.rb', line 57 def client @client end |
Instance Method Details
#create_vm(attrs) ⇒ Object
12 13 14 15 |
# File 'lib/fog/ovirt/requests/compute/create_vm.rb', line 12 def create_vm(attrs) xml = read_xml('vm.xml') OVIRT::VM::new(self, Nokogiri::XML(xml).root) end |
#datacenters(filters = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/fog/ovirt/requests/compute/datacenters.rb', line 13 def datacenters(filters = {}) xml = read_xml 'data_centers.xml' Nokogiri::XML(xml).xpath('/data_centers/data_center').collect do |dc| ovirt_attrs OVIRT::DataCenter::new(self, dc) end end |
#destroy_vm(options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/fog/ovirt/requests/compute/destroy_vm.rb', line 14 def destroy_vm( = {}) raise ArgumentError, "instance id is a required parameter" unless .has_key? :id true end |
#get_cluster(id) ⇒ Object
11 12 13 14 |
# File 'lib/fog/ovirt/requests/compute/get_cluster.rb', line 11 def get_cluster(id) xml = read_xml('cluster.xml') ovirt_attrs OVIRT::Cluster::new(self, Nokogiri::XML(xml).root) end |
#get_template(id) ⇒ Object
11 12 13 14 |
# File 'lib/fog/ovirt/requests/compute/get_template.rb', line 11 def get_template(id) xml = read_xml 'template.xml' ovirt_attrs OVIRT::Template::new(self, Nokogiri::XML(xml).root) end |
#get_virtual_machine(id) ⇒ Object
11 12 13 14 |
# File 'lib/fog/ovirt/requests/compute/get_virtual_machine.rb', line 11 def get_virtual_machine(id) xml = read_xml 'vm.xml' ovirt_attrs OVIRT::VM::new(self, Nokogiri::XML(xml).root) end |
#list_clusters(filters = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/fog/ovirt/requests/compute/list_clusters.rb', line 11 def list_clusters(filters = {}) xml = read_xml 'clusters.xml' Nokogiri::XML(xml).xpath('/clusters/cluster').collect do |cl| ovirt_attrs OVIRT::Cluster::new(self, cl) end end |
#list_templates(filters = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/fog/ovirt/requests/compute/list_templates.rb', line 11 def list_templates(filters = {}) xml = read_xml 'templates.xml' Nokogiri::XML(xml).xpath('/templates/template').collect do |t| ovirt_attrs OVIRT::Template::new(self, t) end end |
#list_virtual_machines(filters = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/fog/ovirt/requests/compute/list_virtual_machines.rb', line 11 def list_virtual_machines(filters = {}) xml = read_xml 'vms.xml' Nokogiri::XML(xml).xpath('/vms/vm').collect do |vm| ovirt_attrs OVIRT::VM::new(self, vm) end end |
#storage_domains(filters = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/fog/ovirt/requests/compute/storage_domains.rb', line 13 def storage_domains(filters = {}) xml = read_xml 'storage_domains.xml' Nokogiri::XML(xml).xpath('/storage_domains/storage_domain').collect do |sd| ovirt_attrs OVIRT::StorageDomain::new(self, sd) end end |
#update_vm(attrs) ⇒ Object
12 13 14 15 |
# File 'lib/fog/ovirt/requests/compute/update_vm.rb', line 12 def update_vm(attrs) xml = read_xml('vm.xml') OVIRT::VM::new(self, Nokogiri::XML(xml).root) end |
#vm_action(options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/fog/ovirt/requests/compute/vm_action.rb', line 17 def vm_action( = {}) raise ArgumentError, "id is a required parameter" unless .has_key? :id raise ArgumentError, "action is a required parameter" unless .has_key? :action true end |