foreman_xen 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ec91f411f72a1ff46a7ec6a185e22e842866736
4
- data.tar.gz: 30682ce9742b077e2f9a62a448209a30d189f72d
3
+ metadata.gz: 2ac77329d8a3e6cb5a669b5f5f91768a9cc11cb9
4
+ data.tar.gz: 6e33e23e884e9b0a78e9f92e6c0f46c9aa2d7580
5
5
  SHA512:
6
- metadata.gz: adcc6e188b5df8ab67e07199a6a590699ea87908797f01d9a569e0d61a8d8f802abc5994fe689cb6f1f141d4123b3b8a5824056c69c50edaff0d00a161dd157e
7
- data.tar.gz: e7dcb42fd309b4ee4a03a73d722d92fb8c16b1e04af0f6389d03a22d9833c739c210b761219d64afdb87dec21a8bdc44a6eb1df7a3fb6568f771ae020a4a797f
6
+ metadata.gz: e7dbe2c6d1422283db19b090a17c4fe0a4ba8b2fc04983759614d05ae92c9d4dfb6cc586dddee8266e0d48aa080f043450ed7d13cc929e706d0b13ef4620352b
7
+ data.tar.gz: 26c02876370b0a7a495a652011411836d3d647efdc275e276d1e96188af2abca7a7624dcb2c562b538a87e0cfa5a976616ba222ae7380fdfba3a242aca5cdec7
data/README.md CHANGED
@@ -20,8 +20,9 @@ Please see the Foreman manual for further instructions:
20
20
  | >=1.5, <1.8 | 0.0.x (unmaintained) |
21
21
  | >=1.8.1, <1.10 | 0.1.x (unmaintained) |
22
22
  | >=1.10, <1.11 | 0.2.x (unmaintained) |
23
- | >=1.11, <1.13 | 0.3.x |
24
- | >=1.13 | 0.4.x |
23
+ | >=1.11, <1.13 | 0.3.x (unmaintained) |
24
+ | >=1.13, <1.14 | 0.4.x |
25
+ | >=1.14 | 0.5.x |
25
26
 
26
27
  ## Support
27
28
 
@@ -0,0 +1,20 @@
1
+ function refreshCache(item, on_success) {
2
+ tfm.tools.showSpinner();
3
+ attribute_name = $(item).data('attribute')
4
+ data = {
5
+ type: attribute_name,
6
+ compute_resource_id: $(item).data('compute-resource-id')
7
+ }
8
+ $.ajax({
9
+ type:'post',
10
+ url: $(item).data('url'),
11
+ data: data,
12
+ complete: function(){
13
+ tfm.tools.hideSpinner();
14
+ },
15
+ error: function(){
16
+ notify(__("Error refreshing cache for " + attribute_name), 'error', true);
17
+ },
18
+ success: on_success
19
+ })
20
+ }
@@ -0,0 +1,32 @@
1
+ function xenPopulateNetworks(network_list){
2
+ $('#host_compute_attributes_VIFs_print').children().remove();
3
+ for (var i = 0; i < network_list.length; i++) {
4
+ network = network_list[i];
5
+ $('#host_compute_attributes_VIFs_print').append('<option id=' + network['name'] + '>' + network['name'] + '</option>');
6
+ }
7
+ }
8
+
9
+ function xenPopulateStoragePools(results){
10
+ $('#host_compute_attributes_VBDs_sr_uuid').children().remove();
11
+ for (var i = 0; i < results.length; i++) {
12
+ result = results[i];
13
+ $('#host_compute_attributes_VBDs_sr_uuid').append('<option id=' + result['uuid'] + '>' + result['name'] + '</option>');
14
+ }
15
+ }
16
+
17
+ function xenPopulateCustomTemplates(custom_templates){
18
+ xenPopulateTemplates(custom_templates, '#host_compute_attributes_custom_template_name');
19
+ }
20
+
21
+ function xenPopulateBuiltinTemplates(builtin_templates){
22
+ xenPopulateTemplates(builtin_templates, '#host_compute_attributes_builtin_template_name');
23
+ }
24
+
25
+ function xenPopulateTemplates(results, selector){
26
+ $(selector).children().remove();
27
+ $(selector).append('<option>No template</option>');
28
+ for (var i = 0; i < results.length; i++) {
29
+ result = results[i];
30
+ $(selector).append('<option id=' + result['name'] + '>' + result['name'] + '</option>');
31
+ }
32
+ }
@@ -0,0 +1,34 @@
1
+ module ForemanXen
2
+ class CacheController < ::ApplicationController
3
+ before_action :load_compute_resource
4
+
5
+ # POST = foreman_xen/cache/refresh
6
+ def refresh
7
+ type = params[:type]
8
+
9
+ unless cache_attribute_whitelist.include?(type)
10
+ process_error(:error_msg => "Error refreshing cache. #{type} is not a white listed attribute")
11
+ end
12
+
13
+ unless @compute_resource.respond_to?("#{type}!")
14
+ process_error(:error_msg => "Error refreshing cache. Method '#{type}!' not found for compute resource" +
15
+ @compute_resource.name)
16
+ end
17
+
18
+ respond_to do |format|
19
+ format.json { render :json => @compute_resource.public_send("#{type}!") }
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ # List of methods to permit
26
+ def cache_attribute_whitelist
27
+ %w(networks hypervisors templates custom_templates builtin_templates storage_pools)
28
+ end
29
+
30
+ def load_compute_resource
31
+ @compute_resource = ComputeResource.find_by(id: params['compute_resource_id'])
32
+ end
33
+ end
34
+ end
@@ -29,19 +29,7 @@ module XenComputeHelper
29
29
  attribute_map = empty_attribute_map
