Skip to content

Commit 79a6b18

Browse files
committed
MTV-3443: MTV template methods
Signed-off-by: Richard Hoch <[email protected]>
1 parent 0a5247f commit 79a6b18

File tree

5 files changed

+172
-7
lines changed

5 files changed

+172
-7
lines changed

documentation/doc-Migrating_your_virtual_machines/assemblies/assembly_migrating-from-vmware.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ include::../modules/mtv-shared-disks-known-issues.adoc[leveloffset=+3]
3737

3838
include::../modules/mtv-shared-disks-workarounds.adoc[leveloffset=+3]
3939

40+
include::../modules/mtv-template-utility.adoc[leveloffset=+2]
41+
4042
include::../modules/canceling-migration-cli.adoc[leveloffset=+2]
4143

4244
include::../modules/canceling-migration-cli-entire.adoc[leveloffset=+3]

documentation/modules/common-attributes.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
:project-short: MTV
2222
:project-first: {project-full} ({project-short})
2323
:project-version: 2.10
24+
:mtv-mig: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/{project-version}/html/migrating_your_virtual_machines_to_red_hat_openshift_virtualization/
25+
:mtv-plan: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/{project-version}/html/planning_your_migration_to_red_hat_openshift_virtualization/
2426
:project-z-version: 2.10.0
2527
:rhel-first: Red Hat Enterprise Linux (RHEL)
2628
:the: The

documentation/modules/creating-plan-wizard-vmware.adoc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Variable names cannot exceed 63 characters.
213213

214214
*** Click the *Edit* icon.
215215
*** Click *Enter custom naming template*.
216-
*** Enter the template according to the instructions.
216+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
217217
*** Click *Save*.
218218

219219
** To specify a different volume name template only for specific VMs, do the following:
@@ -222,13 +222,14 @@ Variable names cannot exceed 63 characters.
222222
*** Select the desired VMs.
223223
*** Click the {kebab} of the VM.
224224
*** Select *Edit Volume name template*.
225-
*** Enter the template according to the instructions.
225+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
226226
*** Click *Save*.
227227
+
228228
[IMPORTANT]
229229
====
230230
Changes you make on the *Virtual Machines* tab override any changes on the *Plan details* page.
231231
====
232+
+
232233
233234
* *PVC name template*: Specifies a template for the name of the persistent volume claim (PVC) for the VMs in your plan.
234235
+
@@ -250,7 +251,7 @@ Variable names cannot exceed 63 characters.
250251

251252
*** Click the *Edit* icon.
252253
*** Click *Enter custom naming template*.
253-
*** Enter the template according to the instructions.
254+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
254255
*** Click *Save*.
255256

256257
** To specify a PVC name template only for specific VMs, do the following:
@@ -259,7 +260,7 @@ Variable names cannot exceed 63 characters.
259260
*** Select the desired VMs.
260261
*** Click the {kebab} of the VM.
261262
*** Select *Edit PVC name template*.
262-
*** Enter the template according to the instructions.
263+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
263264
*** Click *Save*.
264265
+
265266
[IMPORTANT]
@@ -287,7 +288,7 @@ Variable names cannot exceed 63 characters.
287288

288289
*** Click the *Edit* icon.
289290
*** Click *Enter custom naming template*.
290-
*** Enter the template according to the instructions.
291+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
291292
*** Click *Save*.
292293

293294
** To specify a different network name template only for specific VMs, do the following:
@@ -296,13 +297,18 @@ Variable names cannot exceed 63 characters.
296297
*** Select the desired VMs.
297298
*** Click the {kebab} of the VM.
298299
*** Select *Edit Network name template*.
299-
*** Enter the template according to the instructions.
300+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
300301
*** Click *Save*.
301302
+
302303
[IMPORTANT]
303304
====
304305
Changes you make on the *Virtual Machines* tab override any changes on the *Plan details* page.
305306
====
307+
+
308+
[IMPORTANT]
309+
====
310+
{project-short} does not validate VM names generated by the templates you enter on the *Plan details* page. Migrations that include VMs whose names include uppercase letters fail automatically. To avoid failures, you might want to run a Go script that uses the `sprig` methods that {project-short} supports. For tables documenting the methods that {project-short} supports, see {mtv-mig}assembly_migrating-from-vmware#mtv-template-utility_vmware[{project-short} template utility for {vmw} VM names].
311+
====
306312

