foreman_fog_proxmox 0.11.1 → 0.13.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.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +24 -2
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +124 -52
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +0 -48
- 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/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 +11 -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/{models/foreman_fog_proxmox/proxmox_token_expiration.rb → helpers/proxmox_vm_cdrom_helper.rb} +15 -10
- data/app/helpers/proxmox_vm_cloudinit_helper.rb +43 -0
- data/app/helpers/proxmox_vm_config_helper.rb +159 -0
- data/app/helpers/proxmox_vm_helper.rb +24 -70
- data/app/helpers/proxmox_vm_interfaces_helper.rb +85 -0
- data/app/helpers/proxmox_vm_os_template_helper.rb +47 -0
- 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 +8 -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 +1 -0
- data/app/models/foreman_fog_proxmox/proxmox.rb +58 -15
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +20 -12
- 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 -30
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +108 -94
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +2 -1
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +79 -22
- 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 +4 -2
- 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 +16 -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/lib/foreman_fog_proxmox/engine.rb +9 -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 +49 -29
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +53 -30
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +22 -20
- 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 +12 -5
- 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 +21 -7
- 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
- metadata +44 -27
- data/app/helpers/proxmox_container_helper.rb +0 -163
- data/app/helpers/proxmox_server_helper.rb +0 -155
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6101f16731ab275d2adfb1b0abc8fd25690688e34569b7f63c360fb6442da5ec
|
4
|
+
data.tar.gz: 62bfd05f02a526de1a4decc27d5a8c6ee5539b58316fb0bc29338dc26f4c0a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d46aa0181a540105670a8b4cc988f791cde9ac05d8323c2eec250d53ee44c1b1eaea581619276f21cc7a433931470007019e2e3028ece8f750b4fcef704398ac
|
7
|
+
data.tar.gz: ce879270338d08b684991184079b8106519de9394c4e85b8cfcc74e5e30620a75d217eefa8ce8301711b30fbcd20ef051925a3190ae5b8b34e4c4157a1a3895c
|
data/README.md
CHANGED
@@ -32,6 +32,7 @@ You can support the plugin development via the following methods:
|
|
32
32
|
|>=0.10 |>=5.4|>=0.9.4|>=1.22|>=2.5|
|
33
33
|
|>=0.11 |>=5.4|>=0.10|>=1.22|>=2.5|
|
34
34
|
|>=0.12 |>=6.1|>=0.11|>=2.0|>=2.5|
|
35
|
+
|>=0.14 |>=6.2|>=0.13|>=2.0|>=2.5|
|
35
36
|
|
36
37
|
## Installation
|
37
38
|
|
@@ -114,8 +115,8 @@ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.thef
|
|
114
115
|
### Prerequisites
|
115
116
|
|
116
117
|
* You need a Proxmox VE 5.4+ server running.
|
117
|
-
* You need ruby >= 2.5. You can install it with [
|
118
|
-
* You also need nodejs in your dev machine to run webpack-dev-server. You can install it with [
|
118
|
+
* You need ruby >= 2.5. You can install it with [asdf-vm](https://asdf-vm.com).
|
119
|
+
* You also need nodejs in your dev machine to run webpack-dev-server. You can install it with [asdf-vm](https://asdf-vm.com).
|
119
120
|
|
120
121
|
### Platform
|
121
122
|
|
@@ -141,6 +142,8 @@ gem 'simplecov' # test
|
|
141
142
|
* In foreman directory, install dependencies:
|
142
143
|
|
143
144
|
```shell
|
145
|
+
gem install bundler
|
146
|
+
# prerequisites postgresql-client library on OS
|
144
147
|
bundle config set without 'libvirt ovirt mysql2'
|
145
148
|
bundle install
|
146
149
|
```
|
@@ -155,6 +158,12 @@ npm install
|
|
155
158
|
cp config/settings.yaml.test config/settings.yaml
|
156
159
|
```
|
157
160
|
|
161
|
+
add these lines to config/settings.yml:
|
162
|
+
|
163
|
+
```yaml
|
164
|
+
:webpack_dev_server: true
|
165
|
+
```
|
166
|
+
|
158
167
|
* SQLite is no more default rails dev or test database, instead add:
|
159
168
|
|
160
169
|
```shell
|
@@ -208,7 +217,7 @@ or just one:
|
|
208
217
|
|
209
218
|
```shell
|
210
219
|
export DISABLE_SPRING=true
|
211
|
-
bundle exec bin/rake test TEST
|
220
|
+
bundle exec bin/rake test TEST=../foreman_fog_proxmox/test/functional/compute_resources_controller_test.rb DATABASE_URL=nulldb://nohost
|
212
221
|
```
|
213
222
|
|
214
223
|
* Check code syntax with rubocop and foreman rules:
|
@@ -16,9 +16,13 @@
|
|
16
16
|
// along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
|
18
18
|
$(document).on('ContentLoad', tfm.numFields.initAll);
|
19
|
-
$(document).ready(sslVerifyPeerSelected);
|
20
19
|
|
21
|
-
function
|
20
|
+
$(document).ready(function () {
|
21
|
+
sslVerifyPeerSelected();
|
22
|
+
authMethodSelected();
|
23
|
+
});
|
24
|
+
|
25
|
+
function sslVerifyPeerSelected() {
|
22
26
|
var selected = $("#compute_resource_ssl_verify_peer").is(':checked');
|
23
27
|
var ssl_certs_block = $('#compute_resource_ssl_certs').parents('.clearfix');
|
24
28
|
var ssl_certs_textarea = $('#compute_resource_ssl_certs');
|
@@ -31,3 +35,21 @@ function sslVerifyPeerSelected(){
|
|
31
35
|
ssl_certs_textarea.hide();
|
32
36
|
}
|
33
37
|
}
|
38
|
+
|
39
|
+
function authMethodSelected() {
|
40
|
+
var selected = $("#compute_resource_auth_method").val();
|
41
|
+
console.log("auth_method="+selected);
|
42
|
+
var compute_ressource_user_token_field_set = $('#compute_ressource_user_token_field_set');
|
43
|
+
var compute_ressource_access_ticket_field_set = $('#compute_ressource_access_ticket_field_set');
|
44
|
+
if (selected == 'user_token') {
|
45
|
+
compute_ressource_user_token_field_set.show();
|
46
|
+
compute_ressource_user_token_field_set.removeAttr('disabled');
|
47
|
+
compute_ressource_access_ticket_field_set.hide();
|
48
|
+
compute_ressource_access_ticket_field_set.attr('disabled','disabled');
|
49
|
+
} else {
|
50
|
+
compute_ressource_access_ticket_field_set.show();
|
51
|
+
compute_ressource_access_ticket_field_set.removeAttr('disabled');
|
52
|
+
compute_ressource_user_token_field_set.hide();
|
53
|
+
compute_ressource_user_token_field_set.attr('disabled','disabled');
|
54
|
+
}
|
55
|
+
}
|
@@ -34,67 +34,139 @@ function vmTypeSelected() {
|
|
34
34
|
fieldsets.push({id: 'config_cdrom', toggle: false, new_vm: new_vm, selected: selected});
|
35
35
|
fieldsets.push({id: 'config_os', toggle: false, new_vm: new_vm, selected: selected});
|
36
36
|
fieldsets.push({id: 'config_dns', toggle: false, new_vm: new_vm, selected: selected});
|
37
|
-
fieldsets.forEach(
|
37
|
+
fieldsets.forEach(toggleFieldsets);
|
38
38
|
toggleVolumes(selected);
|
39
39
|
return false;
|
40
40
|
}
|
41
41
|
|
42
|
+
function volumeButtonAddId(id){
|
43
|
+
return $("a[data-association='" + id + "_volumes']");
|
44
|
+
}
|
45
|
+
|
46
|
+
function volumeFieldsetId(id, type){
|
47
|
+
return $("fieldset[id^='" + type + "_volume_"+ id +"']").not("fieldset[id$='_new_" + id +"_volumes']");
|
48
|
+
}
|
49
|
+
|
50
|
+
function indexByIdAndType(id, storage_type, vm_type){
|
51
|
+
let regex = new RegExp(`${vm_type}_volume_${storage_type}_(\\d+)`);
|
52
|
+
return id.match(regex)[1];
|
53
|
+
}
|
54
|
+
|
55
|
+
function volidByIndexAndTag(index, tag){
|
56
|
+
return $(tag + "[id='host_compute_attributes_volumes_attributes_" + index + "_volid']").val();
|
57
|
+
}
|
58
|
+
|
59
|
+
function hasCloudinit(){
|
60
|
+
result = false;
|
61
|
+
let id = volumeFieldsetId('cloud_init', 'server').attr('id');
|
62
|
+
if (id !== undefined){
|
63
|
+
let index = indexByIdAndType(id, 'cloud_init', 'server');
|
64
|
+
let volid = volidByIndexAndTag(index, 'input');
|
65
|
+
result = volid.includes("cloudinit");
|
66
|
+
}
|
67
|
+
return result;
|
68
|
+
}
|
69
|
+
|
70
|
+
function hasCdrom(){
|
71
|
+
result = false;
|
72
|
+
let id = volumeFieldsetId('cdrom', 'server').attr('id');
|
73
|
+
if (id !== undefined){
|
74
|
+
let index = indexByIdAndType(id, 'cdrom', 'server');
|
75
|
+
let checked = $("input[id^='host_compute_attributes_volumes_attributes_" + index + "_cdrom']:checked").val();
|
76
|
+
let isCdrom = checked === 'cdrom';
|
77
|
+
result = isCdrom;
|
78
|
+
let isImage = checked === 'image';
|
79
|
+
if (isImage) {
|
80
|
+
let volid = volidByIndexAndTag(index, 'select');
|
81
|
+
result = volid.includes("iso");
|
82
|
+
}
|
83
|
+
}
|
84
|
+
return result;
|
85
|
+
}
|
86
|
+
|
87
|
+
function cloudinit(id){
|
88
|
+
return id === 'cloud_init' && hasCloudinit();
|
89
|
+
}
|
90
|
+
|
91
|
+
function cdrom(id){
|
92
|
+
return id === 'cdrom' && hasCdrom();
|
93
|
+
}
|
94
|
+
|
95
|
+
function enableVolume(id, type){
|
96
|
+
volumeFieldsetId(id, type).show();
|
97
|
+
volumeButtonAddId(id).show();
|
98
|
+
if (cloudinit(id) || cdrom(id)){
|
99
|
+
volumeButtonAddId(id).hide();
|
100
|
+
}
|
101
|
+
volumeFieldsetId(id, type).removeAttr('disabled');
|
102
|
+
}
|
103
|
+
|
104
|
+
function disableVolume(id, type){
|
105
|
+
volumeFieldsetId(id, type).hide();
|
106
|
+
volumeButtonAddId(id).hide();
|
107
|
+
volumeFieldsetId(id, type).attr('disabled','disabled');
|
108
|
+
}
|
109
|
+
|
110
|
+
function volumes(type){
|
111
|
+
return type === 'qemu' ? ['hard_disk', 'cdrom', 'cloud_init'] : ['mp', 'rootfs'];
|
112
|
+
}
|
113
|
+
|
114
|
+
function volume(type){
|
115
|
+
return type === 'qemu' ? 'server' : 'container';
|
116
|
+
}
|
117
|
+
|
118
|
+
function toggleVolume(id, type1, type2){
|
119
|
+
type1 === type2 ? enableVolume(id, volume(type1)) : disableVolume(id, volume(type1));
|
120
|
+
}
|
121
|
+
|
42
122
|
function toggleVolumes(selected){
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
break;
|
54
|
-
case 'lxc':
|
55
|
-
div_container.show();
|
56
|
-
div_server.hide();
|
57
|
-
a_container.show();
|
58
|
-
a_server.hide();
|
59
|
-
break;
|
60
|
-
default:
|
61
|
-
console.log("unkown type="+selected);
|
62
|
-
break;
|
123
|
+
['qemu', 'lxc'].forEach(function(type){
|
124
|
+
volumes(type).forEach(function(id){
|
125
|
+
toggleVolume(id, selected, type);
|
126
|
+
});
|
127
|
+
});
|
128
|
+
}
|
129
|
+
|
130
|
+
function enableFieldset(id, fieldset) {
|
131
|
+
if (fieldset.toggle && fieldset.new_vm){
|
132
|
+
fieldset_id(id, fieldset).show();
|
63
133
|
}
|
134
|
+
fieldset_id(id, fieldset).removeAttr('disabled');
|
135
|
+
input_hidden_id(id).removeAttr('disabled');
|
64
136
|
}
|
65
137
|
|
66
|
-
function
|
67
|
-
|
68
|
-
|
69
|
-
var removable_input_hidden = $("div.removable-item[style='display: none;']" + " + input:hidden");
|
70
|
-
var server_fieldset = $("fieldset[id^='server_"+fieldset.id+"']");
|
71
|
-
var container_fieldset = $("fieldset[id^='container_"+fieldset.id+"']");
|
72
|
-
removable_input_hidden.attr('disabled','disabled');
|
73
|
-
switch (fieldset.selected) {
|
74
|
-
case 'qemu':
|
75
|
-
if (fieldset.toggle && fieldset.new_vm){
|
76
|
-
server_fieldset.show();
|
77
|
-
container_fieldset.hide();
|
78
|
-
}
|
79
|
-
server_fieldset.removeAttr('disabled');
|
80
|
-
container_fieldset.attr('disabled','disabled');
|
81
|
-
server_input_hidden.removeAttr('disabled');
|
82
|
-
container_input_hidden.attr('disabled','disabled');
|
83
|
-
break;
|
84
|
-
case 'lxc':
|
85
|
-
if (fieldset.toggle && fieldset.new_vm){
|
86
|
-
server_fieldset.hide();
|
87
|
-
container_fieldset.show();
|
88
|
-
}
|
89
|
-
server_fieldset.attr('disabled','disabled');
|
90
|
-
container_fieldset.removeAttr('disabled');
|
91
|
-
container_input_hidden.removeAttr('disabled');
|
92
|
-
server_input_hidden.attr('disabled','disabled');
|
93
|
-
break;
|
94
|
-
default:
|
95
|
-
console.log("unkown type="+fieldset.selected);
|
96
|
-
break;
|
138
|
+
function disableFieldset(id, fieldset) {
|
139
|
+
if (fieldset.toggle && fieldset.new_vm){
|
140
|
+
fieldset_id(id, fieldset).hide();
|
97
141
|
}
|
142
|
+
fieldset_id(id, fieldset).attr('disabled','disabled');
|
143
|
+
input_hidden_id(id).attr('disabled','disabled');
|
144
|
+
}
|
145
|
+
|
146
|
+
function toggleFieldset(id, fieldset, type1, type2) {
|
147
|
+
type1 === type2 ? enableFieldset(id, fieldset) : disableFieldset(id, fieldset);
|
148
|
+
}
|
149
|
+
|
150
|
+
function input_hidden_id(id){
|
151
|
+
return $("div[id^='"+ id +"_volumes']" + " + input:hidden");
|
152
|
+
}
|
153
|
+
|
154
|
+
function fieldset_id(id, fieldset){
|
155
|
+
return $("fieldset[id^='" + id + "_"+fieldset.id+"']");
|
156
|
+
}
|
157
|
+
|
158
|
+
function fieldsets(type){
|
159
|
+
return type === 'qemu' ? ['server'] : ['container'];
|
160
|
+
}
|
161
|
+
|
162
|
+
function toggleFieldsets(fieldset){
|
163
|
+
var removable_input_hidden = $("div.removable-item[style='display: none;']" + " + input:hidden");
|
164
|
+
removable_input_hidden.attr('disabled','disabled');
|
165
|
+
['qemu', 'lxc'].forEach(function(type){
|
166
|
+
fieldsets(type).forEach(function(id){
|
167
|
+
toggleFieldset(id, fieldset, fieldset.selected, type);
|
168
|
+
});
|
169
|
+
});
|
98
170
|
}
|
99
171
|
|
100
172
|
function nodeSelected(item) {
|
@@ -15,51 +15,6 @@
|
|
15
15
|
// You should have received a copy of the GNU General Public License
|
16
16
|
// along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
17
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
18
|
function attributesPrefixSelector(profile, type) {
|
64
19
|
return profile ? '#compute_attribute_vm_attrs_' + type + '_attributes_': '#host_compute_attributes_' + type + '_attributes_';
|
65
20
|
}
|
@@ -73,7 +28,6 @@ function getIndex(item) {
|
|
73
28
|
var pattern = /(host_compute_attributes_volumes_attributes_||compute_attribute_vm_attrs_volumes_attributes_)(\d+)[_](.*)/i;
|
74
29
|
pattern_a = pattern.exec(id);
|
75
30
|
var index = pattern_a[2];
|
76
|
-
console.log("index=" + index);
|
77
31
|
return index;
|
78
32
|
}
|
79
33
|
|
@@ -86,7 +40,6 @@ function controllerSelected(item) {
|
|
86
40
|
var index = getIndex(item);
|
87
41
|
var max = computeControllerMaxDevice(controller);
|
88
42
|
var profile = isProfile();
|
89
|
-
console.log("profile="+profile);
|
90
43
|
var device_selector = volumesAttributesSelector(profile,index,'device');
|
91
44
|
var id_selector = volumesAttributesSelector(profile,index,'id');
|
92
45
|
$(device_selector).attr('data-soft-max', max);
|
@@ -100,7 +53,6 @@ function deviceSelected(item) {
|
|
100
53
|
var device = $(item).limitedSpinner('value');
|
101
54
|
var index = getIndex(item);
|
102
55
|
var profile = isProfile();
|
103
|
-
console.log("profile="+profile);
|
104
56
|
var controller_selector = volumesAttributesSelector(profile,index,'controller');
|
105
57
|
var id_selector = volumesAttributesSelector(profile,index,'id');
|
106
58
|
var controller = $(controller_selector).val();
|
@@ -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 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(id);
|
22
|
+
var index = pattern_a[2];
|
23
|
+
return index;
|
24
|
+
}
|
25
|
+
|
26
|
+
function volumeId(type,index){
|
27
|
+
let id = '#volume_' + type + '_' + index;
|
28
|
+
return id;
|
29
|
+
}
|
30
|
+
|
31
|
+
function enableField(id) {
|
32
|
+
$(id).show();
|
33
|
+
$(id).removeAttr('disabled');
|
34
|
+
}
|
35
|
+
|
36
|
+
function disableField(id) {
|
37
|
+
$(id).hide();
|
38
|
+
$(id).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
|
+
}
|