30
30
  if new_host?(new)
31
31
  compute_attributes = compute_resource.compute_profile_attributes_for(params['host']['compute_profile_id'])
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']
35
- end
36
- if compute_attributes['VIFs']
37
- attribute_map[:network_selected] = compute_attributes['VIFs']['print']
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']
32
+ attribute_map = filter_compute_attributes(attribute_map, compute_attributes)
45
33
  elsif new
46
34
  attribute_map[:cpu_count] = new.vcpus_max ? new.vcpus_max : nil
47
35
  attribute_map[:memory_min] = new.memory_static_min ? new.memory_static_min : nil
@@ -68,19 +56,7 @@ module XenComputeHelper
68
56
  compute_attributes = compute_resource.compute_profile_attributes_for(params['host']['compute_profile_id'])
69
57
  end
70
58
  if compute_attributes
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']
74
- end
75
- if compute_attributes['VIFs']
76
- attribute_map[:network_selected] = compute_attributes['VIFs']['print']
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']
59
+ attribute_map = filter_compute_attributes(attribute_map, compute_attributes)
84
60
  end
85
61
  attribute_map
86
62
  end
@@ -96,4 +72,59 @@ module XenComputeHelper
96
72
  :memory_max => nil,
97
73
  :power_on => nil }
98
74
  end
75
+
76
+ def filter_compute_attributes(attribute_map, compute_attributes)
77
+ if compute_attributes['VBDs']
78
+ attribute_map[:volume_size] = compute_attributes['VBDs']['physical_size']
79
+ attribute_map[:volume_selected] = compute_attributes['VBDs']['sr_uuid']
80
+ end
81
+ if compute_attributes['VIFs']
82
+ attribute_map[:network_selected] = compute_attributes['VIFs']['print']
83
+ end
84
+ attribute_map[:template_selected_custom] = compute_attributes['custom_template_name']
85
+ attribute_map[:template_selected_builtin] = compute_attributes['builtin_template_name']
86
+ attribute_map[:cpu_count] = compute_attributes['vcpus_max']
87
+ attribute_map[:memory_min] = compute_attributes['memory_min']
88
+ attribute_map[:memory_max] = compute_attributes['memory_max']
89
+ attribute_map[:power_on] = compute_attributes['start']
90
+ attribute_map
91
+ end
92
+
93
+ def xen_builtin_template_map(compute_resource)
94
+ compute_resource.builtin_templates.map { |t| [t.name, t.name] }
95
+ end
96
+
97
+ def xen_custom_template_map(compute_resource)
98
+ compute_resource.custom_templates.map { |t| [t.name, t.name] }
99
+ end
100
+
101
+ def xen_storage_pool_map(compute_resource)
102
+ compute_resource.storage_pools.map { |item| [item[:display_name], item[:uuid]] }
103
+ end
104
+
105
+ def xen_hypervisor_map(compute_resource)
106
+ compute_resource.available_hypervisors!.map do |t|
107
+ [t.name + ' - ' + (
108
+ t.metrics.memory_free.to_f / t.metrics.memory_total.to_f * 100
109
+ ).round(2).to_s + '% free mem', t.name]
110
+ end
111
+ end
112
+
113
+ def selectable_f_with_cache_invalidation(f, attr, array,
114
+ select_options = {}, html_options = {}, input_group_options = {})
115
+ unless html_options.key?('input_group_btn')
116
+ html_options[:input_group_btn] = link_to_function(
117
+ icon_text('refresh'),
118
+ "refreshCache(this, #{input_group_options[:callback]})",
119
+ :class => 'btn btn-primary',
120
+ :title => _(input_group_options[:title]),
121
+ :data => {
122
+ :url => input_group_options[:url],
123
+ :compute_resource_id => input_group_options[:computer_resource_id],
124
+ :attribute => input_group_options[:attribute]
125
+ }
126
+ )
127
+ end
128
+ selectable_f(f, attr, array, select_options, html_options)
129
+ end
99
130
  end
