foreman_kubevirt 0.1.2 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +5 -3
- data/app/assets/javascripts/bundle.js +1 -0
- data/app/controllers/foreman_kubevirt/concerns/api/compute_resources_controller_extensions.rb +8 -16
- data/app/models/foreman_kubevirt/compute_attribute_extensions.rb +8 -0
- data/app/models/foreman_kubevirt/kubevirt.rb +86 -24
- data/app/validators/volume_validator.rb +13 -0
- data/app/views/compute_resources/form/_kubevirt.html.erb +5 -3
- data/app/views/compute_resources_vms/form/kubevirt/_volume.html.erb +5 -2
- data/app/views/compute_resources_vms/index/_kubevirt.html.erb +1 -1
- data/app/views/compute_resources_vms/show/_kubevirt.html.erb +1 -2
- data/lib/foreman_kubevirt/engine.rb +3 -0
- data/lib/foreman_kubevirt/version.rb +1 -1
- data/locale/action_names.rb +5 -0
- data/locale/ca/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/ca/foreman_kubevirt.po +170 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/cs_CZ/foreman_kubevirt.po +170 -0
- data/locale/de/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/de/foreman_kubevirt.po +170 -0
- data/locale/en/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/en/foreman_kubevirt.edit.po +219 -0
- data/locale/en/foreman_kubevirt.po +162 -11
- data/locale/en/foreman_kubevirt.po.time_stamp +0 -0
- data/locale/en_GB/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/en_GB/foreman_kubevirt.po +170 -0
- data/locale/es/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/es/foreman_kubevirt.po +170 -0
- data/locale/foreman_kubevirt.pot +232 -8
- data/locale/fr/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/fr/foreman_kubevirt.po +170 -0
- data/locale/gemspec.rb +1 -1
- data/locale/gl/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/gl/foreman_kubevirt.po +170 -0
- data/locale/it/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/it/foreman_kubevirt.po +170 -0
- data/locale/ja/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/ja/foreman_kubevirt.po +170 -0
- data/locale/ko/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/ko/foreman_kubevirt.po +170 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/nl_NL/foreman_kubevirt.po +177 -0
- data/locale/pl/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/pl/foreman_kubevirt.po +176 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/pt_BR/foreman_kubevirt.po +178 -0
- data/locale/ru/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/ru/foreman_kubevirt.po +180 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/sv_SE/foreman_kubevirt.po +176 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/zh_CN/foreman_kubevirt.po +177 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_kubevirt.mo +0 -0
- data/locale/zh_TW/foreman_kubevirt.po +175 -0
- data/test/factories/compute_resource_factories.rb +6 -6
- data/test/factories/host_factories.rb +41 -41
- data/test/factories/nic_factories.rb +25 -25
- data/test/models/compute_resources/kubevirt_test.rb +15 -1
- data/test/unit/foreman_kubevirt_test.rb +65 -6
- metadata +52 -12
Binary file
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
2
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3
|
+
# This file is distributed under the same license as the foreman_kubevirt package.
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5
|
+
#
|
6
|
+
# Translators:
|
7
|
+
# 0868a4d1af5275b3f70b0a6dac4c99a4, 2020
|
8
|
+
# Bryan Kearney <bryan.kearney@gmail.com>, 2020
|
9
|
+
#
|
10
|
+
#, fuzzy
|
11
|
+
msgid ""
|
12
|
+
msgstr ""
|
13
|
+
"Project-Id-Version: foreman_kubevirt 0.1.7\n"
|
14
|
+
"Report-Msgid-Bugs-To: \n"
|
15
|
+
"PO-Revision-Date: 2020-05-26 07:39+0000\n"
|
16
|
+
"Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>, 2020\n"
|
17
|
+
"Language-Team: Chinese (Taiwan) (https://www.transifex.com/foreman/teams/114/z"
|
18
|
+
"h_TW/)\n"
|
19
|
+
"MIME-Version: 1.0\n"
|
20
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
21
|
+
"Content-Transfer-Encoding: 8bit\n"
|
22
|
+
"Language: zh_TW\n"
|
23
|
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
24
|
+
|
25
|
+
msgid "%{cpu_cores} Cores and %{memory} memory"
|
26
|
+
msgstr ""
|
27
|
+
|
28
|
+
msgid "API Port"
|
29
|
+
msgstr ""
|
30
|
+
|
31
|
+
msgid "API port for KubeVirt only"
|
32
|
+
msgstr ""
|
33
|
+
|
34
|
+
msgid "Actions"
|
35
|
+
msgstr "動作"
|
36
|
+
|
37
|
+
msgid "Bootable"
|
38
|
+
msgstr "可開機"
|
39
|
+
|
40
|
+
msgid "CA crt for KubeVirt only"
|
41
|
+
msgstr ""
|
42
|
+
|
43
|
+
msgid "CNI Provider"
|
44
|
+
msgstr ""
|
45
|
+
|
46
|
+
msgid "CPUs"
|
47
|
+
msgstr "CPU"
|
48
|
+
|
49
|
+
msgid "Disk"
|
50
|
+
msgstr "磁碟"
|
51
|
+
|
52
|
+
msgid "Does this image support user data input (e.g. via cloud-init)?"
|
53
|
+
msgstr "這映像檔是否支援使用者資料輸入(比方說透過 cloud-init)?"
|
54
|
+
|
55
|
+
msgid "Host name for KubeVirt only"
|
56
|
+
msgstr ""
|
57
|
+
|
58
|
+
msgid "Hostname"
|
59
|
+
msgstr "主機名稱"
|
60
|
+
|
61
|
+
msgid "Image"
|
62
|
+
msgstr "影像"
|
63
|
+
|
64
|
+
msgid "It is not possible to set a bootable volume and image based provisioning."
|
65
|
+
msgstr ""
|
66
|
+
|
67
|
+
msgid "Memory"
|
68
|
+
msgstr "記憶體"
|
69
|
+
|
70
|
+
msgid "NIC"
|
71
|
+
msgstr "NIC"
|
72
|
+
|
73
|
+
msgid "Name"
|
74
|
+
msgstr "名稱"
|
75
|
+
|
76
|
+
msgid "Namespace"
|
77
|
+
msgstr ""
|
78
|
+
|
79
|
+
msgid "Namespace for KubeVirt only"
|
80
|
+
msgstr ""
|
81
|
+
|
82
|
+
msgid "Network"
|
83
|
+
msgstr "網路"
|
84
|
+
|
85
|
+
msgid "Only one volume can be bootable"
|
86
|
+
msgstr "只有一個卷冊能作為開機卷冊"
|
87
|
+
|
88
|
+
msgid "Optionally provide a CA, or a correctly ordered CA chain or a path to a file. If left blank - insecure."
|
89
|
+
msgstr ""
|
90
|
+
|
91
|
+
msgid "Password to authenticate with - used for SSH finish step."
|
92
|
+
msgstr "用來進行認證的密碼 - 用於 SSH 完成步驟。"
|
93
|
+
|
94
|
+
msgid "Please select an image"
|
95
|
+
msgstr "請選擇一個映像檔"
|
96
|
+
|
97
|
+
msgid "Power"
|
98
|
+
msgstr "電源"
|
99
|
+
|
100
|
+
msgid "Power ON this machine"
|
101
|
+
msgstr "開啟這部機器的電源"
|
102
|
+
|
103
|
+
msgid "Properties"
|
104
|
+
msgstr "屬性"
|
105
|
+
|
106
|
+
msgid "Provision and manage Kubevirt Virtual Machines from Foreman."
|
107
|
+
msgstr ""
|
108
|
+
|
109
|
+
msgid "Running on"
|
110
|
+
msgstr "執行於"
|
111
|
+
|
112
|
+
msgid "Size (GB)"
|
113
|
+
msgstr "大小(GB)"
|
114
|
+
|
115
|
+
msgid "Start"
|
116
|
+
msgstr "開始"
|
117
|
+
|
118
|
+
msgid "Storage Class"
|
119
|
+
msgstr ""
|
120
|
+
|
121
|
+
msgid "The compute resource could not be authenticated"
|
122
|
+
msgstr ""
|
123
|
+
|
124
|
+
msgid "The name of the image in the registry."
|
125
|
+
msgstr ""
|
126
|
+
|
127
|
+
msgid ""
|
128
|
+
"The remote system presented a public key signed by an unidentified certificate authority.\n"
|
129
|
+
" If you are sure the remote system is authentic, go to the compute resource edit page, press the 'Test Connection' button and submit"
|
130
|
+
msgstr ""
|
131
|
+
|
132
|
+
msgid "The user that is used to ssh into the instance, normally cloud-user, ec2-user, ubuntu, root etc"
|
133
|
+
msgstr "使用來 ssh 入 instance 的使用者,一般會是 cloud-user、ec2-user、ubuntu、root 等等"
|
134
|
+
|
135
|
+
msgid "Token"
|
136
|
+
msgstr "權杖"
|
137
|
+
|
138
|
+
msgid "Token for KubeVirt only"
|
139
|
+
msgstr ""
|
140
|
+
|
141
|
+
msgid "Type"
|
142
|
+
msgstr "類型"
|
143
|
+
|
144
|
+
msgid "UUID"
|
145
|
+
msgstr "UUID"
|
146
|
+
|
147
|
+
msgid "VCPU(s)"
|
148
|
+
msgstr "VCPU"
|
149
|
+
|
150
|
+
msgid "VM should be created based on Persistent Volume Claim or Image"
|
151
|
+
msgstr ""
|
152
|
+
|
153
|
+
msgid "VM should be created based on an image"
|
154
|
+
msgstr ""
|
155
|
+
|
156
|
+
msgid "X509 Certification Authorities"
|
157
|
+
msgstr "X509 憑證許可"
|
158
|
+
|
159
|
+
msgid "cni_provider or network are missing"
|
160
|
+
msgstr ""
|
161
|
+
|
162
|
+
msgid "e.g. eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9..."
|
163
|
+
msgstr ""
|
164
|
+
|
165
|
+
msgid "genie"
|
166
|
+
msgstr ""
|
167
|
+
|
168
|
+
msgid "multus"
|
169
|
+
msgstr ""
|
170
|
+
|
171
|
+
msgid "no Storage Classes available on provider"
|
172
|
+
msgstr ""
|
173
|
+
|
174
|
+
msgid "pod"
|
175
|
+
msgstr ""
|
@@ -1,10 +1,10 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :compute_resource_kubevirt, class: 'ForemanKubevirt::Kubevirt' do
|
3
|
-
provider "Kubevirt"
|
4
|
-
name 'kubevirt-multus'
|
5
|
-
hostname "192.168.111.13"
|
6
|
-
api_port "6443"
|
7
|
-
namespace "default"
|
8
|
-
token "kubetoken"
|
3
|
+
provider { "Kubevirt" }
|
4
|
+
name { 'kubevirt-multus' }
|
5
|
+
hostname { "192.168.111.13" }
|
6
|
+
api_port { "6443" }
|
7
|
+
namespace { "default" }
|
8
|
+
token { "kubetoken" }
|
9
9
|
end
|
10
10
|
end
|
@@ -1,46 +1,46 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :host_kubevirt, class: 'Host::Managed' do
|
3
|
-
name "susie-baynham.example.com"
|
4
|
-
last_compile nil
|
5
|
-
last_report nil
|
6
|
-
updated_at nil
|
7
|
-
root_pass "$5$pzp5IoYXH9WQT6Ks$fk1OzfJAK1"
|
8
|
-
architecture_id 1
|
9
|
-
operatingsystem_id 3
|
10
|
-
environment_id 3
|
11
|
-
ptable_id 91
|
12
|
-
medium_id 13
|
13
|
-
build true
|
14
|
-
comment ""
|
15
|
-
disk ""
|
16
|
-
installed_at nil
|
17
|
-
model_id nil
|
18
|
-
hostgroup_id 31
|
19
|
-
owner_id 4
|
20
|
-
owner_type "User"
|
21
|
-
enabled true
|
22
|
-
puppet_ca_proxy_id nil
|
23
|
-
managed true
|
24
|
-
use_image nil
|
25
|
-
image_file nil
|
26
|
-
uuid nil
|
27
|
-
compute_resource_id 7
|
28
|
-
puppet_proxy_id 1
|
29
|
-
certname nil
|
30
|
-
image_id nil
|
31
|
-
organization_id 2
|
32
|
-
location_id 1
|
33
|
-
type "Host::Managed"
|
34
|
-
otp nil
|
35
|
-
realm_id nil
|
36
|
-
compute_profile_id nil
|
37
|
-
provision_method "build"
|
38
|
-
grub_pass "$6$aRZAzZm1TOa5WAGX$.Cwxy5zCrjVQqHUE/0Ic9oQ"
|
39
|
-
global_status 0
|
40
|
-
lookup_value_matcher "fqdn=susie-baynham.example.com"
|
41
|
-
pxe_loader "PXELinux BIOS"
|
42
|
-
initiated_at nil
|
43
|
-
build_errors nil
|
3
|
+
name { "susie-baynham.example.com" }
|
4
|
+
last_compile { nil }
|
5
|
+
last_report { nil }
|
6
|
+
updated_at { nil }
|
7
|
+
root_pass { "$5$pzp5IoYXH9WQT6Ks$fk1OzfJAK1" }
|
8
|
+
architecture_id { 1 }
|
9
|
+
operatingsystem_id { 3 }
|
10
|
+
environment_id { 3 }
|
11
|
+
ptable_id { 91 }
|
12
|
+
medium_id { 13 }
|
13
|
+
build { true }
|
14
|
+
comment { "" }
|
15
|
+
disk { "" }
|
16
|
+
installed_at { nil }
|
17
|
+
model_id { nil }
|
18
|
+
hostgroup_id { 31 }
|
19
|
+
owner_id { 4 }
|
20
|
+
owner_type { "User" }
|
21
|
+
enabled { true }
|
22
|
+
puppet_ca_proxy_id { nil }
|
23
|
+
managed { true }
|
24
|
+
use_image { nil }
|
25
|
+
image_file { nil }
|
26
|
+
uuid { nil }
|
27
|
+
compute_resource_id { 7 }
|
28
|
+
puppet_proxy_id { 1 }
|
29
|
+
certname { nil }
|
30
|
+
image_id { nil }
|
31
|
+
organization_id { 2 }
|
32
|
+
location_id { 1 }
|
33
|
+
type { "Host::Managed" }
|
34
|
+
otp { nil }
|
35
|
+
realm_id { nil }
|
36
|
+
compute_profile_id { nil }
|
37
|
+
provision_method { "build" }
|
38
|
+
grub_pass { "$6$aRZAzZm1TOa5WAGX$.Cwxy5zCrjVQqHUE/0Ic9oQ" }
|
39
|
+
global_status { 0 }
|
40
|
+
lookup_value_matcher { "fqdn=susie-baynham.example.com" }
|
41
|
+
pxe_loader { "PXELinux BIOS" }
|
42
|
+
initiated_at { nil }
|
43
|
+
build_errors { nil }
|
44
44
|
|
45
45
|
trait :with_interfaces do
|
46
46
|
interfaces { build_list :nic_kubevirt, 1 }
|
@@ -1,31 +1,31 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :nic_kubevirt, class: 'Nic::Managed' do
|
3
|
-
mac "a2:b4:a2:b2:a2:a8"
|
4
|
-
ip "192.168.111.200"
|
5
|
-
type "Nic::Managed"
|
6
|
-
name "elton-kniola.example.com"
|
7
|
-
host_id 1
|
8
|
-
subnet_id 2
|
9
|
-
domain_id 1
|
3
|
+
mac { "a2:b4:a2:b2:a2:a8" }
|
4
|
+
ip { "192.168.111.200" }
|
5
|
+
type { "Nic::Managed" }
|
6
|
+
name { "elton-kniola.example.com" }
|
7
|
+
host_id { 1 }
|
8
|
+
subnet_id { 2 }
|
9
|
+
domain_id { 1 }
|
10
10
|
attrs {}
|
11
|
-
created_at nil
|
12
|
-
updated_at nil
|
13
|
-
provider nil
|
14
|
-
username nil
|
15
|
-
password nil
|
16
|
-
virtual false
|
17
|
-
link true
|
18
|
-
identifier ""
|
19
|
-
tag ""
|
20
|
-
attached_to ""
|
21
|
-
managed true
|
22
|
-
mode "balance-rr"
|
23
|
-
attached_devices ""
|
24
|
-
bond_options ""
|
25
|
-
primary true
|
26
|
-
provision true
|
11
|
+
created_at { nil }
|
12
|
+
updated_at { nil }
|
13
|
+
provider { nil }
|
14
|
+
username { nil }
|
15
|
+
password { nil }
|
16
|
+
virtual { false }
|
17
|
+
link { true }
|
18
|
+
identifier { "" }
|
19
|
+
tag { "" }
|
20
|
+
attached_to { "" }
|
21
|
+
managed { true }
|
22
|
+
mode { "balance-rr" }
|
23
|
+
attached_devices { "" }
|
24
|
+
bond_options { "" }
|
25
|
+
primary { true }
|
26
|
+
provision { true }
|
27
27
|
compute_attributes { { "cni_provider" => "multus", "network" => "ovs-foreman" } }
|
28
|
-
ip6 ""
|
29
|
-
subnet6_id nil
|
28
|
+
ip6 { "" }
|
29
|
+
subnet6_id { nil }
|
30
30
|
end
|
31
31
|
end
|
@@ -64,6 +64,20 @@ class ForemanKubevirtTest < ActiveSupport::TestCase
|
|
64
64
|
client.stubs(:valid?).returns(true)
|
65
65
|
record = new_kubevirt_vcr
|
66
66
|
record.stubs(:client).returns(client)
|
67
|
-
|
67
|
+
assert_not record.test_connection
|
68
|
+
end
|
69
|
+
|
70
|
+
test "Verify client raises StandardError exception" do
|
71
|
+
record = new_kubevirt_vcr
|
72
|
+
record.stubs(:client).raises(StandardError.new('test'))
|
73
|
+
record.test_connection
|
74
|
+
assert_equal ['test'], record.errors[:base]
|
75
|
+
end
|
76
|
+
|
77
|
+
test "Verify client raises FingerprintException exception" do
|
78
|
+
record = new_kubevirt_vcr
|
79
|
+
record.stubs(:client).raises(Foreman::FingerprintException.new('test'))
|
80
|
+
record.test_connection
|
81
|
+
assert_includes record.errors[:base][0], "[Foreman::FingerprintException]: test"
|
68
82
|
end
|
69
83
|
end
|
@@ -73,35 +73,49 @@ class ForemanKubevirtTest < ActiveSupport::TestCase
|
|
73
73
|
assert_equal 1, server.interfaces.count
|
74
74
|
end
|
75
75
|
|
76
|
+
test "create_vm image based without additional volumes should pass" do
|
77
|
+
vm_args = IMAGE_BASED_VM_ARGS.deep_dup
|
78
|
+
vm_args.delete("volumes_attributes")
|
79
|
+
|
80
|
+
Fog.mock!
|
81
|
+
compute_resource = new_kubevirt_vcr
|
82
|
+
server = compute_resource.create_vm(vm_args)
|
83
|
+
|
84
|
+
assert_equal "olive-kempter.example.com", server.name
|
85
|
+
end
|
86
|
+
|
76
87
|
test "should fail when creating a VM with_bootable flag and image based" do
|
77
88
|
vm_args = IMAGE_BASED_VM_ARGS.deep_dup
|
78
89
|
vm_args["volumes_attributes"]["0"]["bootable"] = "true"
|
79
90
|
Fog.mock!
|
80
91
|
compute_resource = new_kubevirt_vcr
|
81
|
-
assert_raise(Foreman::Exception) do
|
92
|
+
exception = assert_raise(Foreman::Exception) do
|
82
93
|
compute_resource.create_vm(vm_args)
|
83
94
|
end
|
95
|
+
assert_match(/It is not possible to set a bootable volume and image based provisioning./, exception.message)
|
84
96
|
end
|
85
97
|
|
86
98
|
test "should fail when creating a VM without an image or pvc" do
|
87
99
|
vm_args = IMAGE_BASED_VM_ARGS.deep_dup
|
100
|
+
vm_args["volumes_attributes"] = {}
|
88
101
|
vm_args["image_id"] = nil
|
89
102
|
Fog.mock!
|
90
103
|
compute_resource = new_kubevirt_vcr
|
91
|
-
assert_raise(Foreman::Exception) do
|
104
|
+
exception = assert_raise(Foreman::Exception) do
|
92
105
|
compute_resource.create_vm(vm_args)
|
93
106
|
end
|
107
|
+
assert_match(/VM should be created based on Persistent Volume Claim or Image/, exception.message)
|
94
108
|
end
|
95
109
|
|
96
110
|
test "should fail when creating image-based VM without an image" do
|
97
111
|
vm_args = IMAGE_BASED_VM_ARGS.deep_dup
|
98
|
-
vm_args["volumes_attributes"] = {}
|
99
112
|
vm_args["image_id"] = nil
|
100
113
|
Fog.mock!
|
101
114
|
compute_resource = new_kubevirt_vcr
|
102
|
-
assert_raise(Foreman::Exception) do
|
115
|
+
exception = assert_raise(Foreman::Exception) do
|
103
116
|
compute_resource.create_vm(vm_args)
|
104
117
|
end
|
118
|
+
assert_match(/VM should be created based on an image/, exception.message)
|
105
119
|
end
|
106
120
|
|
107
121
|
test "should fail when creating a VM with PVC and not providing a capacity" do
|
@@ -109,9 +123,21 @@ class ForemanKubevirtTest < ActiveSupport::TestCase
|
|
109
123
|
vm_args["volumes_attributes"]["0"]["capacity"] = nil
|
110
124
|
Fog.mock!
|
111
125
|
compute_resource = new_kubevirt_vcr
|
112
|
-
assert_raise(Foreman::Exception) do
|
126
|
+
exception = assert_raise(Foreman::Exception) do
|
127
|
+
compute_resource.create_vm(vm_args)
|
128
|
+
end
|
129
|
+
assert_match(/Volume size is not valid/, exception.message)
|
130
|
+
end
|
131
|
+
|
132
|
+
test "should fail when creating a VM with not valid capacity" do
|
133
|
+
vm_args = NETWORK_BASED_VM_ARGS.deep_dup
|
134
|
+
vm_args["volumes_attributes"]["0"]["capacity"] = "TG"
|
135
|
+
Fog.mock!
|
136
|
+
compute_resource = new_kubevirt_vcr
|
137
|
+
exception = assert_raise(Foreman::Exception) do
|
113
138
|
compute_resource.create_vm(vm_args)
|
114
139
|
end
|
140
|
+
assert_match(/Volume size TG is not valid/, exception.message)
|
115
141
|
end
|
116
142
|
|
117
143
|
test "should fail when creating a VM with two bootable PVCs" do
|
@@ -120,8 +146,41 @@ class ForemanKubevirtTest < ActiveSupport::TestCase
|
|
120
146
|
vm_args["volumes_attributes"]["1"]["bootable"] = "true"
|
121
147
|
Fog.mock!
|
122
148
|
compute_resource = new_kubevirt_vcr
|
123
|
-
assert_raise(Foreman::Exception) do
|
149
|
+
exception = assert_raise(Foreman::Exception) do
|
124
150
|
compute_resource.create_vm(vm_args)
|
125
151
|
end
|
152
|
+
assert_match(/Only one volume can be bootable/, exception.message)
|
153
|
+
end
|
154
|
+
|
155
|
+
test "create_vm without CPU should pass" do
|
156
|
+
vm_args = NETWORK_BASED_VM_ARGS.deep_dup
|
157
|
+
vm_args.delete("cpu_cores")
|
158
|
+
Fog.mock!
|
159
|
+
compute_resource = new_kubevirt_vcr
|
160
|
+
server = compute_resource.create_vm(vm_args)
|
161
|
+
|
162
|
+
# verify default CPU value is set
|
163
|
+
assert_equal 1, server.cpu_cores
|
164
|
+
end
|
165
|
+
|
166
|
+
test "create_vm without memory should pass" do
|
167
|
+
vm_args = NETWORK_BASED_VM_ARGS.deep_dup
|
168
|
+
vm_args.delete("memory")
|
169
|
+
Fog.mock!
|
170
|
+
compute_resource = new_kubevirt_vcr
|
171
|
+
server = compute_resource.create_vm(vm_args)
|
172
|
+
|
173
|
+
# verify default memory value is set
|
174
|
+
assert_equal "1024M", server.memory
|
175
|
+
end
|
176
|
+
|
177
|
+
test "converts memory to byte" do
|
178
|
+
Fog.mock!
|
179
|
+
compute_resource = new_kubevirt_vcr
|
180
|
+
assert_equal 1.gigabytes, compute_resource.convert_memory_to_bytes("1Gi")
|
181
|
+
assert_equal 1.megabytes, compute_resource.convert_memory_to_bytes("1Mi")
|
182
|
+
assert_equal 1_000_000_000, compute_resource.convert_memory_to_bytes("1G")
|
183
|
+
assert_equal 1_000_000, compute_resource.convert_memory_to_bytes("1M")
|
184
|
+
assert_equal 0, compute_resource.convert_memory_to_bytes("0b")
|
126
185
|
end
|
127
186
|
end
|