foreman_fog_proxmox 0.12.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of foreman_fog_proxmox might be problematic. Click here for more details.

Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +619 -0
  3. data/README.md +290 -0
  4. data/Rakefile +49 -0
  5. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +33 -0
  6. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +187 -0
  7. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_container.js +24 -0
  8. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +125 -0
  9. data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +41 -0
  10. data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +86 -0
  11. data/app/helpers/node_dashboard_helper.rb +35 -0
  12. data/app/helpers/proxmox_compute_selectors_helper.rb +184 -0
  13. data/app/helpers/proxmox_container_helper.rb +163 -0
  14. data/app/helpers/proxmox_form_helper.rb +70 -0
  15. data/app/helpers/proxmox_server_helper.rb +155 -0
  16. data/app/helpers/proxmox_vm_helper.rb +88 -0
  17. data/app/models/concerns/fog_extensions/proxmox/disk.rb +29 -0
  18. data/app/models/concerns/fog_extensions/proxmox/interface.rb +40 -0
  19. data/app/models/concerns/fog_extensions/proxmox/node.rb +41 -0
  20. data/app/models/concerns/fog_extensions/proxmox/server.rb +93 -0
  21. data/app/models/concerns/fog_extensions/proxmox/server_config.rb +71 -0
  22. data/app/models/concerns/fog_extensions/proxmox/volume.rb +29 -0
  23. data/app/models/concerns/host_ext/proxmox/interfaces.rb +52 -0
  24. data/app/models/concerns/orchestration/proxmox/compute.rb +42 -0
  25. data/app/models/foreman_fog_proxmox/options_select.rb +36 -0
  26. data/app/models/foreman_fog_proxmox/proxmox.rb +133 -0
  27. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +67 -0
  28. data/app/models/foreman_fog_proxmox/proxmox_connection.rb +67 -0
  29. data/app/models/foreman_fog_proxmox/proxmox_console.rb +41 -0
  30. data/app/models/foreman_fog_proxmox/proxmox_images.rb +61 -0
  31. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +103 -0
  32. data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +49 -0
  33. data/app/models/foreman_fog_proxmox/proxmox_pools.rb +56 -0
  34. data/app/models/foreman_fog_proxmox/proxmox_token_expiration.rb +30 -0
  35. data/app/models/foreman_fog_proxmox/proxmox_version.rb +36 -0
  36. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +116 -0
  37. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +178 -0
  38. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +75 -0
  39. data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +94 -0
  40. data/app/models/foreman_fog_proxmox/vms.rb +37 -0
  41. data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +25 -0
  42. data/app/overrides/compute_resources_vms/form/add_from_profile_to_compute_attributes_form.rb +34 -0
  43. data/app/overrides/compute_resources_vms/form/add_vm_type_node_to_new_form.rb +25 -0
  44. data/app/overrides/compute_resources_vms/form/add_vm_type_to_networks_form.rb +34 -0
  45. data/app/overrides/compute_resources_vms/form/add_vm_type_to_nic_provider_specific_form.rb +26 -0
  46. data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb +25 -0
  47. data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb +25 -0
  48. data/app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb +25 -0
  49. data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +37 -0
  50. data/app/views/api/v2/compute_resources/proxmox.json.rabl +3 -0
  51. data/app/views/compute_resources/form/_proxmox.html.erb +29 -0
  52. data/app/views/compute_resources/show/_proxmox.html.erb +37 -0
  53. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb +23 -0
  54. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb +23 -0
  55. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb +24 -0
  56. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_node_to_new_form.html.erb +24 -0
  57. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb +28 -0
  58. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb +32 -0
  59. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +30 -0
  60. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +71 -0
  61. data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +39 -0
  62. data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +39 -0
  63. data/app/views/compute_resources_vms/form/proxmox/_network.html.erb +19 -0
  64. data/app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb +27 -0
  65. data/app/views/compute_resources_vms/form/proxmox/container/_advanced.html.erb +31 -0
  66. data/app/views/compute_resources_vms/form/proxmox/container/_config.html.erb +41 -0
  67. data/app/views/compute_resources_vms/form/proxmox/container/_extended.html.erb +27 -0
  68. data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +33 -0
  69. data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +27 -0
  70. data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +24 -0
  71. data/app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb +31 -0
  72. data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +60 -0
  73. data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +30 -0
  74. data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +28 -0
  75. data/app/views/compute_resources_vms/index/_proxmox.html.erb +49 -0
  76. data/app/views/compute_resources_vms/show/_proxmox.html.erb +42 -0
  77. data/app/views/dashboard/_foreman_fog_proxmox_widget.erb +21 -0
  78. data/app/views/images/form/_proxmox.html.erb +21 -0
  79. data/config/routes.rb +30 -0
  80. data/lib/foreman_fog_proxmox.rb +23 -0
  81. data/lib/foreman_fog_proxmox/engine.rb +105 -0
  82. data/lib/foreman_fog_proxmox/semver.rb +102 -0
  83. data/lib/foreman_fog_proxmox/value.rb +26 -0
  84. data/lib/foreman_fog_proxmox/version.rb +22 -0
  85. data/lib/tasks/foreman_fog_proxmox_tasks.rake +37 -0
  86. data/locale/Makefile +60 -0
  87. data/locale/en/foreman_fog_proxmox.po +401 -0
  88. data/locale/foreman_fog_proxmox.pot +627 -0
  89. data/locale/fr/foreman_fog_proxmox.po +401 -0
  90. data/locale/gemspec.rb +4 -0
  91. data/test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb +137 -0
  92. data/test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb +87 -0
  93. data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +134 -0
  94. data/test/factories/proxmox_factory.rb +79 -0
  95. data/test/functional/compute_resources_controller_test.rb +48 -0
  96. data/test/test_plugin_helper.rb +19 -0
  97. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +204 -0
  98. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +149 -0
  99. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +216 -0
  100. data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +124 -0
  101. data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +52 -0
  102. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +117 -0
  103. data/test/unit/foreman_fog_proxmox/proxmox_test.rb +58 -0
  104. data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +94 -0
  105. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +280 -0
  106. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +110 -0
  107. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +222 -0
  108. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_volumes_test.rb +308 -0
  109. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb +43 -0
  110. data/test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb +71 -0
  111. data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +68 -0
  112. data/test/unit/foreman_fog_proxmox/semver_test.rb +111 -0
  113. metadata +249 -0