@@ -60,12 +60,14 @@ module ForemanXen
60
60
  end
61
61
 
62
62
  def available_hypervisors
63
- tmps = begin
64
- client.hosts
65
- rescue
66
- []
63
+ read_from_cache('available_hypervisors', 'available_hypervisors!')
64
+ end
65
+
66
+ def available_hypervisors!
67
+ store_in_cache('available_hypervisors') do
68
+ hosts = client.hosts
69
+ hosts.sort_by(&:name)
67
70
  end
68
- tmps.sort_by(&:name)
69
71
  end
70
72
 
71
73
  def new_nic(attr = {})
@@ -77,38 +79,34 @@ module ForemanXen
77
79
  end
78
80
 
79
81
  def storage_pools
80
- results = []
81
-
82
- storages = begin
83
- client.storage_repositories.select { |sr| sr.type != 'udev' && sr.type != 'iso' }
84
- rescue
85
- []
86
- end
87
- hosts = client.hosts
88
-
89
- storages.each do |sr|
90
- subresults = {}
91
- found = 0
92
-
93
- hosts.each do |host|
94
- next unless sr.reference == host.suspend_image_sr
95
- found = 1
96
- subresults[:name] = sr.name
97
- subresults[:display_name] = sr.name + '(' + host.hostname + ')'
98
- subresults[:uuid] = sr.uuid
99
- break
100
- end
82
+ read_from_cache('storage_pools', 'storage_pools!')
83
+ end
101
84
 
102
- if found.zero?
103
- subresults[:name] = sr.name
104
- subresults[:display_name] = sr.name
105
- subresults[:uuid] = sr.uuid
85
+ def storage_pools!
86
+ store_in_cache('storage_pools') do
87
+ results = []
88
+ storages = client.storage_repositories.select { |sr| sr.type != 'udev' && sr.type != 'iso' }
89
+ storages.each do |sr|
90
+ subresults = {}
91
+ found = false
92
+
93
+ available_hypervisors.each do |host|
94
+ next unless sr.reference == host.suspend_image_sr
95
+ found = true
96
+ subresults[:name] = sr.name
97
+ subresults[:display_name] = sr.name + '(' + host.hostname + ')'
98
+ subresults[:uuid] = sr.uuid
99
+ break
100
+ end
101
+ unless found
102
+ subresults[:name] = sr.name
103
+ subresults[:display_name] = sr.name
104
+ subresults[:uuid] = sr.uuid
105
+ end
106
+ results.push(subresults)
106
107
  end
107
- results.push(subresults)
108
+ results.sort_by! { |item| item[:display_name] }
108
109
  end
109
-
110
- results.sort_by! { |item| item[:display_name] }
111
- results
112
110
  end
113
111
 
114
112
  def interfaces
@@ -118,36 +116,43 @@ module ForemanXen
118
116
  end
119
117
 
120
118
  def networks
121
- networks = begin
122
- client.networks
123
- rescue
124
- []
119
+ read_from_cache('networks', 'networks!')
120
+ end
121
+
122
+ def networks!
123
+ store_in_cache('networks') do
124
+ client.networks.sort_by(&:name)
125
125
  end
126
- networks.sort_by(&:name)
127
126
  end
128
127
 
129
128
  def templates
