foreman_fog_proxmox 0.15.1 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/proxmox_compute_resources_helper.rb +1 -1
  3. data/app/helpers/proxmox_form_helper.rb +2 -2
  4. data/app/helpers/proxmox_vm_attrs_helper.rb +131 -0
  5. data/app/helpers/proxmox_vm_interfaces_helper.rb +3 -3
  6. data/app/helpers/proxmox_vm_volumes_helper.rb +3 -3
  7. data/app/models/concerns/fog_extensions/proxmox/node.rb +1 -1
  8. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +3 -3
  9. data/app/models/foreman_fog_proxmox/proxmox_images.rb +5 -0
  10. data/app/models/foreman_fog_proxmox/proxmox_version.rb +1 -1
  11. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +1 -1
  12. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +1 -1
  13. data/app/overrides/compute_resources_vms/form/add_from_profile_to_compute_attributes_form.rb +8 -0
  14. data/app/overrides/compute_resources_vms/form/add_react_component_to_host.rb +25 -0
  15. data/app/overrides/compute_resources_vms/form/update_react_component_to_host_form.rb +25 -0
  16. data/app/views/compute_resources_vms/form/proxmox/_add_react_component_to_host_form.html.erb +5 -0
  17. data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +21 -21
  18. data/app/views/compute_resources_vms/form/proxmox/_update_react_component_to_host_form.html.erb +26 -0
  19. data/config/routes.rb +3 -3
  20. data/lib/foreman_fog_proxmox/version.rb +1 -1
  21. data/package.json +42 -0
  22. data/test/factories/proxmox_factory.rb +7 -7
  23. data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +1 -1
  24. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +6 -6
  25. data/webpack/components/GeneralTabContent.js +107 -0
  26. data/webpack/components/ProxmoxComputeSelectors.js +141 -0
  27. data/webpack/components/ProxmoxContainer/MountPoint.js +91 -0
  28. data/webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js +85 -0
  29. data/webpack/components/ProxmoxContainer/ProxmoxContainerNetwork.js +179 -0
  30. data/webpack/components/ProxmoxContainer/ProxmoxContainerOptions.js +104 -0
  31. data/webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js +194 -0
  32. data/webpack/components/ProxmoxContainer/components/NetworkInterface.js +193 -0
  33. data/webpack/components/ProxmoxServer/ProxmoxServerHardware.js +204 -0
  34. data/webpack/components/ProxmoxServer/ProxmoxServerNetwork.js +161 -0
  35. data/webpack/components/ProxmoxServer/ProxmoxServerOptions.js +105 -0
  36. data/webpack/components/ProxmoxServer/ProxmoxServerStorage.js +272 -0
  37. data/webpack/components/ProxmoxServer/components/CDRom.js +149 -0
  38. data/webpack/components/ProxmoxServer/components/CPUFlagsModal.js +88 -0
  39. data/webpack/components/ProxmoxServer/components/HardDisk.js +143 -0
  40. data/webpack/components/ProxmoxServer/components/NetworkInterface.js +150 -0
  41. data/webpack/components/ProxmoxStoragesUtils.js +50 -0
  42. data/webpack/components/ProxmoxVmType.js +256 -0
  43. data/webpack/components/ProxmoxVmUtils.js +62 -0
  44. data/webpack/components/common/FormInputs.js +143 -0
  45. data/webpack/global_index.js +15 -0
  46. data/webpack/index.js +7 -0
  47. metadata +49 -21
