foreman_ovirt 2.0.2 → 2.0.4
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/Rakefile +2 -17
- data/app/assets/javascripts/foreman_ovirt/ovirt.js +37 -8
- data/app/controllers/concerns/foreman_ovirt/api_compute_resources_controller_extension.rb +42 -0
- data/app/controllers/concerns/foreman_ovirt/compute_resources_vms_controller.rb +3 -1
- data/app/controllers/concerns/foreman_ovirt/parameters_extension.rb +5 -5
- data/app/controllers/foreman_ovirt/concerns/compute_resources_controller_extensions.rb +12 -3
- data/app/helpers/ovirt_compute_resource_helper.rb +18 -4
- data/app/models/concerns/fog_extensions/ovirt/server.rb +13 -4
- data/app/models/concerns/fog_extensions/ovirt/template.rb +3 -1
- data/app/models/concerns/fog_extensions/ovirt/volume.rb +3 -1
- data/app/models/foreman_ovirt/ovirt.rb +167 -142
- data/app/views/api/v2/compute_resources/ovirt.json.rabl +2 -0
- data/config/routes.rb +8 -5
- data/db/migrate/20250810212811_update_legacy_ovirt_compute_resource_type.rb +5 -3
- data/lib/foreman_ovirt/engine.rb +8 -5
- data/lib/foreman_ovirt/version.rb +3 -1
- data/lib/foreman_ovirt.rb +2 -0
- data/lib/tasks/foreman_ovirt_tasks.rake +37 -22
- data/locale/gemspec.rb +3 -1
- data/package.json +1 -0
- data/test/controllers/api/v2/compute_resources_controller_test.rb +186 -0
- data/test/controllers/hosts_controller_test.rb +46 -0
- data/test/factories/foreman_ovirt_factories.rb +27 -2
- data/test/fixtures/ovirt_operating_systems.xml +243 -0
- data/test/graphql/types/provider_enum_test.rb +12 -0
- data/test/integration/compute_profile_js_test.rb +49 -0
- data/test/models/compute_resources/compute_resource_test_helpers.rb +143 -0
- data/test/models/compute_resources/ovirt_test.rb +687 -0
- data/test/models/ovirt_volume_test.rb +104 -0
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/compute_resource_host_importer_test.rb +48 -0
- data/test/unit/ovirt_connection_test.rb +123 -0
- data/webpack/components/__tests__/ovirt.test.js +17 -0
- data/webpack/components/extensions/HostDetails/DetailsTabCards/OvirtCard.js +40 -38
- data/webpack/global_index.js +0 -2
- data/webpack/global_test_setup.js +3 -3
- data/webpack/index.js +0 -1
- metadata +26 -8
- data/test/unit/foreman_ovirt_test.rb +0 -11
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test_plugin_helper'
|
|
4
|
+
|
|
5
|
+
module ForemanOvirt
|
|
6
|
+
class OvirtVolumeTest < ActiveSupport::TestCase
|
|
7
|
+
setup do
|
|
8
|
+
User.current = users :admin
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test '#new_volume should respect preallocate flag' do
|
|
12
|
+
ovirt = ForemanOvirt::Ovirt.new
|
|
13
|
+
volume = ovirt.new_volume(preallocate: '1')
|
|
14
|
+
assert_equal 'false',
|
|
15
|
+
volume.sparse
|
|
16
|
+
assert_equal 'raw',
|
|
17
|
+
volume.format
|
|
18
|
+
|
|
19
|
+
volume = ovirt.new_volume(preallocate: '0')
|
|
20
|
+
assert_equal 'true',
|
|
21
|
+
volume.sparse
|
|
22
|
+
|
|
23
|
+
volume = ovirt.new_volume
|
|
24
|
+
assert_equal 'true',
|
|
25
|
+
volume.sparse
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test 'accepts multiple certificates' do
|
|
29
|
+
ovirt = ForemanOvirt::Ovirt.new
|
|
30
|
+
|
|
31
|
+
cert1 = "-----BEGIN CERTIFICATE-----\r\n" \
|
|
32
|
+
"MIIFdDCCA1ygAwIBAgIJAM5Uqykb3EAtMA0GCSqGSIb3DQEBCwUAME8xCzAJBgNV\r\n" \
|
|
33
|
+
"BAYTAklMMREwDwYDVQQIDAhUZWwgQXZpdjEUMBIGA1UECgwLVGhlIEZvcmVtYW4x\r\n" \
|
|
34
|
+
"FzAVBgNVBAMMDnRoZWZvcmVtYW4ub3JnMB4X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
89
|
+
"z96knnC6SH0fIgQyXk9KVfHBTqPtHAxnBAOXvPRWlDObRNK8SobyEnAQTE8COGT/\r\n" \
|
|
90
|
+
"+9AuMVbmyEyTMRvY7znv1C7EhjEEOOlpr24on12RpqTJSbTFOppYeABu0rpKM9i7\r\n" \
|
|
91
|
+
"anZnga8BSVy4YbUsMpGdHZ5xhJq8ip9AFjcFvAN0qJFMozlGx6MkgHlmhcLGMPks\r\n" \
|
|
92
|
+
"wKFSycux0qh49d/9TQ0KOiooK/sjS2dbz5bj6Z//6MPmSvRlwPhDhRDaT7D8u7cU\r\n" \
|
|
93
|
+
"svKQIHrQJve7KJxXUuPTh3zawRXdDGmdm7D3CbDOqpAIAnR+/rKXnPzQYBMCvCDG\r\n" \
|
|
94
|
+
"2lSBFSVrAlo=\r\n" \
|
|
95
|
+
'-----END CERTIFICATE-----'
|
|
96
|
+
|
|
97
|
+
store = ovirt.send(
|
|
98
|
+
:ca_cert_store, "#{cert1}\r\n#{cert2}"
|
|
99
|
+
)
|
|
100
|
+
assert store.verify(OpenSSL::X509::Certificate.new(cert1))
|
|
101
|
+
assert store.verify(OpenSSL::X509::Certificate.new(cert2))
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
data/test/test_plugin_helper.rb
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test_plugin_helper'
|
|
4
|
+
|
|
5
|
+
module ForemanOvirt
|
|
6
|
+
class ComputeResourceHostImporterTest < ActiveSupport::TestCase
|
|
7
|
+
setup do
|
|
8
|
+
Fog.mock!
|
|
9
|
+
User.current = users(:admin)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
teardown do
|
|
13
|
+
Fog.unmock!
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:importer) do
|
|
17
|
+
ComputeResourceHostImporter.new(
|
|
18
|
+
compute_resource: compute_resource,
|
|
19
|
+
vm: vm
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:host) { importer.host }
|
|
24
|
+
let(:vm) { compute_resource.find_vm_by_uuid(uuid) }
|
|
25
|
+
|
|
26
|
+
context 'on ovirt' do
|
|
27
|
+
let(:compute_resource) { FactoryBot.build(:ovirt_cr) }
|
|
28
|
+
let(:uuid) { '52b9406e-cf66-4867-8655-719a094e324c' }
|
|
29
|
+
|
|
30
|
+
test 'imports the VM with all parameters' do
|
|
31
|
+
assert_equal 'vm01', host.name
|
|
32
|
+
assert_equal uuid, host.uuid
|
|
33
|
+
assert_nil host.domain
|
|
34
|
+
assert_equal '00:1a:4a:23:1b:8f', host.mac
|
|
35
|
+
assert_equal(
|
|
36
|
+
{
|
|
37
|
+
'name' => 'nic1',
|
|
38
|
+
'network' => '00000000-0000-0000-0000-000000000009',
|
|
39
|
+
'interface' => 'virtio',
|
|
40
|
+
'vnic_profile' => '871f3a06-ef53-4ab1-922f-5aa2bea2e94e',
|
|
41
|
+
},
|
|
42
|
+
host.primary_interface.compute_attributes
|
|
43
|
+
)
|
|
44
|
+
assert_equal compute_resource, host.compute_resource
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test_plugin_helper'
|
|
4
|
+
|
|
5
|
+
module ForemanOvirt
|
|
6
|
+
class OvirtConnectionTest < ActiveSupport::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
User.current = users(:admin)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def new_ovirt_cr(proto = 'http')
|
|
12
|
+
ComputeResource.new_provider(
|
|
13
|
+
provider: 'Ovirt',
|
|
14
|
+
name: :myovirt,
|
|
15
|
+
user: 'user',
|
|
16
|
+
password: 'password',
|
|
17
|
+
public_key: 'ovirtcacert',
|
|
18
|
+
url: "#{proto}://ovirt.example.com/"
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
test 'create a new oVirt compute resource' do
|
|
23
|
+
record = new_ovirt_cr
|
|
24
|
+
assert record.valid?
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test 'fingerprint error is ignored on update of operating systems' do
|
|
28
|
+
record = new_ovirt_cr
|
|
29
|
+
record.stubs(:client).raises(Foreman::FingerprintException.new('fingerprint error'))
|
|
30
|
+
original_oses = record.attrs[:available_operating_systems] =
|
|
31
|
+
{ foo: :bar }
|
|
32
|
+
|
|
33
|
+
assert_nothing_raised do
|
|
34
|
+
assert record.send(:update_available_operating_systems),
|
|
35
|
+
'after validation filter does not return true which would cancel the callback chain'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
assert_equal original_oses,
|
|
39
|
+
record.attrs[:available_operating_systems]
|
|
40
|
+
|
|
41
|
+
record.url = ''
|
|
42
|
+
assert_not record.valid?
|
|
43
|
+
|
|
44
|
+
assert_nothing_raised do
|
|
45
|
+
assert_not record.send(:update_available_operating_systems),
|
|
46
|
+
'after validation filter does not return false which would not cancel the callback chain'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
assert_equal original_oses,
|
|
50
|
+
record.attrs[:available_operating_systems]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
test "#supports_operating_systems? defaults to false if there's SSL issue" do
|
|
54
|
+
record = new_ovirt_cr
|
|
55
|
+
record.stubs(:client).raises(Foreman::FingerprintException.new('fingerprint error'))
|
|
56
|
+
|
|
57
|
+
assert_nothing_raised do
|
|
58
|
+
assert_not record.supports_operating_systems?,
|
|
59
|
+
'ForemanOvirt::Ovirt#supports_operating_systems? returns true even if there is SSL issue'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test 'test_connection should fail if datacenters not found (404)' do
|
|
64
|
+
client = stub
|
|
65
|
+
client.stubs(:datacenters).raises(StandardError.new('404 error'))
|
|
66
|
+
record = new_ovirt_cr
|
|
67
|
+
record.stubs(:client).returns(client)
|
|
68
|
+
record.test_connection
|
|
69
|
+
assert_equal ['404 error'],
|
|
70
|
+
record.errors[:url]
|
|
71
|
+
assert_empty record.errors[:base]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
test 'test_connection should fail if not authorized for datacenters (401)' do
|
|
75
|
+
client = stub
|
|
76
|
+
client.stubs(:datacenters).raises(StandardError.new('401 error'))
|
|
77
|
+
record = new_ovirt_cr
|
|
78
|
+
record.stubs(:client).returns(client)
|
|
79
|
+
record.test_connection
|
|
80
|
+
assert_equal ['401 error'],
|
|
81
|
+
record.errors[:user]
|
|
82
|
+
assert_empty record.errors[:base]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
test 'test_connection should succeed with HTTP url' do
|
|
86
|
+
record = new_ovirt_cr 'http'
|
|
87
|
+
record.expects(:client).never
|
|
88
|
+
record.stubs(:datacenters).returns([
|
|
89
|
+
'example', 1
|
|
90
|
+
])
|
|
91
|
+
# returned by oVirt when HTTP is valid and we POST to /api
|
|
92
|
+
RestClient.expects(:post).raises(StandardError.new('406 Not Acceptable'))
|
|
93
|
+
assert record.test_connection
|
|
94
|
+
assert_empty record.errors[:base]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
test 'test_connection should succeed with HTTPS url' do
|
|
98
|
+
record = new_ovirt_cr 'https'
|
|
99
|
+
record.expects(:client).never
|
|
100
|
+
record.stubs(:datacenters).returns([
|
|
101
|
+
'example', 1
|
|
102
|
+
])
|
|
103
|
+
RestClient.expects(:post).never
|
|
104
|
+
assert record.test_connection
|
|
105
|
+
assert_empty record.errors
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
test 'test_connection should detect 302 HTTPS redirect with HTTP url and fail' do
|
|
109
|
+
record = new_ovirt_cr 'http'
|
|
110
|
+
record.expects(:client).never
|
|
111
|
+
record.stubs(:datacenters).returns([
|
|
112
|
+
'example', 1
|
|
113
|
+
])
|
|
114
|
+
# RestClient throws 302 as an error during POSTs
|
|
115
|
+
RestClient.expects(:post).raises(StandardError.new('302 Found'))
|
|
116
|
+
record.test_connection
|
|
117
|
+
assert_match(
|
|
118
|
+
/HTTPS/, record.errors[:url].first
|
|
119
|
+
)
|
|
120
|
+
assert_empty record.errors[:base]
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { datacenterSelected } from '../ovirt';
|
|
2
|
+
|
|
3
|
+
jest.mock('jquery', () => {
|
|
4
|
+
const fn = jest.fn(() => fn);
|
|
5
|
+
fn.fn = fn;
|
|
6
|
+
return fn;
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
jest.mock('../ovirt', () => ({
|
|
10
|
+
datacenterSelected: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('ovirt', () => {
|
|
14
|
+
it('datacenterSelected is defined', () => {
|
|
15
|
+
expect(datacenterSelected).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -6,25 +6,17 @@ import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
|
|
|
6
6
|
import ErrorBoundary from 'foremanReact/components/common/ErrorBoundary';
|
|
7
7
|
import CardTemplate from 'foremanReact/components/HostDetails/Templates/CardItem/CardTemplate';
|
|
8
8
|
import {
|
|
9
|
-
Card,
|
|
10
|
-
CardBody,
|
|
11
|
-
CardHeader,
|
|
12
|
-
CardTitle,
|
|
13
9
|
DescriptionList,
|
|
14
10
|
DescriptionListGroup,
|
|
15
11
|
DescriptionListTerm,
|
|
16
12
|
DescriptionListDescription,
|
|
13
|
+
Spinner,
|
|
14
|
+
EmptyState,
|
|
17
15
|
} from '@patternfly/react-core';
|
|
18
|
-
import { Spinner } from '@patternfly/react-core';
|
|
19
16
|
import { number_to_human_size as NumberToHumanSize } from 'number_helpers';
|
|
20
17
|
|
|
21
18
|
const OvirtCard = ({ hostDetails }) => {
|
|
22
|
-
const {
|
|
23
|
-
id: hostId,
|
|
24
|
-
compute_resource_id: computeResourceId,
|
|
25
|
-
compute_resource_name: computeResourceName,
|
|
26
|
-
compute_resource_provider: provider,
|
|
27
|
-
} = hostDetails;
|
|
19
|
+
const { id: hostId, compute_resource_provider: provider } = hostDetails;
|
|
28
20
|
const virtUrl = foremanUrl(`/api/hosts/${hostId}/vm_compute_attributes`);
|
|
29
21
|
const { response: vm, status = {} } = useAPI('get', virtUrl) || {};
|
|
30
22
|
|
|
@@ -62,18 +54,24 @@ const OvirtCard = ({ hostDetails }) => {
|
|
|
62
54
|
</DescriptionListGroup>
|
|
63
55
|
<DescriptionListGroup>
|
|
64
56
|
<DescriptionListTerm>{__('Sockets')}</DescriptionListTerm>
|
|
65
|
-
<DescriptionListDescription>
|
|
57
|
+
<DescriptionListDescription>
|
|
58
|
+
{vm.sockets}
|
|
59
|
+
</DescriptionListDescription>
|
|
66
60
|
</DescriptionListGroup>
|
|
67
61
|
<DescriptionListGroup>
|
|
68
62
|
<DescriptionListTerm>{__('Memory')}</DescriptionListTerm>
|
|
69
63
|
<DescriptionListDescription>
|
|
70
|
-
{NumberToHumanSize(vm.memory, {
|
|
64
|
+
{NumberToHumanSize(vm.memory, {
|
|
65
|
+
strip_insignificant_zeros: true,
|
|
66
|
+
})}
|
|
71
67
|
</DescriptionListDescription>
|
|
72
68
|
</DescriptionListGroup>
|
|
73
69
|
{vm.display && (
|
|
74
70
|
<DescriptionListGroup>
|
|
75
71
|
<DescriptionListTerm>{__('Display')}</DescriptionListTerm>
|
|
76
|
-
<DescriptionListDescription>
|
|
72
|
+
<DescriptionListDescription>
|
|
73
|
+
{vm.display.type}
|
|
74
|
+
</DescriptionListDescription>
|
|
77
75
|
</DescriptionListGroup>
|
|
78
76
|
)}
|
|
79
77
|
{vm.display && vm.display.type === 'vnc' && (
|
|
@@ -84,32 +82,36 @@ const OvirtCard = ({ hostDetails }) => {
|
|
|
84
82
|
</DescriptionListDescription>
|
|
85
83
|
</DescriptionListGroup>
|
|
86
84
|
)}
|
|
87
|
-
{vm.interfaces_attributes &&
|
|
85
|
+
{vm.interfaces_attributes &&
|
|
86
|
+
Object.keys(vm.interfaces_attributes).length > 0 &&
|
|
88
87
|
Object.values(vm.interfaces_attributes).map((nic, index) => (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
88
|
+
<DescriptionListGroup key={`nic-${index}`}>
|
|
89
|
+
<DescriptionListTerm>{__('NIC name')}</DescriptionListTerm>
|
|
90
|
+
<DescriptionListDescription>
|
|
91
|
+
{nic.compute_attributes.name}
|
|
92
|
+
</DescriptionListDescription>
|
|
93
|
+
<DescriptionListTerm>{__('Network')}</DescriptionListTerm>
|
|
94
|
+
<DescriptionListDescription>
|
|
95
|
+
{nic.compute_attributes.network}
|
|
96
|
+
</DescriptionListDescription>
|
|
97
|
+
<DescriptionListTerm>{__('MAC address')}</DescriptionListTerm>
|
|
98
|
+
<DescriptionListDescription>
|
|
99
|
+
{nic.mac}
|
|
100
|
+
</DescriptionListDescription>
|
|
101
|
+
</DescriptionListGroup>
|
|
102
|
+
))}
|
|
103
|
+
{vm.volumes_attributes &&
|
|
104
|
+
Object.keys(vm.volumes_attributes).length > 0 &&
|
|
103
105
|
Object.values(vm.volumes_attributes).map((vol, index) => (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
<DescriptionListGroup key={`volume-${index}`}>
|
|
107
|
+
<DescriptionListTerm>{__('Disk')}</DescriptionListTerm>
|
|
108
|
+
<DescriptionListDescription>
|
|
109
|
+
{NumberToHumanSize(vol.size_gb * 1024 ** 3, {
|
|
110
|
+
strip_insignificant_zeros: true,
|
|
111
|
+
})}
|
|
112
|
+
</DescriptionListDescription>
|
|
113
|
+
</DescriptionListGroup>
|
|
114
|
+
))}
|
|
113
115
|
</DescriptionList>
|
|
114
116
|
</ErrorBoundary>
|
|
115
117
|
</CardTemplate>
|
data/webpack/global_index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { registerReducer } from 'foremanReact/common/MountingService';
|
|
4
3
|
import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
|
|
5
|
-
import { registerRoutes } from 'foremanReact/routes/RoutingService';
|
|
6
4
|
|
|
7
5
|
import OvirtCard from './components/extensions/HostDetails/DetailsTabCards/OvirtCard';
|
|
8
6
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// fail a test (i.e. default PropType missing). Check the error
|
|
3
3
|
// output and traceback for actual error.
|
|
4
4
|
global.console.error = (error, stack) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/* eslint-disable-next-line no-console */
|
|
6
|
+
if (stack) console.log(stack); // Prints out original stack trace
|
|
7
|
+
throw new Error(error);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// Increase jest timeout as some tests using multiple http mocks can time out on CI systems.
|
data/webpack/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import componentRegistry from 'foremanReact/components/componentRegistry';
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_ovirt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- markt.de
|
|
@@ -108,6 +108,7 @@ files:
|
|
|
108
108
|
- app/assets/javascripts/foreman_ovirt/host_edit.js
|
|
109
109
|
- app/assets/javascripts/foreman_ovirt/nic_info.js
|
|
110
110
|
- app/assets/javascripts/foreman_ovirt/ovirt.js
|
|
111
|
+
- app/controllers/concerns/foreman_ovirt/api_compute_resources_controller_extension.rb
|
|
111
112
|
- app/controllers/concerns/foreman_ovirt/compute_resources_vms_controller.rb
|
|
112
113
|
- app/controllers/concerns/foreman_ovirt/parameters_extension.rb
|
|
113
114
|
- app/controllers/foreman_ovirt/concerns/compute_resources_controller_extensions.rb
|
|
@@ -137,9 +138,19 @@ files:
|
|
|
137
138
|
- locale/foreman_ovirt.pot
|
|
138
139
|
- locale/gemspec.rb
|
|
139
140
|
- package.json
|
|
141
|
+
- test/controllers/api/v2/compute_resources_controller_test.rb
|
|
142
|
+
- test/controllers/hosts_controller_test.rb
|
|
140
143
|
- test/factories/foreman_ovirt_factories.rb
|
|
144
|
+
- test/fixtures/ovirt_operating_systems.xml
|
|
145
|
+
- test/graphql/types/provider_enum_test.rb
|
|
146
|
+
- test/integration/compute_profile_js_test.rb
|
|
147
|
+
- test/models/compute_resources/compute_resource_test_helpers.rb
|
|
148
|
+
- test/models/compute_resources/ovirt_test.rb
|
|
149
|
+
- test/models/ovirt_volume_test.rb
|
|
141
150
|
- test/test_plugin_helper.rb
|
|
142
|
-
- test/unit/
|
|
151
|
+
- test/unit/compute_resource_host_importer_test.rb
|
|
152
|
+
- test/unit/ovirt_connection_test.rb
|
|
153
|
+
- webpack/components/__tests__/ovirt.test.js
|
|
143
154
|
- webpack/components/extensions/HostDetails/DetailsTabCards/OvirtCard.js
|
|
144
155
|
- webpack/components/ovirt.js
|
|
145
156
|
- webpack/global_index.js
|
|
@@ -159,19 +170,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
159
170
|
- - ">="
|
|
160
171
|
- !ruby/object:Gem::Version
|
|
161
172
|
version: '2.7'
|
|
162
|
-
- - "<"
|
|
163
|
-
- !ruby/object:Gem::Version
|
|
164
|
-
version: '4'
|
|
165
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
174
|
requirements:
|
|
167
175
|
- - ">="
|
|
168
176
|
- !ruby/object:Gem::Version
|
|
169
177
|
version: '0'
|
|
170
178
|
requirements: []
|
|
171
|
-
rubygems_version:
|
|
179
|
+
rubygems_version: 4.0.10
|
|
172
180
|
specification_version: 4
|
|
173
|
-
summary: oVirt as a compute resource for
|
|
181
|
+
summary: oVirt as a compute resource for Foreman
|
|
174
182
|
test_files:
|
|
183
|
+
- test/controllers/api/v2/compute_resources_controller_test.rb
|
|
184
|
+
- test/controllers/hosts_controller_test.rb
|
|
175
185
|
- test/factories/foreman_ovirt_factories.rb
|
|
186
|
+
- test/fixtures/ovirt_operating_systems.xml
|
|
187
|
+
- test/graphql/types/provider_enum_test.rb
|
|
188
|
+
- test/integration/compute_profile_js_test.rb
|
|
189
|
+
- test/models/compute_resources/compute_resource_test_helpers.rb
|
|
190
|
+
- test/models/compute_resources/ovirt_test.rb
|
|
191
|
+
- test/models/ovirt_volume_test.rb
|
|
176
192
|
- test/test_plugin_helper.rb
|
|
177
|
-
- test/unit/
|
|
193
|
+
- test/unit/compute_resource_host_importer_test.rb
|
|
194
|
+
- test/unit/ovirt_connection_test.rb
|
|
195
|
+
- webpack/components/__tests__/ovirt.test.js
|