foreman_xen 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/xen_compute_helper.rb +21 -21
- data/app/models/foreman_xen/xenserver.rb +23 -30
- data/lib/foreman_xen/engine.rb +1 -1
- data/lib/foreman_xen/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7970c57af652a76865ce11386d3f96d2ad5cd789
|
4
|
+
data.tar.gz: 8b7a10b16676968ce4a50fcb3d3bc59c5f3248c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e45718f60595e04ccf5b634df462952bf7494881966b4519c2120ebae45a2f5c3a080f525236fff92f2625eb16146d0e62f1ff4b827692fbfc8d259965ee1d5
|
7
|
+
data.tar.gz: c3106ac70bdc20df5c749d63d89dd26234700f3a6e2005645870e5883209408befbbbfcf357bc68b0727e81b69faf18c7e5d2f8987afaf8e0f13001d3d1a0297
|
@@ -30,31 +30,31 @@ module XenComputeHelper
|
|
30
30
|
if new_host?(new)
|
31
31
|
compute_attributes = compute_resource.compute_profile_attributes_for(params['host']['compute_profile_id'])
|
32
32
|
if compute_attributes['VBDs']
|
33
|
-
attribute_map[:volume_size] = compute_attributes['VBDs']['physical_size']
|
34
|
-
attribute_map[:volume_selected] = compute_attributes['VBDs']['sr_uuid']
|
33
|
+
attribute_map[:volume_size] = compute_attributes['VBDs']['physical_size']
|
34
|
+
attribute_map[:volume_selected] = compute_attributes['VBDs']['sr_uuid']
|
35
35
|
end
|
36
36
|
if compute_attributes['VIFs']
|
37
|
-
attribute_map[:network_selected] = compute_attributes['VIFs']['print']
|
37
|
+
attribute_map[:network_selected] = compute_attributes['VIFs']['print']
|
38
38
|
end
|
39
|
-
attribute_map[:template_selected_custom] = compute_attributes['custom_template_name']
|
40
|
-
attribute_map[:template_selected_builtin] = compute_attributes['builtin_template_name']
|
41
|
-
attribute_map[:cpu_count] = compute_attributes['vcpus_max']
|
42
|
-
attribute_map[:memory_min] = compute_attributes['memory_min']
|
43
|
-
attribute_map[:memory_max] = compute_attributes['memory_max']
|
44
|
-
attribute_map[:power_on] = compute_attributes['start']
|
39
|
+
attribute_map[:template_selected_custom] = compute_attributes['custom_template_name']
|
40
|
+
attribute_map[:template_selected_builtin] = compute_attributes['builtin_template_name']
|
41
|
+
attribute_map[:cpu_count] = compute_attributes['vcpus_max']
|
42
|
+
attribute_map[:memory_min] = compute_attributes['memory_min']
|
43
|
+
attribute_map[:memory_max] = compute_attributes['memory_max']
|
44
|
+
attribute_map[:power_on] = compute_attributes['start']
|
45
45
|
elsif new
|
46
46
|
attribute_map[:cpu_count] = new.vcpus_max ? new.vcpus_max : nil
|
47
47
|
attribute_map[:memory_min] = new.memory_static_min ? new.memory_static_min : nil
|
48
48
|
attribute_map[:memory_max] = new.memory_static_max ? new.memory_static_max : nil
|
49
|
-
if new.
|
49
|
+
if new.vbds
|
50
50
|
vdi = new.vbds.first.vdi
|
51
51
|
if vdi
|
52
52
|
attribute_map[:volume_selected] = vdi.sr.uuid ? vdi.sr.uuid : nil
|
53
53
|
attribute_map[:volume_size] = vdi.virtual_size ? (vdi.virtual_size.to_i / 1_073_741_824).to_s : nil
|
54
54
|
end
|
55
55
|
end
|
56
|
-
if new.
|
57
|
-
attribute_map[:network_selected] = new.
|
56
|
+
if new.vifs
|
57
|
+
attribute_map[:network_selected] = new.vifs.first.network.name ? new.vifs.first.network.name : nil
|
58
58
|
end
|
59
59
|
end
|
60
60
|
attribute_map
|
@@ -69,18 +69,18 @@ module XenComputeHelper
|
|
69
69
|
end
|
70
70
|
if compute_attributes
|
71
71
|
if compute_attributes['VBDs']
|
72
|
-
attribute_map[:volume_size] = compute_attributes['VBDs']['physical_size']
|
73
|
-
attribute_map[:volume_selected] = compute_attributes['VBDs']['sr_uuid']
|
72
|
+
attribute_map[:volume_size] = compute_attributes['VBDs']['physical_size']
|
73
|
+
attribute_map[:volume_selected] = compute_attributes['VBDs']['sr_uuid']
|
74
74
|
end
|
75
75
|
if compute_attributes['VIFs']
|
76
|
-
attribute_map[:network_selected] = compute_attributes['VIFs']['print']
|
76
|
+
attribute_map[:network_selected] = compute_attributes['VIFs']['print']
|
77
77
|
end
|
78
|
-
attribute_map[:template_selected_custom] = compute_attributes['custom_template_name']
|
79
|
-
attribute_map[:template_selected_builtin] = compute_attributes['builtin_template_name']
|
80
|
-
attribute_map[:cpu_count] = compute_attributes['vcpus_max']
|
81
|
-
attribute_map[:memory_min] = compute_attributes['memory_min']
|
82
|
-
attribute_map[:memory_max] = compute_attributes['memory_max']
|
83
|
-
attribute_map[:power_on] = compute_attributes['start']
|
78
|
+
attribute_map[:template_selected_custom] = compute_attributes['custom_template_name']
|
79
|
+
attribute_map[:template_selected_builtin] = compute_attributes['builtin_template_name']
|
80
|
+
attribute_map[:cpu_count] = compute_attributes['vcpus_max']
|
81
|
+
attribute_map[:memory_min] = compute_attributes['memory_min']
|
82
|
+
attribute_map[:memory_max] = compute_attributes['memory_max']
|
83
|
+
attribute_map[:power_on] = compute_attributes['start']
|
84
84
|
end
|
85
85
|
attribute_map
|
86
86
|
end
|
@@ -2,10 +2,13 @@ module ForemanXen
|
|
2
2
|
class Xenserver < ComputeResource
|
3
3
|
validates :url, :user, :password, :presence => true
|
4
4
|
|
5
|
+
attr_accessible :uuid
|
6
|
+
|
5
7
|
def provided_attributes
|
6
8
|
super.merge(
|
7
9
|
:uuid => :reference,
|
8
|
-
:mac => :mac
|
10
|
+
:mac => :mac
|
11
|
+
)
|
9
12
|
end
|
10
13
|
|
11
14
|
def capabilities
|
@@ -89,13 +92,12 @@ module ForemanXen
|
|
89
92
|
found = 0
|
90
93
|
|
91
94
|
hosts.each do |host|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
95
|
+
next unless sr.reference == host.suspend_image_sr
|
96
|
+
found = 1
|
97
|
+
subresults[:name] = sr.name
|
98
|
+
subresults[:display_name] = sr.name + '(' + host.hostname + ')'
|
99
|
+
subresults[:uuid] = sr.uuid
|
100
|
+
break
|
99
101
|
end
|
100
102
|
|
101
103
|
if found == 0
|
@@ -190,10 +192,8 @@ module ForemanXen
|
|
190
192
|
end
|
191
193
|
|
192
194
|
def create_vm(args = {})
|
193
|
-
custom_template_name = args[:custom_template_name]
|
194
|
-
builtin_template_name = args[:builtin_template_name]
|
195
|
-
custom_template_name = custom_template_name.to_s
|
196
|
-
builtin_template_name = builtin_template_name.to_s
|
195
|
+
custom_template_name = args[:custom_template_name].to_s
|
196
|
+
builtin_template_name = args[:builtin_template_name].to_s
|
197
197
|
|
198
198
|
if builtin_template_name != '' && custom_template_name != ''
|
199
199
|
logger.info "custom_template_name: #{custom_template_name}"
|
@@ -201,20 +201,13 @@ module ForemanXen
|
|
201
201
|
raise 'you can select at most one template type'
|
202
202
|
end
|
203
203
|
begin
|
204
|
-
vm = nil
|
205
204
|
logger.info "create_vm(): custom_template_name: #{custom_template_name}"
|
206
205
|
logger.info "create_vm(): builtin_template_name: #{builtin_template_name}"
|
207
206
|
vm = (custom_template_name != '') ? create_vm_from_custom(args) : create_vm_from_builtin(args)
|
208
207
|
vm.set_attribute('name_description', 'Provisioned by Foreman')
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
vm.set_attribute('VCPUs_at_startup', cpus)
|
213
|
-
else
|
214
|
-
vm.set_attribute('VCPUs_at_startup', cpus)
|
215
|
-
vm.set_attribute('VCPUs_max', cpus)
|
216
|
-
end
|
217
|
-
vm.refresh
|
208
|
+
vm.set_attribute('VCPUs_at_startup', args[:vcpus_max])
|
209
|
+
vm.set_attribute('VCPUs_max', args[:vcpus_max])
|
210
|
+
vm.reload
|
218
211
|
return vm
|
219
212
|
rescue => e
|
220
213
|
logger.info e
|
@@ -321,13 +314,13 @@ module ForemanXen
|
|
321
314
|
:memory_dynamic_min => mem_min
|
322
315
|
|
323
316
|
vm.save :auto_start => false
|
324
|
-
client.vbds.create :
|
317
|
+
client.vbds.create :vm => vm, :vdi => vdi
|
325
318
|
|
326
319
|
create_network(vm, args)
|
327
320
|
|
328
321
|
vm.provision
|
329
322
|
vm.set_attribute('HVM_boot_policy', 'BIOS order')
|
330
|
-
vm.
|
323
|
+
vm.reload
|
331
324
|
vm
|
332
325
|
end
|
333
326
|
|
@@ -335,7 +328,7 @@ module ForemanXen
|
|
335
328
|
vm = find_vm_by_uuid(uuid)
|
336
329
|
raise 'VM is not running!' unless vm.ready?
|
337
330
|
|
338
|
-
console = vm.service.consoles.find { |c| c.
|
331
|
+
console = vm.service.consoles.find { |c| c.vm && c.vm.reference == vm.reference && c.protocol == 'rfb' }
|
339
332
|
raise "No console for vm #{vm.name}" if console.nil?
|
340
333
|
|
341
334
|
session_ref = (vm.service.instance_variable_get :@connection).instance_variable_get :@credentials
|
@@ -387,17 +380,17 @@ module ForemanXen
|
|
387
380
|
def create_network(vm, args)
|
388
381
|
net = client.networks.find { |n| n.name == args[:VIFs][:print] }
|
389
382
|
net_config = {
|
390
|
-
'
|
391
|
-
'
|
383
|
+
'mac_autogenerated' => 'True',
|
384
|
+
'vm' => vm.reference,
|
392
385
|
'network' => net.reference,
|
393
|
-
'
|
386
|
+
'mac' => '',
|
394
387
|
'device' => '0',
|
395
|
-
'
|
388
|
+
'mtu' => '0',
|
396
389
|
'other_config' => {},
|
397
390
|
'qos_algorithm_type' => 'ratelimit',
|
398
391
|
'qos_algorithm_params' => {}
|
399
392
|
}
|
400
|
-
client.
|
393
|
+
vm.vifs = client.vifs.create net_config
|
401
394
|
vm.reload
|
402
395
|
end
|
403
396
|
|
data/lib/foreman_xen/engine.rb
CHANGED
@@ -13,7 +13,7 @@ module ForemanXen
|
|
13
13
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
14
14
|
end
|
15
15
|
|
16
|
-
initializer 'foreman_xen.register_plugin', :
|
16
|
+
initializer 'foreman_xen.register_plugin', :before => :finisher_hook do |app|
|
17
17
|
Foreman::Plugin.register :foreman_xen do
|
18
18
|
requires_foreman '>= 1.11'
|
19
19
|
# Register xen compute resource in foreman
|
data/lib/foreman_xen/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_xen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Nemirovsky
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fog-xenserver
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.5.1
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Provision and manage XEN Server from Foreman
|