Skip to content

Commit c18193c

Browse files
committed
MTV-3443: MTV template methods
Signed-off-by: Richard Hoch <[email protected]>
1 parent 8bf6733 commit c18193c

File tree

5 files changed

+167
-6
lines changed

5 files changed

+167
-6
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
@@ -38,6 +38,8 @@ include::../modules/mtv-shared-disks-known-issues.adoc[leveloffset=+3]
3838

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

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

4345
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
@@ -221,7 +221,7 @@ Variable names cannot exceed 63 characters.
221221

222222
*** Click the *Edit* icon.
223223
*** Click *Enter custom naming template*.
224-
*** Enter the template according to the instructions.
224+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
225225
*** Click *Save*.
226226

227227
** To specify a different volume name template only for specific VMs, do the following:
@@ -230,13 +230,14 @@ Variable names cannot exceed 63 characters.
230230
*** Select the desired VMs.
231231
*** Click the {kebab} of the VM.
232232
*** Select *Edit Volume name template*.
233-
*** Enter the template according to the instructions.
233+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
234234
*** Click *Save*.
235235
+
236236
[IMPORTANT]
237237
====
238238
Changes you make on the *Virtual Machines* tab override any changes on the *Plan details* page.
239239
====
240+
+
240241
241242
.. *PVC name template*: Specifies a template for the name of the persistent volume claim (PVC) for the VMs in your plan.
242243
+
@@ -258,7 +259,7 @@ Variable names cannot exceed 63 characters.
258259

259260
*** Click the *Edit* icon.
260261
*** Click *Enter custom naming template*.
261-
*** Enter the template according to the instructions.
262+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
262263
*** Click *Save*.
263264

264265
** To specify a PVC name template only for specific VMs, do the following:
@@ -267,7 +268,7 @@ Variable names cannot exceed 63 characters.
267268
*** Select the desired VMs.
268269
*** Click the {kebab} of the VM.
269270
*** Select *Edit PVC name template*.
270-
*** Enter the template according to the instructions.
271+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
271272
*** Click *Save*.
272273
+
273274
[IMPORTANT]
@@ -295,7 +296,7 @@ Variable names cannot exceed 63 characters.
295296

296297
*** Click the *Edit* icon.
297298
*** Click *Enter custom naming template*.
298-
*** Enter the template according to the instructions.
299+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
299300
*** Click *Save*.
300301

301302
** To specify a different network name template only for specific VMs, do the following:
@@ -304,13 +305,18 @@ Variable names cannot exceed 63 characters.
304305
*** Select the desired VMs.
305306
*** Click the {kebab} of the VM.
306307
*** Select *Edit Network name template*.
307-
*** Enter the template according to the instructions.
308+
*** Enter the template according to the instructions. Be sure that your template does not generate VM names that include uppercase letters.
308309
*** Click *Save*.
309310
+
310311
[IMPORTANT]
311312
====
312313
Changes you make on the *Virtual Machines* tab override any changes on the *Plan details* page.
313314
====
315+
+
316+
[IMPORTANT]
317+
====
318+
{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].
319+
====
314320

315321
.. *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}.
316322

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,11 @@ The template follows the Go template syntax and has access to the following vari
933933
<26> Allowed values are `PreHook` before the migration plan starts or `PostHook` after the migration is complete.
934934
+
935935
include::snip_vmware-name-change.adoc[]
936+
+
937+
[IMPORTANT]
938+
====
939+
{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].
940+
====
936941
endif::[]
937942

938943
ifdef::rhv[]

0 commit comments

Comments
 (0)