Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This repository contains multiple workflows. Each workflow is represented by a d
| `move2kube` | Workflow for Move2Kube tasks and transformation. |
| `mta-v7.x` | Migration toolkit for applications, version 7.x. |
| `mtv-migration` | Migration tasks using Migration Toolkit for Virtualization (MTV). |
| `mtv-plan` | Planning workflows for Migration Toolkit for Virtualization. |
| `request-vm-cnv` | Requests and provisions VMs using Container Native Virtualization (CNV). |

Each workflow is organized in its own directory, containing the following components:
Expand Down
48 changes: 43 additions & 5 deletions workflows/mtv-migration/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
> **🚨 Deprecation Notice: 🚨**
> From Orchestrator release version 1.7, Workflow Types will be retired. All workflows will act as infrastructure workflows, and no workflow will act as an assesment workflow. <br>
> This workflow is a continuation of an assessment workflow. Therfore, that workflow will be obsolete and won't server as a perliminary to this one.
> This workflow is a continuation of an assessment workflow. Therfore, that workflow will be obsolete and won't server as a perliminary to this one. See [examples](#how-to-run).

# MTV migration workflow - MTV Migration execution workflow
This workflow is a continuation of the MTV assessment workflow. It executes an MTV Plan and waits for its final condition. Final condition is either success or failure. It is important to note that we rely on MTV to reach a final state. We do not impose our own timeout.
[MTV Migration Plan documentation](https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.6/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-vms-web-console_mtv#creating-migration-plans-ui)
This workflow creates an MTV Plan and an MTV Migration. It waits for the final condition of each resource. Final condition is either success or failure. It is important to note that we rely on MTV to reach a final state. We do not impose our own timeout.
[MTV Migration Plan documentation](https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.6/html/installing_and_using_the_migration_toolkit_for_virtualization/migrating-vms-web-console_mtv#creating-migration-plans-ui)
It is possible to execute just one of the stages: Plan or Migrate. The input variable `operation` determines whether to perform just one of the stages or perform both (sequentially).

## Prerequisite
* Access to an OCP cluster with MTV operator (Openshift Migration Toolkit for Virtualization) installed. The cluster credentials must allow creating the resources listed above.
Expand All @@ -27,10 +28,47 @@ Application properties can be initialized from environment variables before runn
See [official installation guide](https://github.com/rhdhorchestrator/serverless-workflows/blob/main/deploy/docs/main/mtv-migration)

## How to run
Example of POST to trigger the flow (see input schema [mtv-input.json](./schema/mtv-input.json)):
Example of POST to trigger Plan and Migrate (see input schema [mtv-input.json](./schema/mtv-input.json)):
```bash
curl -X POST -H "Content-Type: application/json" http://localhost:8080/mtv-plan -d '{
"migrationName": "my-vms",
"migrationNamespace": "openshift-mtv",
"operation": "PLAN_AND_MIGRATE",
"sourceProvider": "vmware",
"destinationProvider": "host",
"storageMap": "vmware-z976z",
"networkMap": "vmware-zqpl7",
"vms": [
{
"name": "haproxy",
"id": "vm-5932"
}
]
}'
```
Example of POST to trigger just Migrate (see input schema [mtv-input.json](./schema/mtv-input.json)):
```bash
curl -X POST -H "Content-Type: application/json" http://localhost:8080/mtv-migration -d '{
"migrationName": "my-vms",
"migrationNamespace": "openshift-mtv"
"migrationNamespace": "openshift-mtv",
"operation": "MIGRATE"
}'
```
Example of POST to trigger just Plan (see input schema [mtv-input.json](./schema/mtv-input.json)):
```bash
curl -X POST -H "Content-Type: application/json" http://localhost:8080/mtv-plan -d '{
"migrationName": "my-vms",
"migrationNamespace": "openshift-mtv",
"operation": "PLAN",
"sourceProvider": "vmware",
"destinationProvider": "host",
"storageMap": "vmware-z976z",
"networkMap": "vmware-zqpl7",
"vms": [
{
"name": "haproxy",
"id": "vm-5932"
}
]
}'
```
2 changes: 1 addition & 1 deletion workflows/mtv-migration/mtv.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 147 additions & 23 deletions workflows/mtv-migration/mtv.sw.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
specVersion: "0.8"
id: mtv-migration
version: '1.0'
version: "1.0"
name: MTV migration workflow
description: workflow executes a plan by creating a migration and waiting for it to be successful or failed
annotations:
Expand All @@ -12,41 +12,165 @@ extensions:
- extensionid: workflow-uri-definitions
definitions:
notifications: "https://raw.githubusercontent.com/rhdhorchestrator/serverless-workflows/main/workflows/shared/specs/notifications-openapi.yaml"
start: CreateMigration
start: SelectOperation
functions:
- name: createNotification
operation: notifications#createNotification
- name: createPlan
type: rest
operation: "specs/mtv.yaml#createPlan"
- name: getPlan
type: rest
operation: "specs/mtv.yaml#getPlan"
- name: createMigration
type: rest
operation: 'specs/mtv.yaml#createMigration'
operation: "specs/mtv.yaml#createMigration"
- name: getMigration
type: rest
operation: 'specs/mtv.yaml#getMigration'
operation: "specs/mtv.yaml#getMigration"
- name: getPlanError
type: expression
operation: .getStatusResult.status.conditions | map(select(.category == "Error" or .category == "Critical"))[0].message
- name: getMigrationError
type: expression
operation: .getStatusResult.status.conditions | map(select(.category == "Error" or .category == "Critical" or .type == "Failed"))[0].message
- name: successResult
- name: successMigrate
type: expression
operation: '{
"result": {
"message": "MTV migration " + .migrationName + " succeeded",
"outputs":[]
}
"result": {
"message": "MTV migration " + .migrationName + " succeeded",
"outputs":[]
}
}'
- name: errorResult
- name: errorMigrate
type: expression
operation: '{
"result": {
"message": "MTV migration " + .migrationName + " failed.",
"outputs":[
{
"key":"Error",
"value": .migrationErrorMessage
}
]
}
"result": {
"message": "MTV migration " + .migrationName + " failed.",
"outputs":[
{
"key":"Error",
"value": .migrationErrorMessage
}
]
}
}'
states:
- name: SelectOperation
type: switch
dataConditions:
- name: JustMigrate
condition: .operation == "MIGRATE"
transition: CreateMigration
defaultCondition:
transition: CreatePlan
- name: CreatePlan
type: operation
actions:
- functionRef:
refName: createPlan
arguments:
namespace: .migrationNamespace
apiVersion: "forklift.konveyor.io/v1beta1"
kind: Plan
metadata:
name: .migrationName
namespace: .migrationNamespace
spec:
map:
network:
name: .networkMap
namespace: .migrationNamespace
storage:
name: .storageMap
namespace: .migrationNamespace
provider:
destination:
name: .destinationProvider
namespace: .migrationNamespace
source:
name: .sourceProvider
namespace: .migrationNamespace
targetNamespace: .migrationNamespace
vms: .vms
transition: GetPlan
- name: GetPlan
type: operation
actions:
- name: getPlan
actionDataFilter:
toStateData: .getStatusResult
functionRef:
refName: getPlan
arguments:
namespace: .migrationNamespace
plan: .migrationName
sleep:
before: PT10S
transition: CheckPlanStatus
- name: CheckPlanStatus
type: switch
dataConditions:
- name: PlanFailure
condition: .getStatusResult.status.conditions | map(select(.category == "Error" or .category == "Critical")) | length > 0
transition: PlanFailure
- name: PlanReady
condition: .getStatusResult.status.conditions | map(select(.type == "Ready")) | length > 0
transition: NextOperation
defaultCondition:
transition:
nextState: GetPlan
- name: PlanFailure
type: operation
metadata:
errorMessage: '"MTV plan " + .migrationName + " is not ready for migration"'
actions:
- name: setPlanErrorMessage
actionDataFilter:
toStateData: .planErrorMessage
functionRef:
refName: getPlanError
- name: createNotification
functionRef:
refName: createNotification
arguments:
recipients:
type: "entity"
entityRef: .recipients
payload:
title: "MTV plan is not ready for migration"
description: '"MTV plan " + .migrationName + " is not ready for migration. Error: " + .planErrorMessage'
topic: "MTV plan assessment workflow"
severity: "critical"
stateDataFilter:
output: "{result: {message: .planErrorMessage}}"
end: true
- name: PlanReady
type: operation
actions:
- name: createNotification
functionRef:
refName: createNotification
arguments:
recipients:
type: "entity"
entityRef: .recipients
payload:
title: "MTV plan is ready for migration"
description: '"MTV plan " + .migrationName + " is ready for migration"'
topic: "MTV plan assessment workflow"
severity: "normal"
stateDataFilter:
output: '{result: {message: "MTV plan successful", "outputs": [] }}'
end: true
- name: NextOperation
type: switch
dataConditions:
- name: Migrate
condition: .operation == "PLAN_AND_MIGRATE"
transition: CreateMigration
defaultCondition:
transition: PlanReady
- name: CreateMigration
type: operation
actions:
Expand Down Expand Up @@ -93,7 +217,7 @@ states:
- name: MigrationFailure
type: operation
metadata:
errorMessage: '"MTV migration " + .migrationName + " failed"'
errorMessage: '"MTV migration " + .migrationName + " failed"'
actions:
- name: setMigrationErrorMessage
actionDataFilter:
Expand All @@ -114,7 +238,7 @@ states:
severity: "critical"
- name: setOutput
functionRef:
refName: errorResult
refName: errorMigrate
end: true
- name: MigrationSuccessful
type: operation
Expand All @@ -133,5 +257,5 @@ states:
severity: "normal"
- name: setOutput
functionRef:
refName: successResult
end: true
refName: successMigrate
end: true
42 changes: 42 additions & 0 deletions workflows/mtv-migration/schemas/mtv-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,48 @@
"type": "string",
"pattern": "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
},
"operation": {
"type": "string",
"enum": [
"PLAN,MIGRATE,PLAN_AND_MIGRATE"
],
"description": "create a plan and then migrate or perform just one of the two stages"
},
"sourceProvider": {
"type": "string",
"pattern": "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
},
"destinationProvider": {
"type": "string",
"pattern": "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
},
"storageMap": {
"type": "string",
"pattern": "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
},
"networkMap": {
"type": "string",
"pattern": "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
},
"vms": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"name",
"id"
]
},
"minItems": 1
},
"recipients": {
"type": "array",
"items": {
Expand Down
47 changes: 0 additions & 47 deletions workflows/mtv-plan/README.md

This file was deleted.

Loading