Class: Xencap::SessionProxy::Vm

Inherits:
Xencap::SessionProxy show all
Defined in:
lib/xencap/session_proxy/vm.rb

Instance Method Summary collapse

Methods inherited from Xencap::SessionProxy

#_request, #clone, #find_all_records, #find_record, #method_missing

Constructor Details

#initialize(session) ⇒ Vm

Returns a new instance of Vm.



2
3
4
5
# File 'lib/xencap/session_proxy/vm.rb', line 2

def initialize(session)
  @session = session
  @scope = "VM"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Xencap::SessionProxy

Instance Method Details

#clone_template(template_name, name) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/xencap/session_proxy/vm.rb', line 25

def clone_template(template_name, name)
  template_ref, template_record = get_all_records.detect do |ref, record|
    record['is_a_template'] == true && record['name_label'] == template_name
  end
  ref = clone(template_ref, name)
  set_is_a_template(ref, false)
  ref
end

#get_control_dom0Object



7
8
9
10
11
# File 'lib/xencap/session_proxy/vm.rb', line 7

def get_control_dom0
  get_all_records.select do |vm|
    vm['is_control_domain']
  end
end

#get_templatesObject



13
14
15
16
17
# File 'lib/xencap/session_proxy/vm.rb', line 13

def get_templates
  get_all_records.select do |vm|
    vm['is_a_template']
  end
end

#get_vmsObject



19
20
21
22
23
# File 'lib/xencap/session_proxy/vm.rb', line 19

def get_vms
  get_all_records.reject do |vm, params|
    params['is_a_template'] || params['is_control_domain']
  end
end