307313
* *Raw copy mode*: By default, during migration, virtual machines (VMs) are converted using a tool named `virt-v2v` that makes them compatible with {virt}. For more information about the virt-v2v conversion process, see 'How {project-short} uses the virt-v2v tool' in _Migrating your virtual machines to Red Hat {virt}_. _Raw copy mode_ copies VMs without converting them. This allows for faster conversions, migrating VMs running a wider range of operating systems, and supporting migrating disks encrypted using Linux Unified Key Setup (LUKS) without needing keys. However, VMs migrated using raw copy mode might not function properly on {virt}.
308314
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * documentation/doc-Migrating_your_virtual_machines/assembly_migrating-from-vmware.adoc
4+
5+
:_content-type: CONCEPT
6+
[id="mtv-template-utility_{context}"]
7+
= {project-short} template utility for {vmw} VM names
8+
9+
[role="_abstract"]
10+
You can use the template utility of {project-first} to generate names for your virtual machines (VMs). Using names generated by these methods reduces the possibilities of problems with your VMs after their migration to {virt}.
11+
12+
The tables that follow describe string and mathematical functions that you can use in templates that rename VMs for use with {project-short}.
13+
14+
[cols="1,1,1",options="header"]
15+
.String functions
16+
17+
|===
18+
| Function
19+
| Description
20+
| Example
21+
22+
| `lower`
23+
| Converts a string to lowercase.
24+
| `{{ lower "TEXT" }}``text`
25+
26+
| `upper`
27+
| Converts a string to uppercase.
28+
| `{{ upper "text" }}``TEXT`
29+
30+
| `contains`
31+
| Checks if a string contains a specific substring.
32+
| `{{ contains "hello" "lo" }}``true`
33+
34+
| `replace`
35+
| Replaces occurrences in a string.
36+
| `{{"I Am Henry VIII" \| replace "{nbsp}" "-"}}``I-Am-Henry-VIII`
37+
38+
| `trim`
39+
| Removes whitespace from both ends of a string.
40+
| `{{ trim " text " }}``text`
41+
42+
| `trimAll`
43+
| Removes specified characters from both ends of a string.
44+
| `{{ trimAll "$" "$5.00$" }}``5.00`
45+
46+
| `trimSuffix`
47+
| Removes the specified suffix from a string, if it is present.
48+
| `{{ trimSuffix ".go" "file.go" }}``file`
49+
50+
| `trimPrefix`
51+
| Removes the specified prefix from a string, if it is present.
52+
| `{{ trimPrefix "go." "go.file" }}``file`
53+
54+
| `title`
55+
| Converts a string to title case.
56+
| `{{ title "hello world" }}``Hello World`
57+
58+
| `untitle`
59+
| Converts a string in title case to lowercase.
60+
| `{{ untitle "Hello World" }}``hello world`
61+
62+
| `repeat`
63+
| Repeats a string _n_ times.
64+
| `{{ repeat 3 "abc" }}``abcabcabc`
65+
66+
| `substr`
67+
| Extracts substring from _index>=a_ to _b<index_.
68+
| `{{ substr 1 4 "abcdef" }}``bcd`
69+
70+
| `nospace`
71+
| Removes all whitespace from a string.
72+
| `{{ nospace "a b c" }}``abc`
73+
74+
| `trunc`
75+
| Truncates a string to specified length.
76+
| `{{ trunc 3 "abcdef" }}``abc`
77+
78+
| `initials`
79+
| Extracts the first letter of each word in a string.
80+
| `{{ initials "John Doe" }} → `JD`
81+
82+
| `hasPrefix`
83+
| Checks if a string starts with the specified prefix.
84+
| `{{ hasPrefix "go" "golang" }}``true`
85+
86+
| `hasSuffix`
87+
| Checks if a string ends with the specified suffix.
88+
| `{{ hasSuffix "ing" "coding" }}``true`
89+
90+
| `mustRegexReplaceAll`
91+
| Replaces matches using regular expressions with submatch expansion.
92+
| `{{ mustRegexReplaceAll "a(x*)b" "-ab-axxb-" "${1}W" }}``-W-xxW-`
93+
|===
94+
95+
[cols="1,1,1",options="header"]
96+
.Mathematical functions
97+
98+
|===
99+
| Function
100+
| Description
101+
| Example
102+
103+
| `add`
104+
| Sum of the numbers that follow.
105+
| `{{ add 1 2 3 }}``6`
106+
107+
| `add1`
108+
| Increment by 1.
109+
| `{{ add1 5 }}``6`
110+
111+
| `sub`
112+
| Subtract the second number from the first.
113+
| `{{ sub 5 3 }}``2`
114+
115+
| `div`
116+
| Integer division (remainder discarded).
117+
| `{{ div 10 3 }}``3`
118+
119+
| `mod`
120+
| Modulo operation.
121+
| `{{ mod 10 3 }}``1`
122+
123+
| `multiply`
124+
| Multiply the numbers that follow.
125+
| `{{ mul 2 3 4 }}``24`
126+
127+
| `max`
128+
| Return the largest of the following integers.
129+
| `{{ max 1 5 3 }}``5`
130+
131+
| `min`
132+
| Return the smallest of the following integers.
133+
| `{{ min 1 5 3 }}``1`
134+
135+
| `floor`
136+
| Round the following number down to the nearest integer.
137+
| `{{ floor 3.75 }}``3.0`
138+
139+
| `ceil`
140+
| Round the following number up to the nearest integer.
141+
| `{{ ceil 3.25 }}``4.0`
142+
143+
| `round`
144+
| Round the following number to the specified number of decimal places.
145+
| `{{ round 3.75159 2 }}``3.75`
146+
|===

documentation/modules/proc_migrating-virtual-machines-cli.adoc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Module included in the following assemblies:
22
//
3-
// * documentation/doc-Migration_Toolkit_for_Virtualization/master.adoc
3+
// * documentation/doc-Migrating_your_virtual_machines/assembly_migrating-from-cnv.adoc
4+
// * documentation/doc-Migrating_your_virtual_machines/assembly_migrating-from-osp.adoc
5+
// * documentation/doc-Migrating_your_virtual_machines/assembly_migrating-from-ova.adoc
6+
// * documentation/doc-Migrating_your_virtual_machines/assembly_migrating-from-rhv.adoc
7+
// * documentation/doc-Migrating_your_virtual_machines/assembly_migrating-from-vmware.adoc
48

59
:_mod-docs-content-type: PROCEDURE
610
[id="proc_migrating-virtual-machines-cli_{context}"]
@@ -918,6 +922,11 @@ The template follows the Go template syntax and has access to the following vari
918922
<23> Allowed values are `PreHook` before the migration plan starts or `PostHook` after the migration is complete.
919923
+
920924
include::snip_vmware-name-change.adoc[]
925+
+
926+
[IMPORTANT]
927+
====
928+
{project-short} does not validate VM names generated by the templates described here. Migrations that include VMs whose names include uppercase letters fail automatically. To avoid failures, you might want to run a Go script that uses the `sprig` methods that {project-short} supports. For tables documenting the methods that {project-short} supports, see xref:mtv-template-utility_vmware[{project-short} template utility for {vmw} VM names].
929+
====
921930
endif::[]
922931

923932
ifdef::rhv[]

0 commit comments

Comments
 (0)