foreman_xen 0.7.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -1
  3. data/app/assets/javascripts/foreman_xen/xenserver/cache_refresh.js +31 -18
  4. data/app/controllers/foreman_xen/cache_controller.rb +8 -5
  5. data/app/helpers/xen_compute_helper.rb +8 -103
  6. data/app/models/concerns/fog_extensions/xenserver/host.rb +23 -0
  7. data/app/models/concerns/fog_extensions/xenserver/server.rb +21 -3
  8. data/app/models/concerns/fog_extensions/xenserver/storage_repository.rb +45 -0
  9. data/app/models/concerns/fog_extensions/xenserver/vdi.rb +11 -0
  10. data/app/models/concerns/foreman_xen/host_extensions.rb +17 -0
  11. data/app/models/foreman_xen/xenserver.rb +395 -172
  12. data/app/views/api/v1/compute_resources/xenserver.json.rabl +1 -1
  13. data/app/views/api/v2/compute_resources/xenserver.json.rabl +1 -1
  14. data/app/views/compute_resources/form/_xenserver.html.erb +2 -4
  15. data/app/views/compute_resources_vms/form/_hypervisors.html.erb +15 -11
  16. data/app/views/compute_resources_vms/form/_image_provisioning.html.erb +49 -0
  17. data/app/views/compute_resources_vms/form/_isos.html.erb +15 -0
  18. data/app/views/compute_resources_vms/form/_network_provisioning.html.erb +26 -0
  19. data/app/views/compute_resources_vms/form/_profile.html.erb +5 -0
  20. data/app/views/compute_resources_vms/form/_templates.html.erb +13 -34
  21. data/app/views/compute_resources_vms/form/xenserver/_base.html.erb +22 -178
  22. data/app/views/compute_resources_vms/form/xenserver/_network.html.erb +23 -0
  23. data/app/views/compute_resources_vms/form/xenserver/_volume.html.erb +15 -0
  24. data/app/views/compute_resources_vms/index/_xenserver.html.erb +1 -1
  25. data/app/views/images/form/_xenserver.html.erb +4 -0
  26. data/lib/foreman_xen/engine.rb +14 -3
  27. data/lib/foreman_xen/version.rb +1 -1
  28. data/test/test_helper.rb +1 -3
  29. metadata +14 -7
  30. data/app/assets/javascripts/foreman_xen/xenserver/populate_fields.js +0 -32
  31. data/app/views/compute_resources_vms/form/_network.html.erb +0 -20
  32. data/app/views/compute_resources_vms/form/_volume.html.erb +0 -18
  33. data/app/views/compute_resources_vms/form/_xenstore.html.erb +0 -119
@@ -0,0 +1,15 @@
1
+ <%= selectable_f_with_cache_invalidation f, :sr,
2
+ options_from_collection_for_select(
3
+ compute_resource.storage_pools, :uuid, :display_name, (f.object.sr.uuid rescue nil)
4
+ ),
5
+ {},
6
+ { class: 'span2',
7
+ label: _("Storage Repository") },
8
+ { title: 'Refresh available storage repositories',
9
+ url: url_for(controller: "foreman_xen/cache",
10
+ action: "refresh", only_path: true),
11
+ compute_resource_id: compute_resource.id,
12
+ attribute: 'storage_pools' }
13
+ %>
14
+
15
+ <%= text_f f, :virtual_size_gb, :class => "input-mini", :label => _("Size (GB)"), :value => (f.object.virtual_size.to_i / 1_073_741_824) %>
@@ -11,7 +11,7 @@
11
11
  <tbody>
12
12
  <% @vms.each do |vm| -%>
13
13
  <tr>
14
- <td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity) %></td>
14
+ <td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.uuid) %></td>
15
15
  <td><%= vm.vcpus_max %></td>
16
16
  <td><%= (vm.memory_static_max.to_i / 1073741824).to_s %> GB</td>
17
17
  <td><%= vm.power_state %> </td>