130
- client.servers.templates
131
- rescue
132
- []
129
+ read_from_cache('templates', 'templates!')
130
+ end
131
+
132
+ def templates!
133
+ store_in_cache('templates') do
134
+ client.servers.templates.sort_by(&:name)
135
+ end
133
136
  end
134
137
 
135
138
  def custom_templates
136
- tmps = begin
137
- client.servers.custom_templates.select { |t| !t.is_a_snapshot }
138
- rescue
139
- []
139
+ read_from_cache('custom_templates', 'custom_templates!')
140
+ end
141
+
142
+ def custom_templates!
143
+ store_in_cache('custom_templates') do
144
+ get_templates(client.servers.custom_templates)
140
145
  end
141
- tmps.sort_by(&:name)
142
146
  end
143
147
 
144
148
  def builtin_templates
145
- tmps = begin
146
- client.servers.builtin_templates.select { |t| !t.is_a_snapshot }
147
- rescue
148
- []
149
+ read_from_cache('builtin_templates', 'builtin_templates!')
150
+ end
151
+
152
+ def builtin_templates!
153
+ store_in_cache('builtin_templates') do
154
+ get_templates(client.servers.builtin_templates)
149
155
  end
150
- tmps.sort_by(&:name)
151
156
  end
152
157
 
153
158
  def associated_host(vm)
@@ -219,20 +224,15 @@ module ForemanXen
219
224
  mem_max = args[:memory_max]
220
225
  mem_min = args[:memory_min]
221
226
 
222
- host = if args[:hypervisor_host] != ''
223
- client.hosts.find { |host| host.name == args[:hypervisor_host] }
224
- else
225
- client.hosts.first
226
- end
227
+ host = get_hypervisor_host(args)
227
228
 
228
229
  logger.info "create_vm_from_builtin: host : #{host.name}"
229
230
 
230
231
  raise 'Memory max cannot be lower than Memory min' if mem_min.to_i > mem_max.to_i
231
- vm = client.servers.new :name => args[:name],
232
- :affinity => host,
233
- :template_name => args[:custom_template_name]
234
232
 
235
- vm.save :auto_start => false
233
+ template = client.custom_templates.select { |t| t.name == args[:custom_template_name] }.first
234
+ vm = template.clone args[:name]
235
+ vm.affinity = host
236
236
 
237
237
  vm.provision
238
238
 
@@ -274,11 +274,7 @@ module ForemanXen
274
274
  mem_max = args[:memory_max]
275
275
  mem_min = args[:memory_min]
276
276
 
277
- host = if args[:hypervisor_host] != ''
278
- client.hosts.find { |host| host.name == args[:hypervisor_host] }
279
- else
280
- client.hosts.first
281
- end
277
+ host = get_hypervisor_host(args)
282
278
 
283
279
  logger.info "create_vm_from_builtin: host : #{host.name}"
284
280
 
@@ -317,6 +313,23 @@ module ForemanXen
317
313
 
318
314
  create_network(vm, args)
319
315
 
316
+ if args[:xstools] == '1'
317
+ # Add xs-tools ISO to newly created VMs
318
+ dvd_vdi = client.vdis.find { |isovdi| isovdi.name == 'xs-tools.iso' }
319
+ vbdconnectcd = {
320
+ 'vdi' => dvd_vdi,
321
+ 'vm' => vm.reference,
322
+ 'userdevice' => '1',
323
+ 'mode' => 'RO',
324
+ 'type' => 'cd',
325
+ 'other_config' => {},
326
+ 'qos_algorithm_type' => '',
327
+ 'qos_algorithm_params' => {}
328
+ }
329
+ vm.vbds = client.vbds.create vbdconnectcd
330
+ vm.reload
331
+ end
332
+
320
333
  vm.provision
321
334
  vm.set_attribute('HVM_boot_policy', 'BIOS order')
322
335
  vm.reload
@@ -403,5 +416,30 @@ module ForemanXen
403
416
  end
404
417
  out_hash
405
418
  end
