### Apply Migration Manifest Example Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index An example of how to apply a Migration manifest using `oc apply -f -`. This demonstrates the basic structure of a Migration CR, including metadata and spec, which is essential for initiating a migration plan. ```yaml apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: ``` -------------------------------- ### Example Output for Rules Version Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This demonstrates the expected JSON output when retrieving the rules version. It confirms the structure of the response, showing the 'rules_version' key with its numerical value. ```json { "result": { "rules_version": 5 } } ``` ```json { "result": { "rules_version": 5 } } ``` -------------------------------- ### Query Inventory Service for Providers Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index Triggers an HTTP GET request to the Inventory service to retrieve a list of available providers. Requires the Inventory service route and an authorization token. ```bash curl -H "Authorization: Bearer $TOKEN" https:///providers -k ``` ```bash $ curl -H "Authorization: Bearer $TOKEN" https:///providers -k ``` -------------------------------- ### Go Template Examples for Volume Name Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-vmware Provides examples of Go template syntax for specifying volume name templates for virtual machines. These templates can include variables like the PVC name or volume index. Variable names are limited to 63 characters. ```Go Template "disk-{{.VolumeIndex}}" ``` ```Go Template "pvc-{{.PVCName}}" ``` -------------------------------- ### Example Inventory Service JSON Output Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This is an example of the JSON output received when querying the Inventory service for VM details. It includes attributes like 'input' (which contains inventory attributes for validation rules), 'networks', 'disks', 'cpuCount', 'memoryMB', and 'powerState'. ```json { "input": { "selfLink": "providers/vsphere/c872d364-d62b-46f0-bd42-16799f40324e/workloads/vm-431", "id": "vm-431", "parent": { "kind": "Folder", "id": "group-v22" }, "revision": 1, "name": "iscsi-target", "revisionValidated": 1, "isTemplate": false, "networks": [ { "kind": "Network", "id": "network-31" }, { "kind": "Network", "id": "network-33" } ], "disks": [ { "key": 2000, "file": "[iSCSI_Datastore] iscsi-target/iscsi-target-000001.vmdk", "datastore": { "kind": "Datastore", "id": "datastore-63" }, "capacity": 17179869184, "shared": false, "rdm": false }, { "key": 2001, "file": "[iSCSI_Datastore] iscsi-target/iscsi-target_1-000001.vmdk", "datastore": { "kind": "Datastore", "id": "datastore-63" }, "capacity": 10737418240, "shared": false, "rdm": false } ], "concerns": [], "policyVersion": 5, "uuid": "42256329-8c3a-2a82-54fd-01d845a8bf49", "firmware": "bios", "powerState": "poweredOn", "connectionState": "connected", "snapshot": { "kind": "VirtualMachineSnapshot", "id": "snapshot-3034" }, "changeTrackingEnabled": false, "cpuAffinity": [ 0, 2 ], "cpuHotAddEnabled": true, "cpuHotRemoveEnabled": false, "memoryHotAddEnabled": false, "faultToleranceEnabled": false, "cpuCount": 2, "coresPerSocket": 1, "memoryMB": 2048, "guestName": "Red Hat Enterprise Linux 7 (64-bit)", "balloonedMemory": 0, "ipAddress": "10.19.2.96", "storageUsed": 30436770129, "numaNodeAffinity": [ "0", "1" ], "devices": [ { "kind": "RealUSBController" } ], "host": { "id": "host-29", "parent": { "kind": "Cluster", "id": "domain-c26" }, "revision": 1, ``` -------------------------------- ### Create Subscription CR for MTV Operator using oc CLI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/installing-the-operator_mtv This command creates a Subscription custom resource to install the MTV Operator. It specifies the channel, approval strategy, source, and starting CSV version for the operator. ```bash cat << EOF | oc apply -f - apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: mtv-operator namespace: openshift-mtv spec: channel: release-v2.9 installPlanApproval: Automatic name: mtv-operator source: redhat-operators sourceNamespace: openshift-marketplace startingCSV: "mtv-operator.v2.9.4" EOF ``` ```bash $ cat << EOF | oc apply -f - apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: mtv-operator namespace: openshift-mtv spec: channel: release-v2.9 installPlanApproval: Automatic name: mtv-operator source: redhat-operators sourceNamespace: openshift-marketplace startingCSV: "mtv-operator.v2.9.4" EOF ``` -------------------------------- ### Create Migration Manifest with oc apply Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv Example command to apply a Migration manifest using `oc apply`. This snippet demonstrates how to define and apply a Kubernetes resource for the migration process. ```bash cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: EOF ``` -------------------------------- ### Example virt-v2v Debug Log Output for AIO Buffering Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/mtv-performance-recommendation_mtv Shows a snippet of the 'virt-v2v' debug logs indicating the successful configuration and application of AIO buffer settings, including buffer size calculation and session initialization flags. ```text Buffer size calc for 16 value: (16 * 64 * 1024 = 1048576) nbdkit: vddk[1]: debug: [NFC VERBOSE] NfcAio_OpenSession: Opening an AIO session. nbdkit: vddk[1]: debug: [NFC INFO] NfcAioInitSession: Disabling read-ahead buffer since the AIO buffer size of 1048576 is >= the read-ahead buffer size of 65536. Explicitly setting flag '`NFC_AIO_SESSION_NO_NET_READ_AHEAD`' bdkit: vddk[1]: debug: [NFC VERBOSE] NfcAioInitSession: AIO Buffer Size is 1048576 ``` -------------------------------- ### Example Migration Hook - Ansible Playbook Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv An example Ansible playbook for a migration hook. It includes tasks to set up SSH access by creating an SSH key from a secret, stopping the MariaDB service, and creating a file with migration details. This playbook is designed to be pasted into the web console's Ansible playbook text box. ```yaml - name: Main hosts: localhost vars_files: - plan.yml - workload.yml tasks: - k8s_info: api_version: v1 kind: Secret name: privkey namespace: openshift-mtv register: ssh_credentials - name: Ensure SSH directory exists file: path: ~/.ssh state: directory mode: 0750 - name: Create SSH key copy: dest: ~/.ssh/id_rsa content: "{{ ssh_credentials.resources[0].data.key | b64decode }}" mode: 0600 - add_host: name: "{{ vm.ipaddress }}" # ALT "{{ vm.guestnetworks[2].ip }}" ansible_user: root groups: vms - hosts: vms vars_files: - plan.yml - workload.yml tasks: - name: Stop MariaDB service: name: mariadb state: stopped - name: Create Test File copy: dest: /premigration.txt content: "Migration from {{ provider.source.name }} of {{ vm.vm1.vm0.id }} has finished\n" mode: 0644 ``` ```yaml - name: Main hosts: localhost vars_files: - plan.yml - workload.yml tasks: - k8s_info: api_version: v1 kind: Secret name: privkey namespace: openshift-mtv register: ssh_credentials - name: Ensure SSH directory exists file: path: ~/.ssh state: directory mode: 0750 - name: Create SSH key copy: dest: ~/.ssh/id_rsa content: "{{ ssh_credentials.resources[0].data.key | b64decode }}" mode: 0600 - add_host: name: "{{ vm.ipaddress }}" # ALT "{{ vm.guestnetworks[2].ip }}" ansible_user: root groups: vms - hosts: vms vars_files: - plan.yml - workload.yml tasks: - name: Stop MariaDB service: name: mariadb state: stopped - name: Create Test File copy: dest: /premigration.txt content: "Migration from {{ provider.source.name }} of {{ vm.vm1.vm0.id }} has finished\n" mode: 0644 ``` -------------------------------- ### Example Migration Hook - Ansible Playbook Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This Ansible playbook defines a pre-migration hook. It ensures SSH access by creating an SSH key, stops the MariaDB service, and creates a file at /premigration.txt on the target VM. It utilizes variables from plan.yml and workload.yml. ```yaml - name: Main hosts: localhost vars_files: - plan.yml - workload.yml tasks: - k8s_info: api_version: v1 kind: Secret name: privkey namespace: openshift-mtv register: ssh_credentials - name: Ensure SSH directory exists file: path: ~/.ssh state: directory mode: 0750 - name: Create SSH key copy: dest: ~/.ssh/id_rsa content: "{{ ssh_credentials.resources[0].data.key | b64decode }}" mode: 0600 - add_host: name: "{{ vm.ipaddress }}" # ALT "{{ vm.guestnetworks[2].ip }}" ansible_user: root groups: vms - hosts: vms vars_files: - plan.yml - workload.yml tasks: - name: Stop MariaDB service: name: mariadb state: stopped - name: Create Test File copy: dest: /premigration.txt content: "Migration from {{ provider.source.name }} of {{ vm.vm1.vm0.id }} has finished\n" mode: 0644 ``` -------------------------------- ### Go Template Examples for Network Name Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-vmware Demonstrates Go template syntax for network interface names within a migration plan. It supports variables for network name, namespace, type, and index, accommodating different network configurations like 'multus' or 'pod'. Variable names have a 63-character limit. ```Go Template "net-{{.NetworkIndex}}" ``` ```Go Template "{{if eq .NetworkType "pod"}}pod{{else}}multus-{{.NetworkIndex}}{{end}}" ``` -------------------------------- ### Example Output for Updated Rules Version Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This displays the expected JSON output after successfully updating the rules version. It shows the incremented 'rules_version' value, confirming the update. ```json { "result": { "rules_version": 6 } } ``` ```json { "result": { "rules_version": 6 } } ``` -------------------------------- ### Example must-gather Archive Structure Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/logs-and-crs_mtv This example demonstrates the typical directory structure of a must-gather archive generated for a VMware migration plan. It shows the organization of CR files and logs within namespaces, including DataVolume, VirtualMachine, and Plan CRs, as well as logs from various pods involved in the migration process. ```text must-gather └── namespaces ├── target-vm-ns │ ├── crs │ │ ├── datavolume │ │ │ ├── mig-plan-vm-7595-tkhdz.yaml │ │ │ ├── mig-plan-vm-7595-5qvqp.yaml │ │ │ └── mig-plan-vm-8325-xccfw.yaml │ │ └── virtualmachine │ │ ├── test-test-rhel8-2disks2nics.yaml │ │ └── test-x2019.yaml │ └── logs │ ├── importer-mig-plan-vm-7595-tkhdz │ │ └── current.log │ ├── importer-mig-plan-vm-7595-5qvqp │ │ └── current.log │ ├── importer-mig-plan-vm-8325-xccfw │ │ └── current.log │ ├── mig-plan-vm-7595-4glzd │ │ └── current.log │ └── mig-plan-vm-8325-4zw49 │ └── current.log └── openshift-mtv ├── crs │ └── plan │ └── mig-plan-cold.yaml └── logs ├── forklift-controller-67656d574-w74md │ └── current.log └── forklift-must-gather-api-89fc7f4b6-hlwb6 └── current.log ``` -------------------------------- ### Example Rego Query for Validation Rule Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv A Rego query used to define a validation rule. This example checks if a virtual machine has more than one disk attached, based on the 'disks' attribute provided by the 'Provider Inventory' service. ```Rego `count(input.numaNodeAffinity) != 0` ``` ```Rego `count(input.disks) > 1` ``` -------------------------------- ### Example virt-v2v Command with VDDk Config Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/mtv-performance-recommendation_mtv Illustrates how the 'virt-v2v' command utilizes the `--vddk-config` argument, pointing to the location of the AIO configuration file within the container. This is used for verification in migration pod logs. ```bash exec: /usr/bin/virt-v2v … --vddk-config /mnt/extra-v2v-conf/input.conf ``` -------------------------------- ### Trigger HTTP GET Request for Providers - Curl Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This Curl command sends an authenticated HTTP GET request to the Inventory service to retrieve a list of providers. It requires the access token and the Inventory service route. The '-k' flag allows for insecure connections, useful in testing environments. ```shell curl -H "Authorization: Bearer $TOKEN" https:///providers -k ``` -------------------------------- ### Example Output for Rules Version (JSON) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This shows the expected JSON output when retrieving the inventory rules version, indicating the current rules_version number. ```JSON { "result": { "rules_version": 5 } } ``` -------------------------------- ### Create openshift-mtv Project using oc CLI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/installing-the-operator_mtv This command creates a new Kubernetes project named 'openshift-mtv' using the 'oc apply' command with a YAML definition. It's a prerequisite for installing the MTV Operator. ```bash cat << EOF | oc apply -f - apiVersion: project.openshift.io/v1 kind: Project metadata: name: openshift-mtv EOF ``` ```bash $ cat << EOF | oc apply -f - apiVersion: project.openshift.io/v1 kind: Project metadata: name: openshift-mtv EOF ``` -------------------------------- ### Example Output for Updated Rules Version (JSON) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This shows the expected JSON output after updating the rules version, confirming the incremented rules_version number. ```JSON { "result": { "rules_version": 6 } } ``` -------------------------------- ### Go Template Examples for PVC Name Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-vmware Illustrates Go template syntax for defining persistent volume claim (PVC) names for virtual machines. Available variables include VM name, plan name, and disk index. Variable names are restricted to 63 characters. ```Go Template "{{.VmName}}-disk-{{.DiskIndex}}" ``` ```Go Template "{{if eq .DiskIndex .RootDiskIndex}}root{{else}}data{{end}}-{{.DiskIndex}}" ``` -------------------------------- ### View Validation Pod Log Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This command streams the logs of the `Validation` pod. It is used to verify that the `Validation` pod has started successfully after applying new rules or configuration changes. If the pod fails to start, the logs can help diagnose issues, such as conflicts with default rules. ```Shell oc logs -f ``` -------------------------------- ### Create Dockerfile for VDDK Image Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-per-provider_mtv This script creates a Dockerfile that defines the steps to build a VDDK image using a Red Hat Universal Base Image (UBI) minimal environment. It copies the VDDK distribution and prepares it for use. ```dockerfile FROM registry.access.redhat.com/ubi8/ubi-minimal USER 1001 COPY vmware-vix-disklib-distrib /vmware-vix-disklib-distrib RUN mkdir -p /opt ENTRYPOINT ["cp", "-r", "/vmware-vix-disklib-distrib", "/opt"] ``` ```dockerfile $ FROM registry.access.redhat.com/ubi8/ubi-minimal USER 1001 COPY vmware-vix-disklib-distrib /vmware-vix-disklib-distrib RUN mkdir -p /opt ENTRYPOINT ["cp", "-r", "/vmware-vix-disklib-distrib", "/opt"] ``` -------------------------------- ### Create Temporary Directory for VDDK Image Building Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-per-provider_mtv This command creates a temporary directory and navigates into it, preparing the environment for building a VDDK image. Ensure the file system preserves symbolic links. ```bash mkdir /tmp/ && cd /tmp/ ``` ```bash $ mkdir /tmp/ && cd /tmp/ ``` -------------------------------- ### Create StorageMap using YAML in MTV UI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This snippet demonstrates how to create a StorageMap resource using YAML definitions with the `oc apply -f -` command. It requires specifying API version, kind, metadata (name, namespace), and spec details including source and destination storage mappings and provider information. Ensure to replace placeholders like ``, ``, ``, ``, ``, ``, and `` with actual values. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` -------------------------------- ### Example Ansible Playbook for Migration Hook Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This is an example Ansible playbook that can be used as a migration hook. It demonstrates tasks such as retrieving SSH credentials from a Kubernetes Secret, creating an SSH directory, copying the SSH key, and adding a host. This playbook can be customized to perform various pre- or post-migration operations. ```yaml - name: Main hosts: localhost vars_files: - plan.yml - workload.yml tasks: - k8s_info: api_version: v1 kind: Secret name: privkey namespace: openshift-mtv register: ssh_credentials - name: Ensure SSH directory exists file: path: ~/.ssh state: directory mode: 0750 - name: Create SSH key copy: dest: ~/.ssh/id_rsa content: "{{ ssh_credentials.resources[0].data.key | b64decode }}" mode: 0600 - add_host: ``` -------------------------------- ### Create a Migration CR to run a Plan Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv This snippet demonstrates how to create a `Migration` Custom Resource (CR) to initiate a virtual machine migration based on a previously defined `Plan` CR. It includes specifying the plan's name and namespace, and an optional cutover time in ISO 8601 format. ```yaml apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: namespace: spec: plan: name: namespace: cutover: ``` -------------------------------- ### Download Migration Logs from OpenShift Web Console Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This section describes the manual process of downloading logs for migration plans or individual virtual machines directly from the Red Hat OpenShift web console. No code is involved, but it outlines the UI steps. -------------------------------- ### Get Pod YAML Configuration (OpenShift CLI) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/mtv-performance-recommendation_mtv Fetches the complete YAML configuration of a specified pod in the 'openshift-mtv' namespace. This is used to inspect environment variables and other pod settings. ```bash oc get pod forklift-controller-667f57c8f8-qllnx -n openshift-mtv -o yaml ``` -------------------------------- ### Build VDDK Container Image using Podman Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-per-provider_mtv This command builds the Dockerfile into a container image using Podman. Replace `` and `` with your specific registry details and desired tag for the image. ```bash podman build . -t /vddk: ``` ```bash $ podman build . -t /vddk: ``` -------------------------------- ### Extract VDDK Archive for Image Building Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-per-provider_mtv This command extracts the downloaded VDDK archive file. Make sure to replace `` with the actual version number of the VDDK you downloaded. This step is crucial for accessing the VDDK components. ```bash tar -xzf VMware-vix-disklib-.x86_64.tar.gz ``` ```bash $ tar -xzf VMware-vix-disklib-.x86_64.tar.gz ``` -------------------------------- ### Get forklift-controller Pod Name (OpenShift CLI) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/mtv-performance-recommendation_mtv Retrieves the name of the forklift-controller pod in the 'openshift-mtv' namespace. This command is useful for identifying the dynamic pod name needed for subsequent operations. ```bash oc get pods -n openshift-mtv | grep forklift-controller | awk '{print $1}' ``` -------------------------------- ### Push VDDK Container Image to Registry Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-per-provider_mtv This command pushes the newly built VDDK container image to your specified container registry. Ensure you have authenticated with the registry prior to execution. Replace placeholders with your registry path and tag. ```bash podman push /vddk: ``` ```bash $ podman push /vddk: ``` -------------------------------- ### Create OperatorGroup CR using oc CLI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/installing-the-operator_mtv This command creates an OperatorGroup custom resource named 'migration' within the 'openshift-mtv' namespace. This resource defines the strategy for how operators are installed and managed. ```bash cat << EOF | oc apply -f - apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: migration namespace: openshift-mtv spec: targetNamespaces: - openshift-mtv EOF ``` ```bash $ cat << EOF | oc apply -f - apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: migration namespace: openshift-mtv spec: targetNamespaces: - openshift-mtv EOF ``` -------------------------------- ### Create Plan Manifest for VM Migration Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This code snippet shows the creation of a Plan manifest, which defines the parameters for a virtual machine migration. It includes source and destination provider details, network and storage map references, the target namespace, and a list of VMs to migrate, with options for specifying hooks for individual VMs. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Plan metadata: name: namespace: spec: provider: source: name: namespace: destination: name: namespace: map: network: name: namespace: storage: name: namespace: targetNamespace: vms: - id: - name: hooks: - hook: namespace: name: step: EOF ``` -------------------------------- ### Dockerfile for Creating VDDK Image Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This Dockerfile defines the steps to create a VDDK image using a minimal UBI image. It copies the extracted VDDK distribution into the image and sets an entrypoint to ensure the files are available in the `/opt` directory upon container startup. This image is essential for MTV when migrating VMware vSphere virtual disks. ```dockerfile FROM registry.access.redhat.com/ubi8/ubi-minimal USER 1001 COPY vmware-vix-disklib-distrib /vmware-vix-disklib-distrib RUN mkdir -p /opt ENTRYPOINT ["cp", "-r", "/vmware-vix-disklib-distrib", "/opt"] ``` ```dockerfile $ cat > Dockerfile <", "namespace": "" }, "spec": { "map": [ { "destination": { "storageClass": "", "accessMode": "" }, "source": { "id": "" } } ], "provider": { "source": { "name": "", "namespace": "" }, "destination": { "name": "", "namespace": "" } } } } EOF ``` -------------------------------- ### Generate OpenStack Token and Get Credentials Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-per-provider_mtv This command retrieves an OpenStack token and associated authentication details. The output is essential for configuring token-based authentication with OpenStack source providers in MTV. It requires an active OpenStack session. ```bash openstack token issue ``` ```bash $ openstack token issue ``` -------------------------------- ### Create StorageMap using JSON definition in MTV UI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This snippet illustrates creating an ownerless StorageMap using a JSON definition within the Migration Toolkit for Virtualization (MTV) UI. It leverages the oc client for applying the configuration. The JSON structure specifies the map details, including source and destination providers and storage configurations. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` -------------------------------- ### Create StorageMap using YAML definition in MTV UI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-osp_ostack This snippet demonstrates how to create a StorageMap resource using a YAML definition applied via the `oc apply` command. It defines the source and destination storage configurations for migration. Ensure the `apiVersion` and `kind` are correct for your MTV version. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` -------------------------------- ### Create and Apply Plan CR using oc apply Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This snippet demonstrates how to define and apply a `Plan` Custom Resource (CR) using the `oc apply -f -` command. The Plan CR is essential for defining the migration strategy, including source and destination providers, network and storage maps, and the specific virtual machines to be migrated. It also supports specifying hooks for pre-migration and post-migration actions. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Plan metadata: name: spec: warm: false provider: source: name: namespace: destination: name: namespace: map: network: name: namespace: storage: name: namespace: targetNamespace: vms: - id: - name: hooks: - hook: namespace: name: step: EOF ``` -------------------------------- ### Monitor Migration Progress After Cancellation (OpenShift CLI) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv This command retrieves the `Migration` custom resource (CR) to monitor the progress of the remaining VMs after specific cancellations have been applied. It uses `oc get migration/` to fetch the resource in YAML format. ```openshiftcli oc get migration/ -n -o yaml ``` ```openshiftcli $ oc get migration/ -n -o yaml ``` -------------------------------- ### Create a Migration Custom Resource using oc apply Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv This snippet demonstrates how to create a Migration custom resource (CR) using the `oc apply` command with a heredoc. It requires specifying the names of the migration and plan CRs, the namespace, and an optional cutover time in ISO 8601 format. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: namespace: spec: plan: name: namespace: cutover: EOF ``` -------------------------------- ### Monitor Validation Pod Logs Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This command streams the logs of the validation pod. It's used to verify that the Validation pod has started successfully after applying new rules or configurations. ```Shell oc logs -f ``` ```Shell $ oc logs -f ``` -------------------------------- ### Create StorageMap Manifest for Storage Mapping Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv Defines a StorageMap to map source and destination storage. It specifies storage class, access mode, source volume type, and provider details for both source and destination. Required parameters include storage class, access mode, source volume type, and provider names/namespaces. ```yaml apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` -------------------------------- ### Cancel Specific VMs Migration using CLI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv This example illustrates how to cancel the migration of specific virtual machines by adding them to the `spec.cancel` block of the `Migration` manifest. VMs can be identified by their `id` or `name`. The `id` can be a managed object reference for VMware or a VM UUID for RHV. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: namespace: ... spec: cancel: - id: vm-102 - id: vm-203 name: rhel8-vm EOF ``` ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: namespace: ... spec: cancel: - id: vm-102 EOF ``` -------------------------------- ### Cancel Specific VMs in Migration CR Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv Modifies the `Migration` manifest to include a `spec.cancel` block, specifying individual VMs to be excluded from the migration. VMs can be identified by their `id` or `name`. After applying the updated manifest, monitor the remaining VMs using `oc get migration`. ```yaml cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: namespace: spec: cancel: - id: vm-102 - id: vm-203 name: rhel8-vm EOF ``` ```yaml cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: namespace: spec: cancel: - id: vm-102 EOF ``` -------------------------------- ### Create Storage Map with YAML Definition Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-vmware This code snippet demonstrates how to create a StorageMap using YAML definitions applied via the `oc apply` command. It configures the source and destination providers, source datastore, and target storage class. Ensure that the `accessMode` is set to either `ReadWriteOnce` or `ReadWriteMany`, and provide the correct VMware vSphere datastore moRef for the `id` field. ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` -------------------------------- ### Windows VM VSS Error Message Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/prerequisites-for-all-providers_mtv This code snippet displays a common error message encountered when migrating Windows VMs without Volume Shadow Copy Service (VSS) enabled. It highlights the failure in snapshot creation during a warm migration if VSS is not properly started. ```text An error occurred while taking a snapshot: Failed to restart the virtual machine An error occurred while taking a snapshot: Failed to restart the virtual machine ``` -------------------------------- ### Create StorageMap using YAML definition in MTV UI Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-rhv_rhv This snippet demonstrates how to create a StorageMap using YAML definition within the Migration Toolkit for Virtualization (MTV) UI. It requires OpenShift CLI (oc) and specifies the API version, kind, metadata, and spec for the StorageMap, including source and destination provider details. Ensure correct values for placeholders like , , , , , , and . ```bash $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: EOF ``` -------------------------------- ### Example Rego Query for NUMA Node Affinity Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This snippet shows a Rego query used to check if a virtual machine has NUMA node affinity configured. It leverages the input attribute `numaNodeAffinity` provided by the Provider Inventory service. This query is intended to be part of a `forklift-validation-config` config map. ```Rego `count(input.numaNodeAffinity) != 0` ``` -------------------------------- ### Scale Up Forklift Controller Deployment Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This command scales up the `forklift-controller` deployment to 1 replica in the `openshift-mtv` namespace. This action restarts the `Validation` pod, enabling it to load the newly applied validation rules from the ConfigMap. ```Shell oc scale -n openshift-mtv --replicas=1 deployment/forklift-controller ``` -------------------------------- ### Virtual Machine Resource Configuration Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index Details the CPU and memory settings for the virtual machine, including counts, hot-add/remove capabilities, and affinity settings. ```json { "policyVersion": 5, "uuid": "42256329-8c3a-2a82-54fd-01d845a8bf49", "firmware": "bios", "powerState": "poweredOn", "connectionState": "connected", "snapshot": { "kind": "VirtualMachineSnapshot", "id": "snapshot-3034" }, "changeTrackingEnabled": false, "cpuAffinity": [ 0, 2 ], "cpuHotAddEnabled": true, "cpuHotRemoveEnabled": false, "memoryHotAddEnabled": false, "faultToleranceEnabled": false, "cpuCount": 2, "coresPerSocket": 1, "memoryMB": 2048, "guestName": "Red Hat Enterprise Linux 7 (64-bit)", "balloonedMemory": 0, "ipAddress": "10.19.2.96", "storageUsed": 30436770129, "numaNodeAffinity": [ "0", "1" ], "devices": [ { "kind": "RealUSBController" } ] } ``` -------------------------------- ### Retrieve Current Inventory Rules Version (HTTP) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/advanced-migration-options_mtv This snippet shows how to retrieve the current inventory rules version using an HTTP GET request. It is essential for understanding the current state before making updates. ```HTTP GET https://forklift-validation/v1/data/io/konveyor/forklift//rules_version ``` ```Shell $ GET https://forklift-validation/v1/data/io/konveyor/forklift//rules_version ``` -------------------------------- ### Windows VM Warm Migration VSS Quiescing Error Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This code snippet illustrates a common error encountered during warm migration of Windows virtual machines when Volume Shadow Copy Service (VSS) is not properly started or configured. It highlights the failure to create a snapshot due to VSS issues. ```text An error occurred while taking a snapshot: Failed to restart the virtual machine ``` -------------------------------- ### Create NetworkMap Manifest Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index Creates a Kubernetes NetworkMap manifest to define the mapping between source and destination networks for the migration process. ```yaml apiVersion: forklift.konveyor.io/v1beta1 kind: NetworkMap metadata: name: namespace: ``` -------------------------------- ### Create a Migration Hook Custom Resource (YAML/Shell) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index This snippet demonstrates how to create a Migration Toolkit for Virtualization (MTV) Hook Custom Resource (CR) using the 'oc apply' command. It defines the hook's image, service account, and a base64-encoded Ansible playbook. The playbook will be executed during the migration process. ```shell $ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Hook metadata: name: namespace: spec: image: quay.io/kubev2v/hook-runner serviceAccount: playbook: | LS0tCi0gbm... EOF ``` -------------------------------- ### Create vSphere Host Manifest Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index Creates a Kubernetes Host manifest to represent the vSphere source host. This manifest links to the Provider, specifies the host's Managed Object Reference (moRef), and the IP address of the migration network. ```yaml apiVersion: forklift.konveyor.io/v1beta1 kind: Host metadata: name: namespace: spec: provider: namespace: name: id: ipAddress: EOF ``` -------------------------------- ### Configure Plan CR to Migrate Shared Disks (YAML) Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv This example demonstrates how to configure a `Plan` custom resource (CR) in MTV to migrate shared disks. Setting `migrateSharedDisks` to `true` instructs MTV to include shared disks in the migration process. This is typically the first step in a two-plan migration strategy for VMs with shared disks. ```YAML apiVersion: forklift.konveyor.io/v1beta1 kind: Plan name: transfer-shared-disks namespace: openshift-mtv spec: map: network: ``` -------------------------------- ### Create StorageMap Manifest for VM Migration Source: https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.9/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-virtual-machines-from-the-command-line_mtv This manifest maps source datastores to destination storage classes and access modes for virtual machine migrations. It requires the source datastore ID, destination storage class, and access mode. Allowed access modes are 'ReadWriteOnce' and 'ReadWriteMany'. ```yaml apiVersion: forklift.konveyor.io/v1beta1 kind: StorageMap metadata: name: namespace: spec: map: - destination: storageClass: accessMode: source: id: provider: source: name: namespace: destination: name: namespace: ```