@@ -0,0 +1,4 @@
1
+ <%= text_f f, :username, :value => @image.username || "root", :help_inline => _("The user that is used to ssh into the instance, normally cloud-user, ec2-user, ubuntu, root etc") %>
2
+ <%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input (e.g. via cloud-init)?") %>
3
+ <%= password_f f, :password, :help_inline => _("Password to authenticate with - used for SSH finish step.") %>
4
+ <%= image_field(f, :label => _("Image UUID"), :help_inline => _("UUID to template")) %>
@@ -17,10 +17,10 @@ module ForemanXen
17
17
 
18
18
  initializer 'foreman_xen.register_plugin', :before => :finisher_hook do |app|
19
19
  Foreman::Plugin.register :foreman_xen do
20
- requires_foreman '>= 1.18'
20
+ requires_foreman '>= 1.20'
21
21
  # Register xen compute resource in foreman
22
22
  compute_resource ForemanXen::Xenserver
23
- parameter_filter(ComputeResource, :uuid)
23
+ parameter_filter(ComputeResource, :uuid, :iso_library_mountpoint)
24
24
  end
25
25
  end
26
26
 
@@ -43,11 +43,22 @@ module ForemanXen
43
43
  begin
44
44
  # extend fog xen server and image models.
45
45
  require 'fog/xenserver/compute/models/server'
46
+ require 'fog/xenserver/compute/models/host'
47
+ require 'fog/xenserver/compute/models/vdi'
48
+ require 'fog/xenserver/compute/models/storage_repository'
46
49
  require File.expand_path('../../app/models/concerns/fog_extensions/xenserver/server', __dir__)
50
+ require File.expand_path('../../app/models/concerns/fog_extensions/xenserver/host', __dir__)
51
+ require File.expand_path('../../app/models/concerns/fog_extensions/xenserver/vdi', __dir__)
52
+ require File.expand_path('../../app/models/concerns/fog_extensions/xenserver/storage_repository', __dir__)
47
53
  require File.expand_path('../../app/models/concerns/foreman_xen/host_helper_extensions', __dir__)
54
+ require File.expand_path('../../app/models/concerns/foreman_xen/host_extensions', __dir__)
48
55
 
49
- Fog::XenServer::Compute::Server.send(:include, ::FogExtensions::Xenserver::Server)
56
+ Fog::XenServer::Compute::Models::Server.send(:include, ::FogExtensions::Xenserver::Server)
57
+ Fog::XenServer::Compute::Models::Host.send(:include, ::FogExtensions::Xenserver::Host)
58
+ Fog::XenServer::Compute::Models::Vdi.send(:include, ::FogExtensions::Xenserver::Vdi)
59
+ Fog::XenServer::Compute::Models::StorageRepository.send(:include, ::FogExtensions::Xenserver::StorageRepository)
50
60
  ::HostsHelper.send(:include, ForemanXen::HostHelperExtensions)
61
+ ::Host::Managed.send(:prepend, ForemanXen::HostExtensions)
51
62
  rescue => e
52
63
  Rails.logger.warn "Foreman-Xen: skipping engine hook (#{e})"
53
64
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanXen
2
- VERSION = '0.7.1'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -10,6 +10,4 @@ Rails.backtrace_cleaner.remove_silencers!
10
10
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
11
 
12
12
  # Load fixtures from the engine
13
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
- ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__)
15
- end
13
+ ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__) if ActiveSupport::TestCase.method_defined?(:fixture_path=)
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.7.1
4
+ version: 1.0.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: 2019-01-18 00:00:00.000000000 Z
13
+ date: 2019-07-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog-xenserver
@@ -51,11 +51,14 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - app/assets/javascripts/foreman_xen/xenserver/cache_refresh.js
54
- - app/assets/javascripts/foreman_xen/xenserver/populate_fields.js
55
54
  - app/controllers/foreman_xen/cache_controller.rb
56
55
  - app/controllers/foreman_xen/snapshots_controller.rb
57
56
  - app/helpers/xen_compute_helper.rb
57
+ - app/models/concerns/fog_extensions/xenserver/host.rb
58
58
  - app/models/concerns/fog_extensions/xenserver/server.rb
