foreman_fog_proxmox 0.12.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -6
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +36 -2
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +134 -60
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +2 -50
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js +39 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cdrom.js +63 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js +25 -0
- data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
- data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +23 -25
- data/app/helpers/proxmox_compute_controllers_helper.rb +39 -0
- data/app/helpers/proxmox_compute_resources_helper.rb +49 -0
- data/app/helpers/proxmox_compute_selectors_helper.rb +6 -44
- data/app/helpers/proxmox_form_helper.rb +12 -4
- data/app/{models/concerns/fog_extensions/proxmox/volume.rb → helpers/proxmox_storages_helper.rb} +5 -8
- data/app/helpers/proxmox_vm_cdrom_helper.rb +35 -0
- data/app/helpers/proxmox_vm_cloudinit_helper.rb +43 -0
- data/app/helpers/proxmox_vm_config_helper.rb +160 -0
- data/app/helpers/proxmox_vm_helper.rb +24 -62
- data/app/helpers/proxmox_vm_interfaces_helper.rb +85 -0
- data/app/helpers/proxmox_vm_os_template_helper.rb +47 -0
- data/app/{models/foreman_fog_proxmox/proxmox_token_expiration.rb → helpers/proxmox_vm_uuid_helper.rb} +14 -10
- data/app/helpers/proxmox_vm_volumes_helper.rb +105 -0
- data/app/models/concerns/fog_extensions/proxmox/disk.rb +17 -2
- data/app/models/concerns/fog_extensions/proxmox/interface.rb +19 -4
- data/app/models/concerns/fog_extensions/proxmox/server.rb +12 -3
- data/app/models/concerns/fog_extensions/proxmox/server_config.rb +8 -30
- data/app/models/concerns/host_ext/proxmox/interfaces.rb +7 -2
- data/app/models/concerns/orchestration/proxmox/compute.rb +49 -0
- data/app/models/foreman_fog_proxmox/proxmox.rb +58 -15
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +14 -18
- data/app/models/foreman_fog_proxmox/proxmox_connection.rb +14 -9
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +2 -1
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +53 -28
- data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox_version.rb +7 -2
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +19 -31
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +108 -94
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +9 -6
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +79 -22
- data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +6 -2
- data/app/views/api/v2/compute_resources/proxmox.json.rabl +1 -1
- data/app/views/compute_resources/form/_proxmox.html.erb +23 -10
- data/app/views/compute_resources/show/_proxmox.html.erb +6 -6
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +3 -1
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +46 -29
- data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +3 -3
- data/app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb +2 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +8 -7
- data/app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb +0 -2
- data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +15 -14
- data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/server/_volume_cdrom.html.erb +34 -0
- data/app/views/compute_resources_vms/form/proxmox/server/_volume_cloud_init.html.erb +29 -0
- data/app/views/compute_resources_vms/form/proxmox/server/{_volume.html.erb → _volume_hard_disk.html.erb} +7 -3
- data/app/views/compute_resources_vms/show/_proxmox.html.erb +2 -0
- data/config/routes.rb +7 -7
- data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +29 -0
- data/lib/foreman_fog_proxmox/engine.rb +15 -10
- data/lib/foreman_fog_proxmox/hash_collection.rb +69 -0
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/lib/tasks/foreman_fog_proxmox_tasks.rake +0 -3
- data/test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb +20 -8
- data/test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb +5 -5
- data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +17 -7
- data/test/factories/proxmox_factory.rb +4 -4
- data/test/functional/compute_resources_controller_test.rb +4 -4
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +53 -32
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +56 -31
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +22 -20
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb +38 -0
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb +50 -0
- data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +10 -11
- data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +38 -10
- data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +10 -10
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +34 -24
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +8 -8
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +181 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb +131 -0
- data/test/unit/foreman_fog_proxmox/{proxmox_vm_commands_server_update_volumes_test.rb → proxmox_vm_commands_server_update_hard_disk_test.rb} +45 -19
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +21 -21
- data/test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb +3 -3
- data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +3 -3
- metadata +47 -26
- data/app/helpers/proxmox_container_helper.rb +0 -163
- data/app/helpers/proxmox_server_helper.rb +0 -155
@@ -0,0 +1,39 @@
|
|
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 getIndex(item) {
|
19
|
+
var index_id = $(item).attr('id');
|
20
|
+
var pattern = /(host_compute_attributes_volumes_attributes_||compute_attribute_vm_attrs_volumes_attributes_)(\d+)[_](.*)/i;
|
21
|
+
pattern_a = pattern.exec(index_id);
|
22
|
+
var index = pattern_a[2];
|
23
|
+
return index;
|
24
|
+
}
|
25
|
+
|
26
|
+
function volumeId(type,index){
|
27
|
+
let volume_id = '#volume_' + type + '_' + index;
|
28
|
+
return volume_id;
|
29
|
+
}
|
30
|
+
|
31
|
+
function enableField(item) {
|
32
|
+
$(item).show();
|
33
|
+
$(item).removeAttr('disabled');
|
34
|
+
}
|
35
|
+
|
36
|
+
function disableField(item) {
|
37
|
+
$(item).hide();
|
38
|
+
$(item).attr('disabled','disabled');
|
39
|
+
}
|
@@ -0,0 +1,63 @@
|
|
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 index = getIndex(item);
|
21
|
+
var cdrom_image_form_id = '#cdrom_image_form_' + index;
|
22
|
+
|
23
|
+
switch (selected) {
|
24
|
+
case 'none':
|
25
|
+
initCdromStorage(index);
|
26
|
+
initCdromOptions(index,'volid');
|
27
|
+
disableField(cdrom_image_form_id);
|
28
|
+
break;
|
29
|
+
case 'cdrom':
|
30
|
+
initCdromStorage(index);
|
31
|
+
initCdromOptions(index,'volid');
|
32
|
+
disableField(cdrom_image_form_id);
|
33
|
+
break;
|
34
|
+
case 'image':
|
35
|
+
initCdromStorage(index);
|
36
|
+
initCdromOptions(index,'volid');
|
37
|
+
enableField(cdrom_image_form_id);
|
38
|
+
break;
|
39
|
+
default:
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
return false;
|
43
|
+
}
|
44
|
+
|
45
|
+
function initCdromStorage(index) {
|
46
|
+
var select = '#host_compute_attributes_volumes_attributes_' + index + '_storage';
|
47
|
+
$(select + ' option:selected').prop('selected', false);
|
48
|
+
$(select).val('');
|
49
|
+
}
|
50
|
+
|
51
|
+
function initCdromOptions(index, name) {
|
52
|
+
var select = '#host_compute_attributes_volumes_attributes_' + index + '_' + name;
|
53
|
+
$(select).empty();
|
54
|
+
$(select).append($("<option></option>").val('').text(''));
|
55
|
+
$(select).val('');
|
56
|
+
}
|
57
|
+
|
58
|
+
function storageIsoSelected(item) {
|
59
|
+
var index = getIndex(item);
|
60
|
+
var storage = $(item).val();
|
61
|
+
var node_id = $('#host_compute_attributes_node_id').val();
|
62
|
+
updateOptions('isos', 'compute_attributes_volumes_attributes_' + index , 'volid', undefined, undefined, 'volid', node_id, storage);
|
63
|
+
}
|
@@ -0,0 +1,25 @@
|
|
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 cloudinitControllerSelected(item) {
|
19
|
+
var controller = $(item).val();
|
20
|
+
var index = getIndex(item);
|
21
|
+
var max = computeControllerMaxDevice(controller);
|
22
|
+
var device_selector = 'host_compute_attributes_volumes_attributes_' + index + 'device';
|
23
|
+
$(device_selector).attr('data-soft-max', max);
|
24
|
+
tfm.numFields.initAll();
|
25
|
+
}
|
@@ -19,59 +19,57 @@
|
|
19
19
|
|
20
20
|
module ForemanFogProxmox
|
21
21
|
class ComputeResourcesController < ::ApplicationController
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def isos_by_node_and_storage
|
26
|
-
volumes = @compute_resource.images_by_storage(params[:node_id], params[:storage], 'iso')
|
22
|
+
# GET foreman_fog_proxmox/isos/:compute_resource_id/:node_id/:storage
|
23
|
+
def isos_by_id_and_node_and_storage
|
24
|
+
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id], params[:storage], 'iso')
|
27
25
|
respond_to do |format|
|
28
26
|
format.json { render :json => volumes }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
|
-
# GET foreman_fog_proxmox/ostemplates/:node_id/:storage
|
33
|
-
def
|
34
|
-
volumes =
|
30
|
+
# GET foreman_fog_proxmox/ostemplates/:compute_resource_id/:node_id/:storage
|
31
|
+
def ostemplates_by_id_and_node_and_storage
|
32
|
+
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id], params[:storage], 'vztmpl')
|
35
33
|
respond_to do |format|
|
36
34
|
format.json { render :json => volumes }
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
|
-
# GET foreman_fog_proxmox/isos/:node_id
|
41
|
-
def
|
42
|
-
volumes =
|
38
|
+
# GET foreman_fog_proxmox/isos/:compute_resource_id/:node_id
|
39
|
+
def isos_by_id_and_node
|
40
|
+
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id], params[:storage], 'iso')
|
43
41
|
respond_to do |format|
|
44
42
|
format.json { render :json => volumes }
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
|
-
# GET foreman_fog_proxmox/ostemplates/:node_id
|
49
|
-
def
|
50
|
-
storages =
|
46
|
+
# GET foreman_fog_proxmox/ostemplates/:compute_resource_id/:node_id
|
47
|
+
def ostemplates_by_id_and_node
|
48
|
+
storages = load_compute_resource(params[:compute_resource_id]).storages(params[:node_id], 'vztmpl')
|
51
49
|
respond_to do |format|
|
52
50
|
format.json { render :json => storages }
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
|
-
# GET foreman_fog_proxmox/storages/:node_id
|
57
|
-
def
|
58
|
-
storages =
|
54
|
+
# GET foreman_fog_proxmox/storages/:compute_resource_id/:node_id
|
55
|
+
def storages_by_id_and_node
|
56
|
+
storages = load_compute_resource(params[:compute_resource_id]).storages(params[:node_id])
|
59
57
|
respond_to do |format|
|
60
58
|
format.json { render :json => storages }
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
64
|
-
# GET foreman_fog_proxmox/isostorages/:node_id
|
65
|
-
def
|
66
|
-
storages =
|
62
|
+
# GET foreman_fog_proxmox/isostorages/:compute_resource_id/:node_id
|
63
|
+
def iso_storages_by_id_and_node
|
64
|
+
storages = load_compute_resource(params[:compute_resource_id]).storages(params[:node_id], 'iso')
|
67
65
|
respond_to do |format|
|
68
66
|
format.json { render :json => storages }
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
72
|
-
# GET foreman_fog_proxmox/bridges/:node_id
|
73
|
-
def
|
74
|
-
bridges =
|
70
|
+
# GET foreman_fog_proxmox/bridges/:compute_resource_id/:node_id
|
71
|
+
def bridges_by_id_and_node
|
72
|
+
bridges = load_compute_resource(params[:compute_resource_id]).bridges(params[:node_id])
|
75
73
|
respond_to do |format|
|
76
74
|
format.json { render :json => bridges }
|
77
75
|
end
|
@@ -79,8 +77,8 @@ module ForemanFogProxmox
|
|
79
77
|
|
80
78
|
private
|
81
79
|
|
82
|
-
def load_compute_resource
|
83
|
-
|
80
|
+
def load_compute_resource(compute_resource_id)
|
81
|
+
ComputeResource.find(compute_resource_id)
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|
@@ -0,0 +1,39 @@
|
|
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 ProxmoxComputeControllersHelper
|
21
|
+
def proxmox_controllers_map
|
22
|
+
proxmox_controllers_cloudinit_map << ForemanFogProxmox::OptionsSelect.new(name: 'VirtIO Block', id: 'virtio', range: 15)
|
23
|
+
end
|
24
|
+
|
25
|
+
def proxmox_controllers_cloudinit_map
|
26
|
+
[ForemanFogProxmox::OptionsSelect.new(id: 'ide', name: 'IDE', range: 3),
|
27
|
+
ForemanFogProxmox::OptionsSelect.new(id: 'sata', name: 'SATA', range: 5),
|
28
|
+
ForemanFogProxmox::OptionsSelect.new(id: 'scsi', name: 'SCSI', range: 13)]
|
29
|
+
end
|
30
|
+
|
31
|
+
def proxmox_scsi_controllers_map
|
32
|
+
[OpenStruct.new(id: 'lsi', name: 'LSI 53C895A (Default)'),
|
33
|
+
OpenStruct.new(id: 'lsi53c810', name: 'LSI 53C810'),
|
34
|
+
OpenStruct.new(id: 'virtio-scsi-pci', name: 'VirtIO SCSI'),
|
35
|
+
OpenStruct.new(id: 'virtio-scsi-single', name: 'VirtIO SCSI Single'),
|
36
|
+
OpenStruct.new(id: 'megasas', name: 'MegaRAID SAS 8708EM2'),
|
37
|
+
OpenStruct.new(id: 'pvscsi', name: 'VMware PVSCSI')]
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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 ProxmoxComputeResourcesHelper
|
21
|
+
def user_token_expiration_date(compute_resource)
|
22
|
+
expire = compute_resource.current_user_token_expire
|
23
|
+
rescue ::Foreman::Exception => e
|
24
|
+
return 'Has already expired. Please edit the compute resource to set a new valid one.' if e.message == 'User token expired'
|
25
|
+
rescue StandardError => e
|
26
|
+
logger.warn(format(_('failed to get identity client version: %<e>s'), e: e))
|
27
|
+
raise e
|
28
|
+
else
|
29
|
+
return 'Never' if expire == 0
|
30
|
+
|
31
|
+
Time.at(expire).utc
|
32
|
+
end
|
33
|
+
|
34
|
+
def cluster_nodes(compute_resource)
|
35
|
+
nodes = compute_resource.nodes ? compute_resource.nodes.collect(&:node) : []
|
36
|
+
rescue ::Foreman::Exception => e
|
37
|
+
return [] if e.message == 'User token expired'
|
38
|
+
rescue StandardError => e
|
39
|
+
logger.warn(format(_('failed to get cluster nodes: %<e>s'), e: e))
|
40
|
+
raise e
|
41
|
+
else
|
42
|
+
nodes
|
43
|
+
end
|
44
|
+
|
45
|
+
def proxmox_auth_methods_map
|
46
|
+
[OpenStruct.new(id: 'access_ticket', name: '(Default) Access ticket'),
|
47
|
+
OpenStruct.new(id: 'user_token', name: 'User token')]
|
48
|
+
end
|
49
|
+
end
|
@@ -40,22 +40,6 @@ module ProxmoxComputeSelectorsHelper
|
|
40
40
|
OpenStruct.new(id: 'unmanaged', name: 'Unmanaged')]
|
41
41
|
end
|
42
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
43
|
def proxmox_operating_systems_map
|
60
44
|
[OpenStruct.new(id: 'other', name: 'Unspecified OS'),
|
61
45
|
OpenStruct.new(id: 'wxp', name: 'Microsoft Windows XP'),
|
@@ -84,34 +68,6 @@ module ProxmoxComputeSelectorsHelper
|
|
84
68
|
OpenStruct.new(id: 'serial3', name: 'Serial terminal 3')]
|
85
69
|
end
|
86
70
|
|
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
71
|
def get_controller(id)
|
116
72
|
proxmox_controllers_map.find { |controller| controller.id == id }
|
117
73
|
end
|
@@ -161,6 +117,12 @@ module ProxmoxComputeSelectorsHelper
|
|
161
117
|
OpenStruct.new(id: 'host', name: 'host')]
|
162
118
|
end
|
163
119
|
|
120
|
+
def proxmox_cpu_flags_map
|
121
|
+
[OpenStruct.new(id: '-1', name: 'Off'),
|
122
|
+
OpenStruct.new(id: '0', name: 'Default'),
|
123
|
+
OpenStruct.new(id: '+1', name: 'On')]
|
124
|
+
end
|
125
|
+
|
164
126
|
def proxmox_scsihw_map
|
165
127
|
[OpenStruct.new(id: 'lsi', name: 'lsi'),
|
166
128
|
OpenStruct.new(id: 'lsi53c810', name: 'lsi53c810'),
|
@@ -29,8 +29,7 @@ module ProxmoxFormHelper
|
|
29
29
|
options[:value] = value if value.present?
|
30
30
|
addClass options, 'form-control'
|
31
31
|
pass = f.password_field(attr, options) +
|
32
|
-
|
33
|
-
title: 'Caps lock ON', style: 'display:none')
|
32
|
+
tag(:span, '', class: 'glyphicon glyphicon-warning-sign input-addon', title: 'Caps lock ON', style: 'display:none')
|
34
33
|
if unset_button
|
35
34
|
button = link_to_function(icon_text('edit', '', :kind => 'pficon'), 'toggle_input_group(this)', :id => 'disable-pass-btn', :class => 'btn btn-default', :title => _('Change the password'))
|
36
35
|
input_group(pass, input_group_btn(button))
|
@@ -54,7 +53,7 @@ module ProxmoxFormHelper
|
|
54
53
|
options[:form_builder_local] ||= :f
|
55
54
|
options[:form_builder_attrs] ||= {}
|
56
55
|
|
57
|
-
content_tag(:div, :class => "#{options[:type]}_#{association}_fields_template form_template
|
56
|
+
content_tag(:div, :class => "#{options[:type]}_#{association}_fields_template form_template", :style => 'display: none;') do
|
58
57
|
form_builder.fields_for(association, options[:object], :child_index => "new_#{options[:type]}_#{association}") do |f|
|
59
58
|
render(:partial => options[:partial], :layout => options[:layout],
|
60
59
|
:locals => { options[:form_builder_local] => f }.merge(options[:form_builder_attrs]))
|
@@ -65,6 +64,15 @@ module ProxmoxFormHelper
|
|
65
64
|
def add_child_link_typed(name, association, type, opts = {})
|
66
65
|
opts[:class] = [opts[:class], 'add_nested_fields btn btn-primary'].compact.join(' ')
|
67
66
|
opts[:"data-association"] = (type + '_' + association.to_s).to_sym
|
68
|
-
|
67
|
+
hide = ''
|
68
|
+
hide += '$("[data-association=' + type + '_volumes]").hide();' unless ['hard_disk', 'mp'].include?(type)
|
69
|
+
link_to_function(name.to_s, 'add_child_node(this);tfm.numFields.initAll();' + hide, opts)
|
70
|
+
end
|
71
|
+
|
72
|
+
def remove_child_link_typed(name, f, type, opts = {})
|
73
|
+
opts[:class] = [opts[:class], 'remove_nested_fields'].compact.join(' ')
|
74
|
+
hide = ''
|
75
|
+
hide += '$("[data-association=' + type + '_volumes]").show();' unless ['hard_disk', 'mp'].include?(type)
|
76
|
+
f.hidden_field(opts[:method] || :_destroy) + link_to_function(name, 'remove_child_node(this);' + hide, opts)
|
69
77
|
end
|
70
78
|
end
|
data/app/{models/concerns/fog_extensions/proxmox/volume.rb → helpers/proxmox_storages_helper.rb}
RENAMED
@@ -17,13 +17,10 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
-
module
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
volid ? volid.match(/^([\w-]+)[:]base-(\d+)-disk-(\d+)/) : false
|
26
|
-
end
|
27
|
-
end
|
20
|
+
module ProxmoxStoragesHelper
|
21
|
+
def proxmox_storages_types_map
|
22
|
+
[OpenStruct.new(id: 'hard_disk', name: 'Hard disk'),
|
23
|
+
OpenStruct.new(id: 'cdrom', name: 'CD-ROM'),
|
24
|
+
OpenStruct.new(id: 'cloud_init', name: 'Cloud-init')]
|
28
25
|
end
|
29
26
|
end
|