-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_roaming_migration.sh
More file actions
65 lines (55 loc) · 1.99 KB
/
Copy pathstart_roaming_migration.sh
File metadata and controls
65 lines (55 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Script to start a roaming migration workflow instance
# This script sends a POST request to Camunda to start the cloud-host-roaming-workflow
# Configuration
CAMUNDA_BASE_URL="${CAMUNDA_BASE_URL:-http://localhost:8080/engine-rest}"
CAMUNDA_USERNAME="${CAMUNDA_USERNAME:-admin}"
CAMUNDA_PASSWORD="${CAMUNDA_PASSWORD:-admin}"
WORKFLOW_ID="cloud-host-roaming-workflow"
# Host ID to migrate (can be passed as argument or use default)
HOST_ID="${1:-test-host-$(date +%s)}"
echo "=========================================="
echo "Starting Roaming Migration Workflow"
echo "=========================================="
echo "Camunda Base URL: $CAMUNDA_BASE_URL"
echo "Workflow ID: $WORKFLOW_ID"
echo "Host ID: $HOST_ID"
echo ""
# Create the JSON payload for workflow start
PAYLOAD='{
"variables": {
"hostId": {
"value": "'$HOST_ID'",
"type": "String"
}
}
}'
echo "Sending request to Camunda..."
echo ""
# Send the request to start the workflow
RESPONSE=$(curl -s -X POST \
-H "Content-Type: application/json" \
-u "$CAMUNDA_USERNAME:$CAMUNDA_PASSWORD" \
-d "$PAYLOAD" \
"$CAMUNDA_BASE_URL/process-definition/key/$WORKFLOW_ID/start")
# Parse and display the response
echo "Response:"
echo "$RESPONSE" | jq '.' 2>/dev/null || echo "$RESPONSE"
# Extract the process instance ID if successful
PROCESS_INSTANCE_ID=$(echo "$RESPONSE" | jq -r '.id' 2>/dev/null)
if [ -n "$PROCESS_INSTANCE_ID" ] && [ "$PROCESS_INSTANCE_ID" != "null" ]; then
echo ""
echo "=========================================="
echo "✓ Workflow started successfully!"
echo "=========================================="
echo "Process Instance ID: $PROCESS_INSTANCE_ID"
echo "Host to migrate: $HOST_ID"
echo ""
echo "You can monitor the workflow at:"
echo " Camunda Cockpit: $CAMUNDA_BASE_URL/../app/cockpit/"
echo " Process Instance: $CAMUNDA_BASE_URL/../app/cockpit/#/process-instance/$PROCESS_INSTANCE_ID"
else
echo ""
echo "✗ Failed to start workflow!"
exit 1
fi