419
+
420
+ def get_templates(templates)
421
+ tmps = templates.select { |t| !t.is_a_snapshot }
422
+ tmps.sort_by(&:name)
423
+ end
424
+
425
+ def get_hypervisor_host(args)
426
+ return client.hosts.first unless args[:hypervisor_host] != ''
427
+ client.hosts.find { |host| host.name == args[:hypervisor_host] }
428
+ end
429
+
430
+ def read_from_cache(key, fallback)
431
+ value = Rails.cache.fetch(cache_key + key) { public_send(fallback) }
432
+ value
433
+ end
434
+
435
+ def store_in_cache(key)
436
+ value = yield
437
+ Rails.cache.write(cache_key + key, value)
438
+ value
439
+ end
440
+
441
+ def cache_key
442
+ "computeresource_#{id}/"
443
+ end
406
444
  end
407
445
  end
@@ -1,5 +1,12 @@
1
1
  <div id='templates' class=''>
2
2
  <div class="form-group">
3
- <%= selectable_f f, :hypervisor_host, [[_("Automatic allocation"), ""]] + compute_resource.available_hypervisors.map { |t| [t.name + " - " + (t.metrics.memory_free.to_f / t.metrics.memory_total.to_f * 100).round(2).to_s + "% free mem", t.name] }, {}, :class => 'form-control span2', :disabled => (controller_name != 'hosts'), :label => 'Hypervisor' %>
3
+ <%= selectable_f f, :hypervisor_host,
4
+ [[_("Automatic allocation"), ""]] + xen_hypervisor_map(compute_resource),
5
+ {},
6
+ { :class => 'form-control span2',
7
+ :disabled => (controller_name != 'hosts'),
8
+ :label => 'Hypervisor'
9
+ }
10
+ %>
4
11
  </div>
5
12
  </div>
@@ -1,12 +1,20 @@
1
1
  <div class="fields">
2
- <%
3
- nat = compute_resource.networks
4
- -%>
5
-
6
2
  <div id='nat' class=''>
7
- <%= selectable_f f, :print, nat.map(&:name),
8
- { :include_blank => nat.any? ? false : _("No networks"),
9
- :selected => attribute_map[:network_selected] },
10
- { :class => "span2", :label => _("Network") } %>
3
+ <%= selectable_f_with_cache_invalidation f, :print,
4
+ compute_resource.networks.map(&:name),
5
+ { :include_blank => compute_resource.networks.any? ? false : _('No networks'),
6
+ :selected => attribute_map[:network_selected]
7
+ },
8
+ { :class => 'span2',
9
+ :label => _('Network')
10
+ },
11
+ {
12
+ :callback => 'xenPopulateNetworks',
13
+ :title => 'Refresh available networks',
14
+ :url => '/foreman_xen/cache/refresh',
15
+ :computer_resource_id => compute_resource.id,
16
+ :attribute => 'networks'
17
+ }
18
+ %>
11
19
  </div>
12
20
  </div>
@@ -1,11 +1,39 @@
1
1
  <div class="fields">
2
2
  <div id='templates' class=''>
3
3
  <div class="form-group">
4
- <%= selectable_f f, :custom_template_name, [[_("No template"), ""]] + compute_resource.custom_templates.map { |t| [t.name, t.name] }, { :selected => attribute_map[:template_selected_custom] }, :class => 'form-control span2', :label => 'Custom Template' %>
4
+ <%= selectable_f_with_cache_invalidation f,
5
+ :custom_template_name,
6
+ [[_("No template"), ""]] + xen_custom_template_map(compute_resource),
7
+ { :selected => attribute_map[:template_selected_custom] },
8
+ { :class => 'form-control span2',
9
+ :label => 'Custom Template'
10
+ },
11
+ {
12
+ :callback => 'xenPopulateCustomTemplates',
13
+ :title => 'Refresh available custom templates',
14
+ :url => '/foreman_xen/cache/refresh',
15
+ :computer_resource_id => compute_resource.id,
16
+ :attribute => 'custom_templates'
17
+ }
18
+ %>
5
19
  </div>
6
20
 
7
21
  <div class="form-group ">
8
- <%= selectable_f f, :builtin_template_name, [[_("No template"), ""]] + compute_resource.builtin_templates.map { |t| [t.name, t.name] }, { :selected => attribute_map[:template_selected_builtin] }, :class => 'form-control span2', :label => 'Builtin Template' %>
22
+ <%= selectable_f_with_cache_invalidation f,
23
+ :builtin_template_name,
24
+ [[_("No template"), ""]] + xen_builtin_template_map(compute_resource),
25
+ { :selected => attribute_map[:template_selected_builtin] },
26
+ { :class => 'form-control span2',
27
+ :label => 'Builtin Template'
28
+ },
29
+ {
30
+ :callback => 'xenPopulateBuiltinTemplates',
31
+ :title => 'Refresh available builtin templates',
32
+ :url => '/foreman_xen/cache/refresh',
33
+ :computer_resource_id => compute_resource.id,
34
+ :attribute => 'builtin_templates'
35
+ }
36
+ %>
9
37
  </div>