59
+ - app/models/concerns/fog_extensions/xenserver/storage_repository.rb
60
+ - app/models/concerns/fog_extensions/xenserver/vdi.rb
61
+ - app/models/concerns/foreman_xen/host_extensions.rb
59
62
  - app/models/concerns/foreman_xen/host_helper_extensions.rb
60
63
  - app/models/foreman_xen/xenserver.rb
61
64
  - app/views/api/v1/compute_resources/xenserver.json.rabl
@@ -63,15 +66,19 @@ files:
63
66
  - app/views/compute_resources/form/_xenserver.html.erb
64
67
  - app/views/compute_resources/show/_xenserver.html.erb
65
68
  - app/views/compute_resources_vms/form/_hypervisors.html.erb
66
- - app/views/compute_resources_vms/form/_network.html.erb
69
+ - app/views/compute_resources_vms/form/_image_provisioning.html.erb
70
+ - app/views/compute_resources_vms/form/_isos.html.erb
71
+ - app/views/compute_resources_vms/form/_network_provisioning.html.erb
72
+ - app/views/compute_resources_vms/form/_profile.html.erb
67
73
  - app/views/compute_resources_vms/form/_templates.html.erb
68
- - app/views/compute_resources_vms/form/_volume.html.erb
69
- - app/views/compute_resources_vms/form/_xenstore.html.erb
70
74
  - app/views/compute_resources_vms/form/xenserver/_base.html.erb
75
+ - app/views/compute_resources_vms/form/xenserver/_network.html.erb
76
+ - app/views/compute_resources_vms/form/xenserver/_volume.html.erb
71
77
  - app/views/compute_resources_vms/index/_xenserver.html.erb
72
78
  - app/views/compute_resources_vms/show/_xenserver.html.erb
73
79
  - app/views/foreman_xen/snapshots/new.html.erb
74
80
  - app/views/foreman_xen/snapshots/show.html.erb
81
+ - app/views/images/form/_xenserver.html.erb
75
82
  - config/routes.rb
76
83
  - lib/foreman_xen.rb
77
84
  - lib/foreman_xen/engine.rb
@@ -101,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
108
  version: '0'
102
109
  requirements: []
103
110
  rubyforge_project:
104
- rubygems_version: 2.7.6
111
+ rubygems_version: 2.7.6.2
105
112
  signing_key:
106
113
  specification_version: 4
107
114
  summary: Provision and manage XEN Server from Foreman