@@ -0,0 +1,24 @@
1
+ // Copyright 2018 Tristan Robert
2
+
3
+ // This file is part of ForemanFogProxmox.
4
+
5
+ // ForemanFogProxmox is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+
10
+ // ForemanFogProxmox is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+
19
+ function storageOstemplateSelected(item) {
20
+ var storage = $(item).val();
21
+ var node_id = $('#host_compute_attributes_node_id').val();
22
+ if (node_id == undefined) node_id = $("#compute_attribute_vm_attrs_node_id").val();
23
+ updateOptions('ostemplates', 'compute_attributes_ostemplate', 'file', undefined, undefined, 'volid', node_id, storage);
24
+ }
@@ -0,0 +1,125 @@
1
+ // Copyright 2018 Tristan Robert
2
+
3
+ // This file is part of ForemanFogProxmox.
4
+
5
+ // ForemanFogProxmox is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+
10
+ // ForemanFogProxmox is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ function cdromSelected(item) {
19
+ var selected = $(item).val();
20
+ var cdrom_image_form = $('#cdrom_image_form');
21
+
22
+ switch (selected) {
23
+ case 'none':
24
+ initCdromStorage();
25
+ initCdromOptions('iso');
26
+ cdrom_image_form.hide();
27
+ break;
28
+ case 'cdrom':
29
+ initCdromStorage();
30
+ initCdromOptions('iso');
31
+ cdrom_image_form.hide();
32
+ break;
33
+ case 'image':
34
+ initCdromStorage();
35
+ initCdromOptions('iso');
36
+ cdrom_image_form.show();
37
+ break;
38
+ default:
39
+ break;
40
+ }
41
+ return false;
42
+ }
43
+
44
+ function initCdromStorage() {
45
+ var select = '#host_compute_attributes_config_attributes_cdrom_storage';
46
+ $(select + ' option:selected').prop('selected', false);
47
+ $(select).val('');
48
+ }
49
+
50
+ function initCdromOptions(name) {
51
+ var select = '#host_compute_attributes_config_attributes_cdrom_' + name;
52
+ $(select).empty();
53
+ $(select).append($("<option></option>").val('').text(''));
54
+ $(select).val('');
55
+ }
56
+
57
+ function storageIsoSelected(item) {
58
+ var storage = $(item).val();
59
+ var node_id = $('#host_compute_attributes_node_id').val();
60
+ updateOptions('isos', 'compute_attributes_config_attributes', 'cdrom_iso', undefined, undefined, 'volid', node_id, storage);
61
+ }
62
+
63
+ function attributesPrefixSelector(profile, type) {
64
+ return profile ? '#compute_attribute_vm_attrs_' + type + '_attributes_': '#host_compute_attributes_' + type + '_attributes_';
65
+ }
66
+
67
+ function volumesAttributesSelector(profile,index,selector) {
68
+ return attributesPrefixSelector(profile,'volumes') + index + '_' + selector;
69
+ }
70
+
71
+ function getIndex(item) {
72
+ var id = $(item).attr('id');
73
+ var pattern = /(host_compute_attributes_volumes_attributes_||compute_attribute_vm_attrs_volumes_attributes_)(\d+)[_](.*)/i;
74
+ pattern_a = pattern.exec(id);
75
+ var index = pattern_a[2];
76
+ console.log("index=" + index);
77
+ return index;
78
+ }
79
+
80
+ function isProfile() {
81
+ return $(volumesAttributesSelector(true,0,'id')) !== undefined;
82
+ }
83
+
84
+ function controllerSelected(item) {
85
+ var controller = $(item).val();
86
+ var index = getIndex(item);
87
+ var max = computeControllerMaxDevice(controller);
88
+ var profile = isProfile();
89
+ console.log("profile="+profile);
90
+ var device_selector = volumesAttributesSelector(profile,index,'device');
91
+ var id_selector = volumesAttributesSelector(profile,index,'id');
92
+ $(device_selector).attr('data-soft-max', max);
93
+ var device = $(device_selector).limitedSpinner('value');
94
+ var id = controller + device;
95
+ $(id_selector).val(id);
96
+ tfm.numFields.initAll();
97
+ }
98
+
99
+ function deviceSelected(item) {
100
+ var device = $(item).limitedSpinner('value');
101
+ var index = getIndex(item);
102
+ var profile = isProfile();
103
+ console.log("profile="+profile);
104
+ var controller_selector = volumesAttributesSelector(profile,index,'controller');
105
+ var id_selector = volumesAttributesSelector(profile,index,'id');
106
+ var controller = $(controller_selector).val();
107
+ var id = controller + device;
108
+ $(id_selector).val(id);
109
+ tfm.numFields.initAll();
110
+ }
111
+
112
+ function computeControllerMaxDevice(controller) {
113
+ switch (controller) {
114
+ case 'ide':
115
+ return 3;
116
+ case 'sata':
117
+ return 5;
118
+ case 'scsi':
119
+ return 13;
120
+ case 'virtio':
121
+ return 15;
122
+ default:
123
+ return 1;
124
+ }
125
+ }
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module ForemanFogProxmox
21
+ module Controller
22
+ module Parameters
23
+ module ComputeResource
24
+ extend ActiveSupport::Concern
25
+
26
+ class_methods do
27
+ def compute_resource_params_filter
28
+ super.tap do |filter|
29
+ filter.permit :ssl_verify_peer,
30
+ :ssl_certs, :disable_proxy, :cr_id, :renew
31
+ end
32
+ end
33
+
34
+ def compute_resource_params
35
+ self.class.compute_resource_params_filter.filter_params(params, parameter_filter_context)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module ForemanFogProxmox
21
+ class ComputeResourcesController < ::ApplicationController
22
+ before_action :load_compute_resource
23
+
24
+ # GET foreman_fog_proxmox/isos/:node_id/:storage
25
+ def isos_by_node_and_storage
26
+ volumes = @compute_resource.images_by_storage(params[:node_id], params[:storage], 'iso')
27
+ respond_to do |format|
28
+ format.json { render :json => volumes }
29
+ end
30
+ end
31
+
32
+ # GET foreman_fog_proxmox/ostemplates/:node_id/:storage
33
+ def ostemplates_by_node_and_storage
34
+ volumes = @compute_resource.images_by_storage(params[:node_id], params[:storage], 'vztmpl')
35
+ respond_to do |format|
36
+ format.json { render :json => volumes }
37
+ end
38
+ end
39
+
40
+ # GET foreman_fog_proxmox/isos/:node_id
41
+ def isos_by_node
42
+ volumes = @compute_resource.images_by_storage(params[:node_id], params[:storage], 'iso')
43
+ respond_to do |format|
44
+ format.json { render :json => volumes }
45
+ end
46
+ end
47
+
48
+ # GET foreman_fog_proxmox/ostemplates/:node_id
49
+ def ostemplates_by_node
50
+ storages = @compute_resource.storages(params[:node_id], 'vztmpl')
51
+ respond_to do |format|
52
+ format.json { render :json => storages }
53
+ end
54
+ end
55
+
56
+ # GET foreman_fog_proxmox/storages/:node_id
57
+ def storages_by_node
58
+ storages = @compute_resource.storages(params[:node_id])
59
+ respond_to do |format|
60
+ format.json { render :json => storages }
61
+ end
62
+ end
63
+
64
+ # GET foreman_fog_proxmox/isostorages/:node_id
65
+ def iso_storages_by_node
66
+ storages = @compute_resource.storages(params[:node_id], 'iso')
67
+ respond_to do |format|
68
+ format.json { render :json => storages }
69
+ end
70
+ end
71
+
72
+ # GET foreman_fog_proxmox/bridges/:node_id
73
+ def bridges_by_node
74
+ bridges = @compute_resource.bridges(params[:node_id])
75
+ respond_to do |format|
76
+ format.json { render :json => bridges }
77
+ end
78
+ end
79
+
80
+ private
81
+
82
+ def load_compute_resource
83
+ @compute_resource = ComputeResource.find_by(type: 'ForemanFogProxmox::Proxmox')
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module NodeDashboardHelper
21
+ def compute_data(statistics)
22
+ data = []
23
+ statistics.each do |statistic|
24
+ t = Time.zone.at(statistic['time'])
25
+ x = t.hour.to_s + ':' + t.min.to_s
26
+ data << [x, statistic['loadavg'] * 100]
27
+ end
28
+ data
29
+ end
30
+
31
+ def render_node_statistics(statistics, options = {})
32
+ data = compute_data(statistics)
33
+ flot_bar_chart('node_statistics', _('Time'), _('Average load (x100)'), data, options)
34
+ end
35
+ end
@@ -0,0 +1,184 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module ProxmoxComputeSelectorsHelper
21
+ def proxmox_types_map
22
+ [OpenStruct.new(id: 'qemu', name: 'KVM/Qemu server'),
23
+ OpenStruct.new(id: 'lxc', name: 'LXC container')]
24
+ end
25
+
26
+ def proxmox_archs_map
27
+ [OpenStruct.new(id: 'amd64', name: '64 bits'),
28
+ OpenStruct.new(id: 'i386', name: '32 bits')]
29
+ end
30
+
31
+ def proxmox_ostypes_map
32
+ [OpenStruct.new(id: 'debian', name: 'Debian'),
33
+ OpenStruct.new(id: 'ubuntu', name: 'Ubuntu'),
34
+ OpenStruct.new(id: 'centos', name: 'CentOS'),
35
+ OpenStruct.new(id: 'fedora', name: 'Fedora'),
36
+ OpenStruct.new(id: 'opensuse', name: 'OpenSuse'),
37
+ OpenStruct.new(id: 'archlinux', name: 'ArchLinux'),
38
+ OpenStruct.new(id: 'gentoo', name: 'Gentoo'),
39
+ OpenStruct.new(id: 'alpine', name: 'Alpine'),
40
+ OpenStruct.new(id: 'unmanaged', name: 'Unmanaged')]
41
+ end
42
+
43
+ def proxmox_controllers_map
44
+ [ForemanFogProxmox::OptionsSelect.new(id: 'ide', name: 'IDE', range: 3),
45
+ ForemanFogProxmox::OptionsSelect.new(id: 'sata', name: 'SATA', range: 5),
46
+ ForemanFogProxmox::OptionsSelect.new(id: 'scsi', name: 'SCSI', range: 13),
47
+ ForemanFogProxmox::OptionsSelect.new(name: 'VirtIO Block', id: 'virtio', range: 15)]
48
+ end
49
+
50
+ def proxmox_scsi_controllers_map
51
+ [OpenStruct.new(id: 'lsi', name: 'LSI 53C895A (Default)'),
52
+ OpenStruct.new(id: 'lsi53c810', name: 'LSI 53C810'),
53
+ OpenStruct.new(id: 'virtio-scsi-pci', name: 'VirtIO SCSI'),
54
+ OpenStruct.new(id: 'virtio-scsi-single', name: 'VirtIO SCSI Single'),
55
+ OpenStruct.new(id: 'megasas', name: 'MegaRAID SAS 8708EM2'),
56
+ OpenStruct.new(id: 'pvscsi', name: 'VMware PVSCSI')]
57
+ end
58
+
59
+ def proxmox_operating_systems_map
60
+ [OpenStruct.new(id: 'other', name: 'Unspecified OS'),
61
+ OpenStruct.new(id: 'wxp', name: 'Microsoft Windows XP'),
62
+ OpenStruct.new(id: 'w2k', name: 'Microsoft Windows 2000'),
63
+ OpenStruct.new(id: 'w2k3', name: 'Microsoft Windows 2003'),
64
+ OpenStruct.new(id: 'w2k8', name: 'Microsoft Windows 2008'),
65
+ OpenStruct.new(id: 'wvista', name: 'Microsoft Windows Vista'),
66
+ OpenStruct.new(id: 'win7', name: 'Microsoft Windows 7'),
67
+ OpenStruct.new(id: 'win8', name: 'Microsoft Windows 8/2012/2012r2'),
68
+ OpenStruct.new(id: 'win10', name: 'Microsoft Windows 10/2016'),
69
+ OpenStruct.new(id: 'l24', name: 'Linux 2.4 Kernel'),
70
+ OpenStruct.new(id: 'l26', name: 'Linux 2.6/3.X + Kernel'),
71
+ OpenStruct.new(id: 'solaris', name: 'Solaris/OpenSolaris/OpenIndiania kernel')]
72
+ end
73
+
74
+ def proxmox_vgas_map
75
+ [OpenStruct.new(id: 'std', name: 'Standard VGA'),
76
+ OpenStruct.new(id: 'vmware', name: 'Vmware compatible'),
77
+ OpenStruct.new(id: 'qxl', name: 'SPICE'),
78
+ OpenStruct.new(id: 'qxl2', name: 'SPICE 2 monnitors'),
79
+ OpenStruct.new(id: 'qxl3', name: 'SPICE 3 monnitors'),
80
+ OpenStruct.new(id: 'qxl4', name: 'SPICE 4 monnitors'),
81
+ OpenStruct.new(id: 'serial0', name: 'Serial terminal 0'),
82
+ OpenStruct.new(id: 'serial1', name: 'Serial terminal 1'),
83
+ OpenStruct.new(id: 'serial2', name: 'Serial terminal 2'),
84
+ OpenStruct.new(id: 'serial3', name: 'Serial terminal 3')]
85
+ end
86
+
87
+ def proxmox_keyboards_map
88
+ [OpenStruct.new(id: 'de', name: 'Deutsch'),
89
+ OpenStruct.new(id: 'de-ch', name: 'Deutsch (Swiss)'),
90
+ OpenStruct.new(id: 'da', name: 'Danish'),
91
+ OpenStruct.new(id: 'en-gb', name: 'English (UK)'),
92
+ OpenStruct.new(id: 'en-us', name: 'English (US)'),
93
+ OpenStruct.new(id: 'es', name: 'Spanish'),
94
+ OpenStruct.new(id: 'fi', name: 'Finnish'),
95
+ OpenStruct.new(id: 'fr', name: 'French'),
96
+ OpenStruct.new(id: 'fr-be', name: 'French (Belgium)'),
97
+ OpenStruct.new(id: 'fr-ca', name: 'French (Canadian)'),
98
+ OpenStruct.new(id: 'fr-ch', name: 'French (Swiss)'),
99
+ OpenStruct.new(id: 'hu', name: 'Hungarian'),
100
+ OpenStruct.new(id: 'is', name: 'Israelian'),
101
+ OpenStruct.new(id: 'it', name: 'Italian'),
102
+ OpenStruct.new(id: 'ja', name: 'Japanese'),
103
+ OpenStruct.new(id: 'lt', name: 'Lituanian'),
104
+ OpenStruct.new(id: 'mk', name: ''),
105
+ OpenStruct.new(id: 'nl', name: 'Nederland'),
106
+ OpenStruct.new(id: 'no', name: 'Norway'),
107
+ OpenStruct.new(id: 'pl', name: 'Polish'),
108
+ OpenStruct.new(id: 'pt', name: 'Portugese'),
109
+ OpenStruct.new(id: 'pt-br', name: 'Portugese (Brasilian)'),
110
+ OpenStruct.new(id: 'sv', name: 'Sv'),
111
+ OpenStruct.new(id: 'sl', name: 'Slovakian'),
112
+ OpenStruct.new(id: 'tr', name: 'Tr')]
113
+ end
114
+
115
+ def get_controller(id)
116
+ proxmox_controllers_map.find { |controller| controller.id == id }
117
+ end
118
+
119
+ def proxmox_max_device(id)
120
+ options_select = get_controller(id)
121
+ options_select ? options_select.range : 1
122
+ end
123
+
124
+ def proxmox_caches_map
125
+ [OpenStruct.new(id: 'directsync', name: 'Direct sync'),
126
+ OpenStruct.new(id: 'writethrough', name: 'Write through'),
127
+ OpenStruct.new(id: 'writeback', name: 'Write back'),
128
+ OpenStruct.new(id: 'unsafe', name: 'Write back unsafe'),
129
+ OpenStruct.new(id: 'none', name: 'No cache')]
130
+ end
131
+
132
+ def proxmox_cpus_map
133
+ [OpenStruct.new(id: '486', name: '486'),
134
+ OpenStruct.new(id: 'athlon', name: 'athlon'),
135
+ OpenStruct.new(id: 'core2duo', name: 'core2duo'),
136
+ OpenStruct.new(id: 'coreduo', name: 'coreduo'),
137
+ OpenStruct.new(id: 'kvm32', name: 'kvm32'),
138
+ OpenStruct.new(id: 'kvm64', name: '(Default) kvm64'),
139
+ OpenStruct.new(id: 'pentium', name: 'pentium'),
140
+ OpenStruct.new(id: 'pentium2', name: 'pentium2'),
141
+ OpenStruct.new(id: 'pentium3', name: 'pentium3'),
142
+ OpenStruct.new(id: 'phenom', name: 'phenom'),
143
+ OpenStruct.new(id: 'qemu32', name: 'qemu32'),
144
+ OpenStruct.new(id: 'qemu64', name: 'qemu64'),
145
+ OpenStruct.new(id: 'Conroe', name: 'Conroe'),
146
+ OpenStruct.new(id: 'Penryn', name: 'Penryn'),
147
+ OpenStruct.new(id: 'Nehalem', name: 'Nehalem'),
148
+ OpenStruct.new(id: 'Westmere', name: 'Westmere'),
149
+ OpenStruct.new(id: 'SandyBridge', name: 'SandyBridge'),
150
+ OpenStruct.new(id: 'IvyBridge', name: 'IvyBridge'),
151
+ OpenStruct.new(id: 'Haswell', name: 'Haswell'),
152
+ OpenStruct.new(id: 'Haswell-noTSX', name: 'Haswell-noTSX'),
153
+ OpenStruct.new(id: 'Broadwell', name: 'Broadwell'),
154
+ OpenStruct.new(id: 'Broadwell-noTSX', name: 'Broadwell-noTSX'),
155
+ OpenStruct.new(id: 'Skylake-Client', name: 'Skylake-Client'),
156
+ OpenStruct.new(id: 'Opteron_G1', name: 'Opteron_G1'),
157
+ OpenStruct.new(id: 'Opteron_G2', name: 'Opteron_G2'),
158
+ OpenStruct.new(id: 'Opteron_G3', name: 'Opteron_G3'),
159
+ OpenStruct.new(id: 'Opteron_G4', name: 'Opteron_G4'),
160
+ OpenStruct.new(id: 'Opteron_G5', name: 'Opteron_G5'),
161
+ OpenStruct.new(id: 'host', name: 'host')]
162
+ end
163
+
164
+ def proxmox_scsihw_map
165
+ [OpenStruct.new(id: 'lsi', name: 'lsi'),
166
+ OpenStruct.new(id: 'lsi53c810', name: 'lsi53c810'),
167
+ OpenStruct.new(id: 'megasas', name: 'megasas'),
168
+ OpenStruct.new(id: 'virtio-scsi-pci', name: 'virtio-scsi-pci'),
169
+ OpenStruct.new(id: 'virtio-scsi-single', name: 'virtio-scsi-single'),
170
+ OpenStruct.new(id: 'pvscsi', name: 'pvscsi')]
171
+ end
172
+
173
+ def proxmox_networkcards_map
174
+ [OpenStruct.new(id: 'e1000', name: 'Intel E1000'),
175
+ OpenStruct.new(id: 'virtio', name: 'VirtIO (paravirtualized)'),
176
+ OpenStruct.new(id: 'rtl8139', name: 'Realtek RTL8139'),
177
+ OpenStruct.new(id: 'vmxnet3', name: 'VMware vmxnet3')]
178
+ end
179
+
180
+ def proxmox_bios_map
181
+ [OpenStruct.new(id: 'seabios', name: '(Default) Seabios'),
182
+ OpenStruct.new(id: 'ovmf', name: 'OVMF (UEFI)')]
183
+ end
184
+ end