foreman_fog_proxmox 0.13.4 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +63 -52
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +0 -2
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +0 -1
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +0 -2
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js +0 -1
- data/app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb +17 -7
- data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
- data/app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb +58 -0
- data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +6 -3
- data/app/helpers/proxmox_compute_controllers_helper.rb +2 -1
- data/app/helpers/proxmox_compute_resources_helper.rb +3 -3
- data/app/helpers/proxmox_compute_resources_vms_helper.rb +16 -7
- data/app/helpers/proxmox_form_helper.rb +10 -6
- data/app/helpers/proxmox_vm_config_helper.rb +16 -25
- data/app/helpers/proxmox_vm_interfaces_helper.rb +19 -6
- data/app/helpers/proxmox_vm_os_template_helper.rb +2 -5
- data/app/helpers/proxmox_vm_uuid_helper.rb +1 -1
- data/app/helpers/proxmox_vm_volumes_helper.rb +22 -25
- data/app/models/concerns/fog_extensions/proxmox/node.rb +2 -2
- data/app/models/concerns/fog_extensions/proxmox/server.rb +10 -6
- data/app/models/concerns/host_ext/proxmox/associator.rb +3 -2
- data/app/models/concerns/host_ext/proxmox/for_vm.rb +1 -1
- data/app/models/concerns/host_ext/proxmox/interfaces.rb +7 -3
- data/app/models/concerns/orchestration/proxmox/compute.rb +11 -4
- data/app/models/foreman_fog_proxmox/options_select.rb +1 -3
- data/app/models/foreman_fog_proxmox/proxmox.rb +12 -10
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +15 -3
- data/app/models/foreman_fog_proxmox/proxmox_connection.rb +6 -2
- data/app/models/foreman_fog_proxmox/proxmox_console.rb +3 -1
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +2 -2
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +37 -14
- data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +6 -1
- data/app/models/foreman_fog_proxmox/proxmox_pools.rb +4 -4
- data/app/models/foreman_fog_proxmox/proxmox_version.rb +7 -3
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +9 -7
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +37 -24
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +4 -5
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +23 -12
- data/app/models/foreman_fog_proxmox/vms.rb +2 -2
- data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb +4 -2
- data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +0 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_config.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +3 -3
- data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb +1 -1
- data/config/routes.rb +8 -4
- data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +1 -2
- data/lib/foreman_fog_proxmox/engine.rb +5 -3
- data/lib/foreman_fog_proxmox/semver.rb +1 -4
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/locale/en/foreman_fog_proxmox.po +140 -47
- data/locale/foreman_fog_proxmox.pot +300 -137
- data/locale/fr/foreman_fog_proxmox.po +145 -52
- data/test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb +6 -7
- data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +6 -7
- data/test/functional/compute_resources_controller_test.rb +4 -2
- data/test/test_plugin_helper.rb +12 -7
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +38 -47
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +49 -34
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +29 -65
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb +3 -3
- data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +22 -13
- data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +48 -37
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +45 -35
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +0 -4
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +34 -22
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb +20 -14
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb +76 -54
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +26 -15
- data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +1 -1
- data/test/unit/foreman_fog_proxmox/semver_test.rb +2 -1
- metadata +36 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70a0629dba4c5afe29ddca15cbe49df9325edb80ca73d076c41c3fc1d283ecff
|
4
|
+
data.tar.gz: f680eed4c519701ecdc5bc38117ca62eb846551ab972aa8e5f38869b17fe414e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c8d56b7e0a4e02ac2195fdd248aa12f5934b8a9746763d1aff59d0df1316f09abb3dbfe212f99e7a39307132065550871bb84a7fcab04787e3e8ca9bd70e50d
|
7
|
+
data.tar.gz: 883ee296ceea79f15e220c8fe9cad273aed8201862be59b41b79761ae01d8cc837adcbe3dae54e9e24d1f30f34dee3d85e7eb8c83ccaa94d0522f27bc28925b3
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
[](https://codeclimate.com/github/theforeman/foreman_fog_proxmox/maintainability)
|
5
|
-
[](https://codeclimate.com/github/theforeman/foreman_fog_proxmox/test_coverage)
|
6
6
|
[](https://badge.fury.io/rb/foreman_fog_proxmox)
|
7
7
|
|
8
8
|
# ForemanFogProxmox
|
@@ -38,9 +38,27 @@ You can support the plugin development via the following methods:
|
|
38
38
|
|
39
39
|
## Installation
|
40
40
|
|
41
|
-
###
|
41
|
+
### From OS packages (required)
|
42
42
|
|
43
|
-
|
43
|
+
Please see the Foreman manual for complete instructions:
|
44
|
+
|
45
|
+
* [Foreman: How to Install a Plugin from package](https://theforeman.org/plugins/#2.Installation)
|
46
|
+
|
47
|
+
[Install from package](https://theforeman.org/plugins/#2.2Packageinstallation) is the easiest way to install the plugin. Choose the latest release plugins repository. If you don't find it in the same foreman release repository, get it from the `nightly` repository.
|
48
|
+
|
49
|
+
Then you can install it with the package manager, in Debian/Ubuntu:
|
50
|
+
|
51
|
+
```shell
|
52
|
+
sudo apt-get install ruby-foreman-fog-proxmox
|
53
|
+
```
|
54
|
+
|
55
|
+
and in Fedora/Redhat Linux:
|
56
|
+
|
57
|
+
```shell
|
58
|
+
sudo dnf install rubygem-foreman_fog_proxmox
|
59
|
+
```
|
60
|
+
|
61
|
+
Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.theforeman.org/projects/foreman/wiki/SELinux) to allow foreman and all its plugins to work.
|
44
62
|
|
45
63
|
### From gem
|
46
64
|
|
@@ -69,6 +87,8 @@ sudo -u foreman /usr/bin/foreman-ruby /usr/bin/bundle install
|
|
69
87
|
|
70
88
|
* Precompile plugin assets:
|
71
89
|
|
90
|
+
You need [nodejs](https://nodejs.org/en/download/package-manager/) installed in order to use foreman-assets package.
|
91
|
+
|
72
92
|
```shell
|
73
93
|
/usr/bin/foreman-ruby /usr/bin/bundle exec bin/rake plugin:assets:precompile[foreman_fog_proxmox]
|
74
94
|
```
|
@@ -99,28 +119,6 @@ Then you can check plugin installation after login into your new foreman server
|
|
99
119
|

|
100
120
|

|
101
121
|
|
102
|
-
### From OS packages
|
103
|
-
|
104
|
-
Please see the Foreman manual for complete instructions:
|
105
|
-
|
106
|
-
* [Foreman: How to Install a Plugin from package](https://theforeman.org/plugins/#2.Installation)
|
107
|
-
|
108
|
-
[Install from package](https://theforeman.org/plugins/#2.2Packageinstallation) is the easiest way to install the plugin. Choose the latest release plugins repository. If you don't find it in the same foreman release repository, get it from the `nightly` repository.
|
109
|
-
|
110
|
-
Then you can install it with the package manager, in Debian/Ubuntu:
|
111
|
-
|
112
|
-
```shell
|
113
|
-
sudo apt-get install ruby-foreman-fog-proxmox
|
114
|
-
```
|
115
|
-
|
116
|
-
and in Fedora/Redhat Linux:
|
117
|
-
|
118
|
-
```shell
|
119
|
-
sudo dnf install rubygem-foreman_fog_proxmox
|
120
|
-
```
|
121
|
-
|
122
|
-
Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.theforeman.org/projects/foreman/wiki/SELinux) to allow foreman and all its plugins to work.
|
123
|
-
|
124
122
|
## Usage
|
125
123
|
|
126
124
|
* [Compute resource](.github/compute_resource.md)
|
@@ -130,15 +128,17 @@ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.thef
|
|
130
128
|
|
131
129
|
### Dev prerequisites
|
132
130
|
|
133
|
-
|
134
|
-
|
135
|
-
* You
|
131
|
+
> See [Foreman dev setup](https://github.com/theforeman/foreman/blob/develop/developer_docs/foreman_dev_setup.asciidoc)
|
132
|
+
|
133
|
+
* You need a Proxmox VE 6.2+ server running.
|
134
|
+
* You need ruby 2.7. You can install it with [asdf-vm](https://asdf-vm.com).
|
135
|
+
* You also need nodejs 14 in your dev machine to run webpack-dev-server. You can install it with [asdf-vm](https://asdf-vm.com).
|
136
136
|
|
137
137
|
### Platform
|
138
138
|
|
139
139
|
* Fork this github repo.
|
140
140
|
* Clone it on your local machine
|
141
|
-
* Install foreman
|
141
|
+
* Install foreman v2.5+ on your machine:
|
142
142
|
|
143
143
|
```shell
|
144
144
|
git clone https://github.com/theforeman/foreman -b develop
|
@@ -160,9 +160,9 @@ gem 'simplecov' # test
|
|
160
160
|
|
161
161
|
```shell
|
162
162
|
gem install bundler
|
163
|
-
# prerequisites
|
164
|
-
|
165
|
-
bundle config
|
163
|
+
# prerequisites libraries on Ubuntu OS:
|
164
|
+
# sudo apt install postgresql-client-13 libpq-dev libsystemd-dev
|
165
|
+
bundle config set without 'libvirt ovirt'
|
166
166
|
bundle install
|
167
167
|
```
|
168
168
|
|
@@ -180,6 +180,12 @@ add these lines to config/settings.yml:
|
|
180
180
|
|
181
181
|
```yaml
|
182
182
|
:webpack_dev_server: true
|
183
|
+
:destroy_vm_on_host_delete: true # optional, could be set on UI
|
184
|
+
:logging:
|
185
|
+
:level: debug
|
186
|
+
:loggers:
|
187
|
+
:sql:
|
188
|
+
:enabled: false
|
183
189
|
```
|
184
190
|
|
185
191
|
* SQLite is no more default rails dev or test database, instead add:
|
@@ -191,45 +197,42 @@ DATABASE_URL=nulldb://nohost
|
|
191
197
|
* (Optional) test and dev with postgresql database:
|
192
198
|
|
193
199
|
```shell
|
194
|
-
cp config/model.mappings.example config/model.mappings
|
195
200
|
cp config/database.yml.example config/database.yml
|
196
201
|
```
|
197
202
|
|
198
203
|
add these lines to each environment in config/database.yml:
|
199
204
|
|
200
205
|
```yaml
|
206
|
+
host: localhost
|
201
207
|
username: foreman
|
202
208
|
password: foreman
|
203
209
|
```
|
204
210
|
|
205
211
|
```shell
|
206
212
|
cp config/ignored_environments.yml.sample config/ignored_environments.yml
|
207
|
-
docker run --name foreman-db -v foreman_data:/var/lib/postgresql/data -e POSTGRES_DB=foreman -e POSTGRES_USER=foreman -e POSTGRES_PASSWORD=foreman -p 5432:5432 -d postgres
|
213
|
+
docker run --name foreman-db -v foreman_data:/var/lib/postgresql/data -e POSTGRES_DB=foreman -e POSTGRES_USER=foreman -e POSTGRES_PASSWORD=foreman -p 5432:5432 -d postgres:13
|
208
214
|
bundle exec bin/rake db:migrate
|
209
|
-
|
210
|
-
bundle exec bin/rake db:seed assets:precompile locale:pack webpack:compile
|
215
|
+
RAILS_ENV=development bundle exec bin/rake db:seed assets:precompile locale:pack webpack:compile
|
211
216
|
```
|
212
217
|
|
213
|
-
* You can reset admin password if needed:
|
218
|
+
* You can reset and change your admin password if needed:
|
214
219
|
|
215
220
|
```shell
|
216
|
-
bundle exec bin/rake permissions:reset
|
221
|
+
RAILS_ENV=development bundle exec bin/rake permissions:reset password=changeme
|
217
222
|
```
|
218
223
|
|
219
224
|
* You should write tests and you can execute those specific to this plugin:
|
220
225
|
|
221
|
-
first, create database `foreman-test
|
226
|
+
first, create database `foreman-test`:
|
222
227
|
|
223
228
|
```shell
|
224
|
-
|
225
|
-
foreman=# create database "foreman-test";
|
229
|
+
RAILS_ENV=test bundle exec rake db:create
|
226
230
|
```
|
227
231
|
|
228
232
|
then add test schema and seeds:
|
229
233
|
|
230
234
|
```shell
|
231
235
|
RAILS_ENV=test bundle exec bin/rake db:migrate
|
232
|
-
# reboot if error: "ActiveRecord::RecordNotFound: Couldn't find Setting with [WHERE "settings"."name" = $1]"
|
233
236
|
RAILS_ENV=test bundle exec bin/rake db:seed
|
234
237
|
```
|
235
238
|
|
@@ -247,10 +250,22 @@ export DISABLE_SPRING=true
|
|
247
250
|
bundle exec bin/rake test TEST=../foreman_fog_proxmox/test/functional/compute_resources_controller_test.rb DATABASE_URL=nulldb://nohost
|
248
251
|
```
|
249
252
|
|
250
|
-
*
|
253
|
+
* In foreman_fog_proxmox source directory, check code syntax with rubocop and foreman rules:
|
254
|
+
|
255
|
+
```shell
|
256
|
+
bundle exec rubocop
|
257
|
+
```
|
258
|
+
|
259
|
+
safe autocorrect:
|
260
|
+
|
261
|
+
```shell
|
262
|
+
bundle exec rubocop -a
|
263
|
+
```
|
264
|
+
|
265
|
+
Temporary ignore offenses:
|
251
266
|
|
252
267
|
```shell
|
253
|
-
bundle exec
|
268
|
+
bundle exec rubocop --auto-gen-config
|
254
269
|
```
|
255
270
|
|
256
271
|
* See deface overrides result:
|
@@ -267,14 +282,16 @@ bundle exec bin/rake plugin:assets:precompile[foreman_fog_proxmox]
|
|
267
282
|
|
268
283
|
* In foreman directory, after you modify foreman_fog_proxmox translations (language, texts in new files, etc) you have to compile it:
|
269
284
|
|
285
|
+
Prerequisites: [Transifex CLI](https://github.com/transifex/cli)
|
286
|
+
|
270
287
|
```shell
|
271
|
-
bundle exec bin/rake plugin:gettext[foreman_fog_proxmox]
|
288
|
+
bundle exec bin/rake plugin:gettext\[foreman_fog_proxmox\]
|
272
289
|
```
|
273
290
|
|
274
291
|
* In foreman directory, run in a new terminal the webpack-dev-server:
|
275
292
|
|
276
293
|
```shell
|
277
|
-
./node_modules/.bin/webpack-dev-server --config config/webpack.config.js
|
294
|
+
./node_modules/.bin/webpack-dev-server-without-h2 --config config/webpack.config.js
|
278
295
|
```
|
279
296
|
|
280
297
|
* Or without webpack-dev-server, add this line in config/settings.yml:
|
@@ -301,12 +318,6 @@ bundle exec bin/rails server
|
|
301
318
|
bundle exec foreman start
|
302
319
|
```
|
303
320
|
|
304
|
-
If you want to delete vm on host destroy, add this line in config/settings.yml:
|
305
|
-
|
306
|
-
```yml
|
307
|
-
:destroy_vm_on_host_delete: false
|
308
|
-
```
|
309
|
-
|
310
321
|
See details in [foreman plugin development](https://projects.theforeman.org/projects/foreman/wiki/How_to_Create_a_Plugin)
|
311
322
|
|
312
323
|
## Contributing
|
@@ -15,8 +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
|
-
$(document).on('ContentLoad', tfm.numFields.initAll);
|
19
|
-
|
20
18
|
$(document).ready(function () {
|
21
19
|
sslVerifyPeerSelected();
|
22
20
|
authMethodSelected();
|
@@ -15,7 +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
|
-
$(document).on('ContentLoad', tfm.numFields.initAll);
|
19
18
|
$(document).ready(vmTypeSelected);
|
20
19
|
|
21
20
|
function vmTypeSelected() {
|
@@ -46,7 +46,6 @@ function controllerSelected(item) {
|
|
46
46
|
var device = $(device_selector).limitedSpinner('value');
|
47
47
|
var id = controller + device;
|
48
48
|
$(id_selector).val(id);
|
49
|
-
tfm.numFields.initAll();
|
50
49
|
}
|
51
50
|
|
52
51
|
function deviceSelected(item) {
|
@@ -58,7 +57,6 @@ function deviceSelected(item) {
|
|
58
57
|
var controller = $(controller_selector).val();
|
59
58
|
var id = controller + device;
|
60
59
|
$(id_selector).val(id);
|
61
|
-
tfm.numFields.initAll();
|
62
60
|
}
|
63
61
|
|
64
62
|
function computeControllerMaxDevice(controller) {
|
@@ -21,5 +21,4 @@ function cloudinitControllerSelected(item) {
|
|
21
21
|
var max = computeControllerMaxDevice(controller);
|
22
22
|
var device_selector = 'host_compute_attributes_volumes_attributes_' + index + 'device';
|
23
23
|
$(device_selector).attr('data-soft-max', max);
|
24
|
-
tfm.numFields.initAll();
|
25
24
|
}
|
@@ -26,15 +26,20 @@ module ForemanFogProxmox
|
|
26
26
|
module Overrides
|
27
27
|
def associate
|
28
28
|
if Host.for_vm_uuid(@compute_resource, @vm).any?
|
29
|
-
process_error(:error_msg => _("VM already associated with a host"),
|
29
|
+
process_error(:error_msg => _("VM already associated with a host"),
|
30
|
+
:redirect => compute_resource_vm_path(:compute_resource_id => params[:compute_resource_id],
|
31
|
+
:id => proxmox_vm_id(@compute_resource, @vm)))
|
30
32
|
return
|
31
33
|
end
|
32
34
|
host = @compute_resource.associated_host(@vm) if @compute_resource.respond_to?(:associated_host)
|
33
35
|
if host.present?
|
34
36
|
host.associate!(@compute_resource, @vm)
|
35
|
-
process_success(:success_msg => _("VM associated to host %s") % host.name,
|
37
|
+
process_success(:success_msg => _("VM associated to host %s") % host.name,
|
38
|
+
:success_redirect => host_path(host))
|
36
39
|
else
|
37
|
-
process_error(:error_msg => _("No host found to associate this VM with"),
|
40
|
+
process_error(:error_msg => _("No host found to associate this VM with"),
|
41
|
+
:redirect => compute_resource_vm_path(:compute_resource_id => params[:compute_resource_id],
|
42
|
+
:id => proxmox_vm_id(@compute_resource, @vm)))
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
@@ -51,14 +56,15 @@ module ForemanFogProxmox
|
|
51
56
|
'hosts/console/log'
|
52
57
|
end
|
53
58
|
rescue StandardError => e
|
54
|
-
process_error :redirect => compute_resource_vm_path(@compute_resource, proxmox_vm_id(@compute_resource, @vm)),
|
59
|
+
process_error :redirect => compute_resource_vm_path(@compute_resource, proxmox_vm_id(@compute_resource, @vm)),
|
60
|
+
:error_msg => (_("Failed to set console: %s") % e), :object => @vm
|
55
61
|
end
|
56
62
|
|
57
63
|
private
|
58
64
|
|
59
65
|
def proxmox_vm_id(compute_resource, vm)
|
60
66
|
id = vm.identity
|
61
|
-
id = vm.unique_cluster_identity(compute_resource) if compute_resource.
|
67
|
+
id = vm.unique_cluster_identity(compute_resource) if compute_resource.instance_of?(ForemanFogProxmox::Proxmox)
|
62
68
|
id
|
63
69
|
end
|
64
70
|
|
@@ -69,11 +75,15 @@ module ForemanFogProxmox
|
|
69
75
|
else
|
70
76
|
error format(_("failed to %<action>s %<vm>s"), { :action => _(action), :vm => @vm })
|
71
77
|
end
|
72
|
-
redirect_back(:fallback_location => compute_resource_vm_path(
|
78
|
+
redirect_back(:fallback_location => compute_resource_vm_path(
|
79
|
+
:compute_resource_id => params[:compute_resource_id], :id => proxmox_vm_id(@compute_resource, @vm)
|
80
|
+
))
|
73
81
|
# This should only rescue Fog::Errors, but Fog returns all kinds of errors...
|
74
82
|
rescue StandardError => e
|
75
83
|
error format(_("Error - %<message>s"), { :message => _(e.message) })
|
76
|
-
redirect_back(:fallback_location => compute_resource_vm_path(
|
84
|
+
redirect_back(:fallback_location => compute_resource_vm_path(
|
85
|
+
:compute_resource_id => params[:compute_resource_id], :id => proxmox_vm_id(@compute_resource, @vm)
|
86
|
+
))
|
77
87
|
end
|
78
88
|
end
|
79
89
|
end
|
@@ -27,7 +27,7 @@ module ForemanFogProxmox
|
|
27
27
|
def compute_resource_params_filter
|
28
28
|
super.tap do |filter|
|
29
29
|
filter.permit :ssl_verify_peer,
|
30
|
-
|
30
|
+
:ssl_certs, :disable_proxy, :auth_method, :token_id, :token
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 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 HostsController
|
22
|
+
extend ActiveSupport::Concern
|
23
|
+
included do
|
24
|
+
prepend Overrides
|
25
|
+
end
|
26
|
+
module Overrides
|
27
|
+
include ForemanFogProxmox::ProxmoxVmNew
|
28
|
+
# Clone the host
|
29
|
+
def clone
|
30
|
+
super
|
31
|
+
return true unless @host.compute_resource.instance_of?(ForemanFogProxmox::Proxmox)
|
32
|
+
|
33
|
+
@host.compute_attributes[:vmid] = next_vmid
|
34
|
+
@host.compute_attributes[:interfaces_attributes].each do |index, interface_attributes|
|
35
|
+
@host.compute_attributes[:interfaces_attributes][index] =
|
36
|
+
interface_attributes.merge(macaddr: nil).merge(hwaddr: nil).merge(ip: nil).merge(ip6: nil)
|
37
|
+
end
|
38
|
+
@host.compute_attributes[:volumes_attributes].each do |index, volume_attributes|
|
39
|
+
@host.compute_attributes[:volumes_attributes][index] = volume_attributes.merge(volid: nil)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def bridges
|
46
|
+
@host.compute_resource.bridges
|
47
|
+
end
|
48
|
+
|
49
|
+
def nodes
|
50
|
+
@host.compute_resource.nodes
|
51
|
+
end
|
52
|
+
|
53
|
+
def storages
|
54
|
+
@host.compute_resource.storages
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -21,7 +21,8 @@ module ForemanFogProxmox
|
|
21
21
|
class ComputeResourcesController < ::ApplicationController
|
22
22
|
# GET foreman_fog_proxmox/isos/:compute_resource_id/:node_id/:storage
|
23
23
|
def isos_by_id_and_node_and_storage
|
24
|
-
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
|
24
|
+
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
|
25
|
+
params[:storage], 'iso')
|
25
26
|
respond_to do |format|
|
26
27
|
format.json { render :json => volumes }
|
27
28
|
end
|
@@ -29,7 +30,8 @@ module ForemanFogProxmox
|
|
29
30
|
|
30
31
|
# GET foreman_fog_proxmox/ostemplates/:compute_resource_id/:node_id/:storage
|
31
32
|
def ostemplates_by_id_and_node_and_storage
|
32
|
-
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
|
33
|
+
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
|
34
|
+
params[:storage], 'vztmpl')
|
33
35
|
respond_to do |format|
|
34
36
|
format.json { render :json => volumes }
|
35
37
|
end
|
@@ -37,7 +39,8 @@ module ForemanFogProxmox
|
|
37
39
|
|
38
40
|
# GET foreman_fog_proxmox/isos/:compute_resource_id/:node_id
|
39
41
|
def isos_by_id_and_node
|
40
|
-
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
|
42
|
+
volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
|
43
|
+
params[:storage], 'iso')
|
41
44
|
respond_to do |format|
|
42
45
|
format.json { render :json => volumes }
|
43
46
|
end
|
@@ -19,7 +19,8 @@
|
|
19
19
|
|
20
20
|
module ProxmoxComputeControllersHelper
|
21
21
|
def proxmox_controllers_map
|
22
|
-
proxmox_controllers_cloudinit_map << ForemanFogProxmox::OptionsSelect.new(name: 'VirtIO Block', id: 'virtio',
|
22
|
+
proxmox_controllers_cloudinit_map << ForemanFogProxmox::OptionsSelect.new(name: 'VirtIO Block', id: 'virtio',
|
23
|
+
range: 15)
|
23
24
|
end
|
24
25
|
|
25
26
|
def proxmox_controllers_cloudinit_map
|
@@ -21,9 +21,9 @@ module ProxmoxComputeResourcesHelper
|
|
21
21
|
def user_token_expiration_date(compute_resource)
|
22
22
|
expire = compute_resource.current_user_token_expire
|
23
23
|
rescue ::Foreman::Exception => e
|
24
|
-
|
24
|
+
'Has already expired. Please edit the compute resource to set a new valid one.' if e.message == 'User token expired'
|
25
25
|
rescue StandardError => e
|
26
|
-
logger.warn(
|
26
|
+
logger.warn("failed to get identity client version: #{e}")
|
27
27
|
raise e
|
28
28
|
else
|
29
29
|
return 'Never' if expire == 0
|
@@ -36,7 +36,7 @@ module ProxmoxComputeResourcesHelper
|
|
36
36
|
rescue ::Foreman::Exception => e
|
37
37
|
return [] if e.message == 'User token expired'
|
38
38
|
rescue StandardError => e
|
39
|
-
logger.warn(
|
39
|
+
logger.warn("failed to get cluster nodes: #{e}")
|
40
40
|
raise e
|
41
41
|
else
|
42
42
|
nodes
|
@@ -20,7 +20,7 @@
|
|
20
20
|
module ProxmoxComputeResourcesVmsHelper
|
21
21
|
def proxmox_vm_id(compute_resource, vm)
|
22
22
|
id = vm.identity
|
23
|
-
id = vm.unique_cluster_identity(compute_resource) if compute_resource.
|
23
|
+
id = vm.unique_cluster_identity(compute_resource) if compute_resource.instance_of?(ForemanFogProxmox::Proxmox)
|
24
24
|
id
|
25
25
|
end
|
26
26
|
|
@@ -32,7 +32,9 @@ module ProxmoxComputeResourcesVmsHelper
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def vm_power_action(vm, authorizer = nil)
|
35
|
-
opts = hash_for_power_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => proxmox_vm_id(@compute_resource, vm)).merge(
|
35
|
+
opts = hash_for_power_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => proxmox_vm_id(@compute_resource, vm)).merge(
|
36
|
+
:auth_object => @compute_resource, :permission => 'power_compute_resources_vms', :authorizer => authorizer
|
37
|
+
)
|
36
38
|
html = power_action_html(vm)
|
37
39
|
|
38
40
|
display_link_if_authorized "Power #{action_string(vm)}", opts, html.merge(:method => :put)
|
@@ -46,7 +48,8 @@ module ProxmoxComputeResourcesVmsHelper
|
|
46
48
|
:id => proxmox_vm_id(@compute_resource, vm)
|
47
49
|
).merge(
|
48
50
|
:auth_object => @compute_resource,
|
49
|
-
:permission => 'edit_compute_resources'
|
51
|
+
:permission => 'edit_compute_resources'
|
52
|
+
),
|
50
53
|
:title => _('Associate VM to a Foreman host'),
|
51
54
|
:method => :put,
|
52
55
|
:class => 'btn btn-default'
|
@@ -62,7 +65,8 @@ module ProxmoxComputeResourcesVmsHelper
|
|
62
65
|
hash_for_import_compute_resource_vm_path(
|
63
66
|
:compute_resource_id => @compute_resource,
|
64
67
|
:id => proxmox_vm_id(@compute_resource, vm),
|
65
|
-
:type => 'managed'
|
68
|
+
:type => 'managed'
|
69
|
+
),
|
66
70
|
html_options
|
67
71
|
)
|
68
72
|
import_unmanaged_link = display_link_if_authorized(
|
@@ -70,7 +74,8 @@ module ProxmoxComputeResourcesVmsHelper
|
|
70
74
|
hash_for_import_compute_resource_vm_path(
|
71
75
|
:compute_resource_id => @compute_resource,
|
72
76
|
:id => proxmox_vm_id(@compute_resource, vm),
|
73
|
-
:type => 'unmanaged'
|
77
|
+
:type => 'unmanaged'
|
78
|
+
),
|
74
79
|
html_options
|
75
80
|
)
|
76
81
|
|
@@ -88,12 +93,16 @@ module ProxmoxComputeResourcesVmsHelper
|
|
88
93
|
),
|
89
94
|
{
|
90
95
|
:id => 'console-button',
|
91
|
-
:class => 'btn btn-info'
|
96
|
+
:class => 'btn btn-info',
|
92
97
|
}
|
93
98
|
)
|
94
99
|
end
|
95
100
|
|
96
101
|
def vm_delete_action(vm, authorizer = nil)
|
97
|
-
display_delete_if_authorized(
|
102
|
+
display_delete_if_authorized(
|
103
|
+
hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => proxmox_vm_id(@compute_resource, vm)).merge(
|
104
|
+
:auth_object => @compute_resource, :authorizer => authorizer
|
105
|
+
), :class => 'btn btn-danger'
|
106
|
+
)
|
98
107
|
end
|
99
108
|
end
|
@@ -29,9 +29,11 @@ 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
|
-
tag(:span, '', class: 'glyphicon glyphicon-warning-sign input-addon', title: 'Caps lock ON',
|
32
|
+
tag(:span, '', class: 'glyphicon glyphicon-warning-sign input-addon', title: 'Caps lock ON',
|
33
|
+
style: 'display:none')
|
33
34
|
if unset_button
|
34
|
-
button = link_to_function(icon_text('edit', '', :kind => 'pficon'), 'toggle_input_group(this)',
|
35
|
+
button = link_to_function(icon_text('edit', '', :kind => 'pficon'), 'toggle_input_group(this)',
|
36
|
+
:id => 'disable-pass-btn', :class => 'btn btn-default', :title => _('Change the password'))
|
35
37
|
input_group(pass, input_group_btn(button))
|
36
38
|
else
|
37
39
|
pass
|
@@ -53,10 +55,12 @@ module ProxmoxFormHelper
|
|
53
55
|
options[:form_builder_local] ||= :f
|
54
56
|
options[:form_builder_attrs] ||= {}
|
55
57
|
|
56
|
-
content_tag(:div, :class => "#{options[:type]}_#{association}_fields_template form_template",
|
57
|
-
|
58
|
+
content_tag(:div, :class => "#{options[:type]}_#{association}_fields_template form_template",
|
59
|
+
:style => 'display: none;') do
|
60
|
+
form_builder.fields_for(association, options[:object],
|
61
|
+
:child_index => "new_#{options[:type]}_#{association}") do |f|
|
58
62
|
render(:partial => options[:partial], :layout => options[:layout],
|
59
|
-
|
63
|
+
:locals => { options[:form_builder_local] => f }.merge(options[:form_builder_attrs]))
|
60
64
|
end
|
61
65
|
end
|
62
66
|
end
|
@@ -66,7 +70,7 @@ module ProxmoxFormHelper
|
|
66
70
|
opts[:"data-association"] = (type + '_' + association.to_s).to_sym
|
67
71
|
hide = ''
|
68
72
|
hide += '$("[data-association=' + type + '_volumes]").hide();' unless ['hard_disk', 'mp'].include?(type)
|
69
|
-
link_to_function(name.to_s, 'add_child_node(this);
|
73
|
+
link_to_function(name.to_s, 'add_child_node(this);' + hide, opts)
|
70
74
|
end
|
71
75
|
|
72
76
|
def remove_child_link_typed(name, f, type, opts = {})
|