@@ -1,32 +0,0 @@
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
- }
@@ -1,20 +0,0 @@
1
- <div class="fields">
2
- <div id='nat' class=''>
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
- %>
19
- </div>
20
- </div>
@@ -1,18 +0,0 @@
1
- <div class="fields">
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
- %>
16
-
17
- <%= text_f f, :physical_size, :class => "input-mini", :label => _("Size (GB)"), :value => attribute_map[:volume_size] %>
18
- </div>
@@ -1,119 +0,0 @@
1
- <%
2
-
3
- if params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:xenstore]
4
- vmdata = params[:host][:compute_attributes][:xenstore]['vm-data']
5
- else
6
- vmdata = init_vmdata
7
- end
8
-
9
- disabled = 'readonly'
10
-
11
- %>
12
-
13
- <div class="children_fields">
14
-
15
- <div class="fields">
16
-
17
- <div class="form-group">
18
- <label class="col-md-2 control-label" for="xenstore-vm-data-ifs-0-ip">vm-data/ifs/0/ip</label>
19
-
20
- <div class="col-md-4">
21
- <div class="controls">
22
- <input <%= disabled %> id="xenstore-vm-data-ifs-0-ip" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][ip]" class="form-control input-mini" value="<%= vmdata[:ifs]['0'][:ip] %>">
23
- </div>
24
- </div>
25
- </div>
26
-
27
- <div class="form-group">
28
- <label class="col-md-2 control-label" for="xenstore-vm-data-ifs-0-gateway">vm-data/ifs/0/gateway</label>
29
-
30
- <div class="col-md-4">
31
- <div class="controls">
32
- <input <%= disabled %> id="xenstore-vm-data-ifs-0-gateway" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][gateway]" class="form-control input-mini" value="<%= vmdata[:ifs]['0'][:gateway] %>">
33
- </div>
34
- </div>
35
- </div>
36
-
37
- <div class="form-group">
38
- <label class="col-md-2 control-label" for="xenstore-vm-data-ifs-0-netmask">vm-data/ifs/0/netmask</label>
39
-
40
- <div class="col-md-4">
41
- <div class="controls">
42
- <input <%= disabled %> id="xenstore-vm-data-ifs-0-netmask" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][netmask]" class="form-control input-mini" value="<%= vmdata[:ifs]['0'][:netmask] %>">
43
- </div>
44
- </div>
45
- </div>
46
-
47
- <div class="form-group">
48
- <label class="col-md-2 control-label" for="xenstore-vm-data-nameserver1">vm-data/nameserver1</label>
49
-
50
- <div class="col-md-4">
51
- <input <%= disabled %> id="xenstore-vm-data-nameserver1" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver1]" class="form-control input-mini" value="<%= vmdata[:nameserver1] %>">
52
- </div>
53
- </div>
54
-
55
- <div class="form-group">
56
- <label class="col-md-2 control-label" for="xenstore-vm-data-nameserver2">vm-data/nameserver2</label>
57
-
58
- <div class="col-md-4">
59
- <input <%= disabled %> id="xenstore-vm-data-nameserver2" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver2]" class="form-control input-mini" value="<%= vmdata[:nameserver2] %>">
60
- </div>
61
- </div>
62
-
63
- <div class="form-group">
64
- <label class="col-md-2 control-label" for="xenstore-vm-data-environment">vm-data/environment</label>
65
-
66
- <div class="col-md-4">
67
- <input <%= disabled %> id="xenstore-vm-data-environment" type="text" name="host[compute_attributes][xenstore][vm-data][environment]" class="form-control input-mini" value="<%= vmdata[:environment] %>">
68
- </div>
69
- </div>
70
- </div>
71
- </div>
72
-
73
-
74
- <script type="text/javascript">
75
- function autocomplete_xenstore(subnet_id) {
76
- url = "/subnets/" + subnet_id + "/edit";
77
- $.get(url, function (data) {
78
- fields = $('#primary', data);
79
- $('#xenstore-vm-data-ifs-0-gateway').val($('#subnet_gateway', fields).val());
80
- $('#xenstore-vm-data-ifs-0-netmask').val($('#subnet_mask', fields).val());
81
- $('#xenstore-vm-data-nameserver1').val($('#subnet_dns_primary', fields).val());
82
- $('#xenstore-vm-data-nameserver2').val($('#subnet_dns_secondary', fields).val());
83
- $('#xenstore-vm-data-ifs-0-ip').val($('#host_interfaces_attributes_0_ip').val());
84
- $('#xenstore-vm-data-environment').val($('#host_environment_id option:selected').text())
85
- })
86
- }
87
-
88
- subnet_id = $('#host_interfaces_attributes_0_subnet_id option:selected').val();
89
-
90
- if (subnet_id) {
91
- autocomplete_xenstore(subnet_id)
92
- }
93
-
94
- $(document).off('change.xenstore', '#host_interfaces_attributes_0_subnet_id');
95
- $(document).on('change.xenstore', '#host_interfaces_attributes_0_subnet_id', function (data) {
96
- subnet_id = $('option:selected', data.target).val();
97
- if (subnet_id) {
98
- autocomplete_xenstore(subnet_id)
99
- }
100
- });
101
-
102
- $('#xenstore-vm-data-environment').val($('#host_environment_id option:selected').text());
103
-
104
- $(document).off('change.xenstore', '#host_environment_id');
105
- $(document).on('change.xenstore', '#host_environment_id', function (data) {
106
- env = $('option:selected', data.target).text();
107
- $('#xenstore-vm-data-environment').val(env)
108
- });
109
-
110
- $(document).off('click.xenstore', '#compute_resource_tab a');
111
- $(document).on('click.xenstore', '#compute_resource_tab a', function (data) {
112
- subnet_id = $('#host_interfaces_attributes_0_subnet_id option:selected').val();
113
-
114
- if (subnet_id) {
115
- autocomplete_xenstore(subnet_id)
116
- }
117
- })
118
-
119
- </script>