@@ -0,0 +1,62 @@
1
+ import $ from 'jquery';
2
+
3
+ function networkSelected(value) {
4
+ const fieldSets = [];
5
+ fieldSets.push({
6
+ id: 'network',
7
+ toggle: true,
8
+ newVm: true,
9
+ selected: value,
10
+ });
11
+ fieldSets.forEach(toggleFieldsets);
12
+ return false;
13
+ }
14
+
15
+ function enableFieldSet(fieldSetId, fieldSet) {
16
+ if (fieldSet.toggle && fieldSet.newVm) {
17
+ getFieldSetById(fieldSetId, fieldSet).show();
18
+ }
19
+ getFieldSetById(fieldSetId, fieldSet).removeAttr('disabled');
20
+ getInputHiddenById(fieldSetId).removeAttr('disabled');
21
+ }
22
+
23
+ function disableFieldSet(fieldSetId, fieldSet) {
24
+ if (fieldSet.toggle && fieldSet.newVm) {
25
+ getFieldSetById(fieldSetId, fieldSet).hide();
26
+ }
27
+ getFieldSetById(fieldSetId, fieldSet).attr('disabled', 'disabled');
28
+ getInputHiddenById(fieldSetId).attr('disabled', 'disabled');
29
+ }
30
+
31
+ function toggleFieldSet(fieldSetId, fieldSet, type1, type2) {
32
+ type1 === type2
33
+ ? enableFieldSet(fieldSetId, fieldSet)
34
+ : disableFieldSet(fieldSetId, fieldSet);
35
+ }
36
+
37
+ function getInputHiddenById(volumeId) {
38
+ return $(`div[id^='${volumeId}_volumes'] + input:hidden`);
39
+ }
40
+
41
+ function getFieldSetById(fieldSetId, fieldSet) {
42
+ return $(`fieldset[id^='${fieldSetId}_${fieldSet.id}']`);
43
+ }
44
+
45
+ function getFieldSets(type) {
46
+ return type === 'qemu' ? ['server'] : ['container'];
47
+ }
48
+
49
+ function toggleFieldsets(fieldSet) {
50
+ const removableInputHidden = $(
51
+ `div.removable-item[style='display: none;'] + input:hidden`
52
+ );
53
+ removableInputHidden.attr('disabled', 'disabled');
54
+ ['qemu', 'lxc'].forEach(type => {
55
+ getFieldSets(type).forEach(fieldSetId => {
56
+ toggleFieldSet(fieldSetId, fieldSet, fieldSet.selected, type);
57
+ });
58
+ });
59
+ }
60
+
61
+ window.networkSelected = networkSelected;
62
+ export { networkSelected };
@@ -0,0 +1,143 @@
1
+ import React, { Fragment } from 'react';
2
+ import { FieldLevelHelp } from 'patternfly-react';
3
+ import PropTypes from 'prop-types';
4
+ import CommonForm from 'foremanReact/components/common/forms/CommonForm';
5
+
6
+ const InputField = ({
7
+ name,
8
+ label,
9
+ info,
10
+ value,
11
+ onChange,
12
+ required,
13
+ type,
14
+ disabled,
15
+ options,
16
+ checked,
17
+ error,
18
+ }) => {
19
+ const renderOptions = opts =>
20
+ opts.map(option => <option value={option.value}>{option.label}</option>);
21
+
22
+ let renderComponent;
23
+
24
+ switch (type) {
25
+ case 'textarea':
26
+ renderComponent = (
27
+ <textarea
28
+ name={name}
29
+ className="form-control"
30
+ rows="3"
31
+ cols="50"
32
+ value={value}
33
+ onChange={onChange}
34
+ />
35
+ );
36
+ break;
37
+ case 'select':
38
+ renderComponent = (
39
+ <select
40
+ disabled={disabled}
41
+ name={name}
42
+ className="form-control"
43
+ value={value}
44
+ onChange={onChange}
45
+ >
46
+ {renderOptions(options)}
47
+ </select>
48
+ );
49
+ break;
50
+ case 'checkbox':
51
+ renderComponent = (
52
+ <input
53
+ name={name}
54
+ type={type}
55
+ className=""
56
+ value={value}
57
+ checked={checked}
58
+ onChange={onChange}
59
+ disabled={disabled}
60
+ />
61
+ );
62
+ break;
63
+ default:
64
+ renderComponent = (
65
+ <input
66
+ name={name}
67
+ type={type}
68
+ className="form-control"
69
+ value={value}
70
+ onChange={onChange}
71
+ disabled={disabled}
72
+ />
73
+ );
74
+ break;
75
+ }
76
+
77
+ return (
78
+ <CommonForm
79
+ label={label}
80
+ required={required}
81
+ className="common-textInput"
82
+ tooltipHelp={
83
+ info && (
84
+ <FieldLevelHelp
85
+ buttonClass="field-help"
86
+ content={<Fragment>{info}</Fragment>}
87
+ />
88
+ )
89
+ }
90
+ >
91
+ {renderComponent}
92
+ {error && (
93
+ <div style={{ color: 'red', marginTop: '0.5rem' }}>{error}</div>
94
+ )}
95
+ </CommonForm>
96
+ );
97
+ };
98
+
99
+ InputField.propTypes = {
100
+ name: PropTypes.string,
101
+ label: PropTypes.string,
102
+ info: PropTypes.string,
103
+ value: PropTypes.oneOfType([
104
+ PropTypes.string,
105
+ PropTypes.number,
106
+ PropTypes.bool,
107
+ ]),
108
+ onChange: PropTypes.func.isRequired,
109
+ required: PropTypes.bool,
110
+ type: PropTypes.oneOf([
111
+ 'text',
112
+ 'number',
113
+ 'password',
114
+ 'textarea',
115
+ 'select',
116
+ 'checkbox',
117
+ ]),
118
+ disabled: PropTypes.bool,
119
+ checked: PropTypes.bool,
120
+ options: PropTypes.arrayOf(
121
+ PropTypes.shape({
122
+ label: PropTypes.string.isRequired,
123
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
124
+ .isRequired,
125
+ })
126
+ ),
127
+ error: PropTypes.string,
128
+ };
129
+
130
+ InputField.defaultProps = {
131
+ name: '',
132
+ label: '',
133
+ info: undefined,
134
+ value: '',
135
+ required: false,
136
+ type: 'text',
137
+ disabled: false,
138
+ checked: false,
139
+ options: [],
140
+ error: '',
141
+ };
142
+
143
+ export default InputField;
@@ -0,0 +1,15 @@
1
+ // Placeholder to initialize routes (compare foreman_ansible)
2
+
3
+ /*
4
+ import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
5
+ import { registerReducer } from 'foremanReact/common/MountingService';
6
+ import { registerRoutes } from 'foremanReact/routes/RoutingService';
7
+ import Routes from './src/Router/routes'
8
+
9
+ register client routes
10
+ registerRoutes('PluginTemplate', Routes);
11
+
12
+ register fills for extending foreman core
13
+ http://foreman.surge.sh/?path=/docs/introduction-slot-and-fill--page
14
+ addGlobalFill('<slotId>', '<fillId>', <div key='plugin-template-example' />, 300);
15
+ */
data/webpack/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import componentRegistry from 'foremanReact/components/componentRegistry';
2
+ import ProxmoxVmType from './components/ProxmoxVmType';
3
+
4
+ componentRegistry.register({
5
+ name: 'ProxmoxVmType',
6
+ type: ProxmoxVmType,
7
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_fog_proxmox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Robert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-04-22 00:00:00.000000000 Z
12
+ date: 2024-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -126,6 +126,7 @@ files:
126
126
  - app/helpers/proxmox_compute_selectors_helper.rb
127
127
  - app/helpers/proxmox_form_helper.rb
128
128
  - app/helpers/proxmox_storages_helper.rb
129
+ - app/helpers/proxmox_vm_attrs_helper.rb
129
130
  - app/helpers/proxmox_vm_cdrom_helper.rb
130
131
  - app/helpers/proxmox_vm_cloudinit_helper.rb
131
132
  - app/helpers/proxmox_vm_config_helper.rb
@@ -160,12 +161,14 @@ files:
160
161
  - app/models/foreman_fog_proxmox/vms.rb
161
162
  - app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb
162
163
  - app/overrides/compute_resources_vms/form/add_from_profile_to_compute_attributes_form.rb
164
+ - app/overrides/compute_resources_vms/form/add_react_component_to_host.rb
163
165
  - app/overrides/compute_resources_vms/form/add_vm_type_node_to_new_form.rb
164
166
  - app/overrides/compute_resources_vms/form/add_vm_type_to_networks_form.rb
165
167
  - app/overrides/compute_resources_vms/form/add_vm_type_to_nic_provider_specific_form.rb
166
168
  - app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb
167
169
  - app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb
168
170
  - app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb
171
+ - app/overrides/compute_resources_vms/form/update_react_component_to_host_form.rb
169
172
  - app/services/concerns/foreman_fog_proxmox/compute_resource_host_associator.rb
170
173
  - app/services/foreman_fog_proxmox/node_dashboard/data.rb
171
174
  - app/views/api/v2/compute_resources/proxmox.json.rabl
@@ -174,6 +177,7 @@ files:
174
177
  - app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb
175
178
  - app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb
176
179
  - app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb
180
+ - app/views/compute_resources_vms/form/proxmox/_add_react_component_to_host_form.html.erb
177
181
  - app/views/compute_resources_vms/form/proxmox/_add_vm_type_node_to_new_form.html.erb
178
182
  - app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb
179
183
  - app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb
@@ -183,6 +187,7 @@ files:
183
187
  - app/views/compute_resources_vms/form/proxmox/_general.html.erb
184
188
  - app/views/compute_resources_vms/form/proxmox/_network.html.erb
185
189
  - app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb
190
+ - app/views/compute_resources_vms/form/proxmox/_update_react_component_to_host_form.html.erb
186
191
  - app/views/compute_resources_vms/form/proxmox/container/_advanced.html.erb
187
192
  - app/views/compute_resources_vms/form/proxmox/container/_config.html.erb
188
193
  - app/views/compute_resources_vms/form/proxmox/container/_extended.html.erb
@@ -213,6 +218,7 @@ files:
213
218
  - locale/foreman_fog_proxmox.pot
214
219
  - locale/fr/foreman_fog_proxmox.po
215
220
  - locale/gemspec.rb
221
+ - package.json
216
222
  - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
217
223
  - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
218
224
  - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
@@ -239,6 +245,28 @@ files:
239
245
  - test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
240
246
  - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
241
247
  - test/unit/foreman_fog_proxmox/semver_test.rb
248
+ - webpack/components/GeneralTabContent.js
249
+ - webpack/components/ProxmoxComputeSelectors.js
250
+ - webpack/components/ProxmoxContainer/MountPoint.js
251
+ - webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js
252
+ - webpack/components/ProxmoxContainer/ProxmoxContainerNetwork.js
253
+ - webpack/components/ProxmoxContainer/ProxmoxContainerOptions.js
254
+ - webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js
255
+ - webpack/components/ProxmoxContainer/components/NetworkInterface.js
256
+ - webpack/components/ProxmoxServer/ProxmoxServerHardware.js
257
+ - webpack/components/ProxmoxServer/ProxmoxServerNetwork.js
258
+ - webpack/components/ProxmoxServer/ProxmoxServerOptions.js
259
+ - webpack/components/ProxmoxServer/ProxmoxServerStorage.js
260
+ - webpack/components/ProxmoxServer/components/CDRom.js
261
+ - webpack/components/ProxmoxServer/components/CPUFlagsModal.js
262
+ - webpack/components/ProxmoxServer/components/HardDisk.js
263
+ - webpack/components/ProxmoxServer/components/NetworkInterface.js
264
+ - webpack/components/ProxmoxStoragesUtils.js
265
+ - webpack/components/ProxmoxVmType.js
266
+ - webpack/components/ProxmoxVmUtils.js
267
+ - webpack/components/common/FormInputs.js
268
+ - webpack/global_index.js
269
+ - webpack/index.js
242
270
  homepage: https://github.com/theforeman/foreman_fog_proxmox
243
271
  licenses:
244
272
  - GPL-3.0
@@ -263,29 +291,29 @@ signing_key:
263
291
  specification_version: 4
264
292
  summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
265
293
  test_files:
266
- - test/test_plugin_helper.rb
267
- - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
268
- - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
269
- - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
270
- - test/factories/proxmox_factory.rb
271
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
272
- - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
273
- - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
274
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
275
- - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
276
294
  - test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
295
+ - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
296
+ - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
277
297
  - test/unit/foreman_fog_proxmox/proxmox_test.rb
278
- - test/unit/foreman_fog_proxmox/semver_test.rb
279
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
280
298
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
281
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
282
- - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
283
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
284
- - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
285
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
286
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
287
299
  - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
288
300
  - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
289
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
301
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
290
302
  - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
303
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
304
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
305
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
306
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
307
+ - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
308
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
309
+ - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
310
+ - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
311
+ - test/unit/foreman_fog_proxmox/semver_test.rb
312
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
313
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
314
+ - test/test_plugin_helper.rb
315
+ - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
316
+ - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
317
+ - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
318
+ - test/factories/proxmox_factory.rb
291
319
  - test/functional/compute_resources_controller_test.rb