-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm-single-provisioning-with-output
More file actions
executable file
·89 lines (71 loc) · 2.15 KB
/
vm-single-provisioning-with-output
File metadata and controls
executable file
·89 lines (71 loc) · 2.15 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# ===============================================
# 🔧 OpenShift VM Template Provisioner
# ===============================================
# Namespace where templates are located
NAMESPACE="uat-infra-tools"
# List of available templates
declare -A templates
templates=(
["1"]="centos-stream9-desktop"
["2"]="rhel8-desktop"
["3"]="windows2k22-vm-template"
["4"]="windows2k25"
)
echo "==============================================="
echo " 🔧 OpenShift VM Template Provisioner"
echo "==============================================="
echo ""
echo "Select a template to provision:"
echo "1) CentOS Stream 9 Desktop"
echo "2) RHEL 8 Desktop"
echo "3) Windows Server 2022 (Template)"
echo "4) Windows Server 2025"
echo ""
read -p "Enter your choice [1-4]: " choice
# Validate input
if [[ -z "${templates[$choice]}" ]]; then
echo "❌ Invalid choice. Exiting."
exit 1
fi
TEMPLATE=${templates[$choice]}
# Ask for VM name
read -p "Enter VM name: " VM_NAME
if [[ -z "$VM_NAME" ]]; then
echo "❌ VM name cannot be empty."
exit 1
fi
echo ""
echo "==============================================="
echo " You have selected:"
echo " Template: $TEMPLATE"
echo " VM Name: $VM_NAME"
echo " Namespace: $NAMESPACE"
echo "==============================================="
echo ""
read -p "Proceed with provisioning? (y/n): " confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
echo "❌ Operation cancelled."
exit 0
fi
# Run the OpenShift commands
echo "🚀 Provisioning VM from template..."
oc process -n "$NAMESPACE" "$TEMPLATE" NAME="$VM_NAME" | oc apply -f -
if [[ $? -ne 0 ]]; then
echo "❌ Failed to create VM. Please check the logs."
exit 1
fi
# Wait for a few seconds before showing VM status
echo ""
echo "⏳ Waiting for VM to appear..."
sleep 5
echo ""
echo "==============================================="
echo "📦 VM List:"
oc get vm -n "$NAMESPACE" | grep "$VM_NAME" || echo "⚠️ VM not found yet."
echo ""
echo "==============================================="
echo "🧩 VMI List (VirtualMachineInstances):"
oc get vmi -n "$NAMESPACE" | grep "$VM_NAME" || echo "⚠️ No VMI created yet."
echo ""
echo "✅ Done."