Class: Fog::Compute::XenServer::Servers
Instance Attribute Summary
#service
Instance Method Summary
collapse
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#connection, #connection=, #prepare_service_value
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Instance Method Details
#all(options = {}) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 36
def all(options = {})
data = service.get_records 'VM'
data.delete_if { |vm| vm[:is_control_domain] or vm[:is_a_template] }
data.delete_if { |vm| vm[:is_a_snapshot] and !options[:include_snapshots] }
data.delete_if { |vm| options[:name_matches] and (vm[:name_label] !~ /#{Regexp.escape(options[:name_matches])}/i ) }
data.delete_if { |vm| options[:name_equals] and (vm[:name_label] != options[:name_equals] ) }
load(data)
end
|
#builtin_templates ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 28
def builtin_templates
data = service.get_records 'VM'
data.delete_if do |vm|
!vm[:is_a_template] or vm[:other_config]['default_template'].nil?
end
load(data)
end
|
#custom_templates ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 20
def custom_templates
data = service.get_records 'VM'
data.delete_if do |vm|
!vm[:is_a_template] or !vm[:other_config]['default_template'].nil?
end
load(data)
end
|
#get(vm_ref) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 56
def get( vm_ref )
if vm_ref && vm = service.get_record( vm_ref, 'VM' )
new(vm)
end
rescue Fog::XenServer::NotFound
nil
end
|
#get_by_name(name) ⇒ Object
46
47
48
49
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 46
def get_by_name( name )
ref = service.get_vm_by_name( name )
get ref
end
|
#get_by_uuid(uuid) ⇒ Object
51
52
53
54
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 51
def get_by_uuid( uuid )
ref = service.get_vm_by_uuid( uuid )
get ref
end
|
#templates ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/fog/xenserver/models/compute/servers.rb', line 12
def templates
data = service.get_records 'VM'
data.delete_if do |vm|
!vm[:is_a_template]
end
load(data)
end
|