10
38
  </div>
11
- </div>
39
+ </div>
@@ -1,6 +1,18 @@
1
1
  <div class="fields">
2
-
3
- <%= selectable_f f, :sr_uuid, compute_resource.storage_pools.map { |item| [item[:display_name], item[:uuid]] }, { :selected => attribute_map[:volume_selected] }, :class => "span2", :label => _("Storage Repository") %>
2
+ <%= selectable_f_with_cache_invalidation f, :sr_uuid,
3
+ xen_storage_pool_map(compute_resource),
4
+ { :selected => attribute_map[:volume_selected] },
5
+ { :class => "span2",
6
+ :label => _("Storage Repository"),
7
+ },
8
+ {
9
+ :callback => 'xenPopulateStoragePools',
10
+ :title => 'Refresh available storage repositories',
11
+ :url => '/foreman_xen/cache/refresh',
12
+ :computer_resource_id => compute_resource.id,
13
+ :attribute => 'storage_pools'
14
+ }
15
+ %>
4
16
 
5
17
  <%= text_f f, :physical_size, :class => "input-mini", :label => _("Size (GB)"), :value => attribute_map[:volume_size] %>
6
18
  </div>
@@ -53,6 +53,7 @@
53
53
  <%= render 'compute_resources_vms/form/volume', :f => i, :compute_resource => compute_resource, :new => new, :attribute_map => attribute_map %>
54
54
  <% end -%>
55
55
  <% end -%>
56
+ <%= checkbox_f f, :xstools, :checked => false, :label => _('Insert XS Tools ISO Drive') %>
56
57
  </div>
57
58
 
58
59
  <!-- Network -->
@@ -190,3 +191,6 @@
190
191
  }
191
192
  })
192
193
  </script>
194
+
195
+ <%= compute_specific_js(compute_resource, 'cache_refresh') %>
196
+ <%= compute_specific_js(compute_resource, 'populate_fields') %>
data/config/routes.rb CHANGED
@@ -6,5 +6,7 @@ Rails.application.routes.draw do
6
6
  match 'snapshots/:id/delete/:ref', :to => 'snapshots#destroy', :via => 'get'
7
7
 
8
8
  match 'snapshots/:id/create', :to => 'snapshots#create', :via => 'post'
9
+
10
+ match 'cache/refresh', :to => 'cache#refresh', :via => 'post'
9
11
  end
10
12
  end
@@ -22,6 +22,21 @@ module ForemanXen
22
22
  end
23
23
  end
24
24
 
25
+ assets_to_precompile =
26
+ Dir.chdir(root) do
27
+ Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
28
+ f.split(File::SEPARATOR, 4).last
29
+ end
30
+ end
31
+
32
+ initializer 'foreman_xen.assets.precompile' do |app|
33
+ app.config.assets.precompile += assets_to_precompile
34
+ end
35
+
36
+ initializer 'foreman_xen.configure_assets', group: :assets do
37
+ SETTINGS[:foreman_xen] = { assets: { precompile: assets_to_precompile } }
38
+ end
39
+
25
40
  config.to_prepare do
26
41
  begin
27
42
  # extend fog xen server and image models.
@@ -1,3 +1,3 @@
1
1
  module ForemanXen
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
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.4.1
4
+ version: 0.5.0
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-12-23 00:00:00.000000000 Z
13
+ date: 2017-03-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog-xenserver
@@ -50,6 +50,9 @@ files:
50
50
  - LICENSE
51
51
  - README.md
52
52
  - Rakefile
53
+ - app/assets/javascripts/compute_resources/xenserver/cache_refresh.js
54
+ - app/assets/javascripts/compute_resources/xenserver/populate_fields.js
55
+ - app/controllers/foreman_xen/cache_controller.rb
53
56
  - app/controllers/foreman_xen/snapshots_controller.rb
54
57
  - app/helpers/xen_compute_helper.rb
55
58
  - app/models/concerns/fog_extensions/xenserver/server.rb