/rh-virt:vm-clonefrom rh-virt
Clone existing virtual machines for testing, scaling, or creating templates. Use when: - "Clone VM [source] to [target]" - "Create a copy of VM [name]" - "Duplicate VM [name] for testing" - "Create 3 copies of template-vm" This skill clones VM configuration and optionally creates new storage or references existing storage. NOT for snapshots (use vm-snapshot for point-in-time backups).
Ships in rh-virt. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Clone existing virtual machines in OpenShift Virtualization, creating new VMs with copied configuration and optional storage cloning. This skill is ideal for creating test environments, scaling workloads, or duplicating VM templates.
Required MCP Server: openshift-virtualization (OpenShift MCP Server)
Required MCP Tools:
resources_get (from openshift-virtualization) - Get source VM configurationresources_create_or_update (from openshift-virtualization) - Create cloned VMresources_list (from openshift-virtualization) - List DataVolumes, PVCs, VMsRequired Environment Variables:
KUBECONFIG - Path to Kubernetes configuration file with cluster accessRequired Cluster Setup:
Before executing:
openshift-virtualization in mcps.json, KUBECONFIG set (never expose value)Human Notification Protocol: ❌ Cannot execute vm-clone: MCP server 'openshift-virtualization' is not available. Setup: Add to mcps.json, set KUBECONFIG, restart Claude Code. Docs: https://github.com/openshift/openshift-mcp-server
⚠️ SECURITY: Never display KUBECONFIG path or credential values.
Trigger this skill when:
/vm-clone commandUser phrases that trigger this skill:
Do NOT use this skill when:
/vm-create skill insteadRequired Information from User:
If user doesn't provide all information, ask for missing details.
1.1: Verify Source VM Exists
MCP Tool: resources_get (from openshift-virtualization)
Parameters:
{
"apiVersion": "kubevirt.io/v1",
"kind": "VirtualMachine",
"namespace": "<source-namespace>",
"name": "<source-vm-name>"
}
Expected Output: Complete VirtualMachine resource specification
Error Handling:
1.2: Check Target VM Name Availability
MCP Tool: resources_get (from openshift-virtualization)
Parameters:
{
"apiVersion": "kubevirt.io/v1",
"kind": "VirtualMachine",
"namespace": "<target-namespace>",
"name": "<target-vm-name>"
}
If VM exists: Offer options (choose different name, delete existing VM, cancel), wait for decision
1.3: Discover Source VM Storage
Use resources_list for DataVolumes (labelSelector: vm.kubevirt.io/name) or PVCs if not found
Parse: Extract storage names, calculate size, determine DataSources vs container disks
Present storage cloning options:
## VM Cloning - Storage Strategy
**Source VM**: `<source-vm-name>` (namespace: `<source-namespace>`)
**Source Storage**: <source-disk> (<size>)
**Select cloning strategy:**
1. **Clone Storage** - Full copy, independent storage (~5-10 min, <size> new allocation)
2. **Reference Existing** - ⚠️ Shared disk (dangerous, both VMs access same storage)
3. **New Empty Storage** - Fresh disk, no data copied (<size> new allocation)
4. **Cancel** - Abort operation
**Select option (1-4):**
Wait for user selection (1-4).
Handle response: "4"/cancel → stop; "1" → clone_storage=true; "2" → warn + share_storage=true; "3" → new_storage=true
Option 2 warning: ⚠️ Shared Storage Dangerous - Both VMs share disk, data corruption risk. Only safe if source stopped. Use Option 1 instead. Proceed anyway? (yes/cancel) Wait for explicit "yes".
3.0: Check ResourceQuota (before presenting confirmation)
Use resources_list (apiVersion="v1", kind="ResourceQuota", namespace=<target-namespace>) to check if quotas exist. If a quota is found, compare current usage against limits for CPU, memory, and storage. If the clone would push usage above 80% of any limit, include a warning in the confirmation summary.
Present configuration summary:
## VM Clone Configuration - Review
**Source**: `<source-vm-name>` (<source-namespace>) - <instance-type>, <cpu> vCPU, <memory>
**Target**: `<target-vm-name>` (<target-namespace>) - Same config, starts Stopped
**Storage**: <strategy-description> - <size> <allocation-details>
**Resource Impact**: <cpu> vCPU, <memory> RAM, <storage> disk
**What changes**: IP addresses, hostname, MAC addresses, firmware UUID
**What's preserved**: Instance type, vCPU/memory, network config, cloud-init
**Proceed with VM cloning? (yes/no)**
Wait for user confirmation.
Handle response:
On cancellation:
VM cloning cancelled by user. No resources were created.
STOP workflow.
ONLY PROCEED AFTER: Source VM validated, target name available, user selected storage strategy, user confirmed configuration
4.1: Prepare Cloned VM Specification
Modify source VM spec:
name → target-vm-name, namespace → target-namespace; remove uid, resourceVersion, creationTimestamp, statusrunStrategy: Halted (starts stopped)domain.firmware.uuid, domain.firmware.serial)4.2: Create Storage Resources
Clone storage - Use resources_create_or_update with DataVolume (source.pvc from source, storage from source class/size)
New empty storage - Use resources_create_or_update with DataVolume (source.blank, storage from source class/size)
4.3: Create Cloned VirtualMachine
Use resources_create_or_update with prepared spec from 4.1
Error handling: Creation fails → report error, rollback storage; permission denied → RBAC error; namespace missing → namespace error
4.4: Monitor Storage Cloning Progress
Use resources_get on DataVolume, check status.phase (Pending/Succeeded/Failed), report every 30s, wait up to 15 min
On successful clone:
## ✓ VM Cloned Successfully
**Source**: `<source-vm-name>` (<source-namespace>)
**Target**: `<target-vm-name>` (<target-namespace>) - Status: Stopped (ready to start)
**Config**: <instance-type>, <cpu> vCPU, <memory>, <storage-size>
<if clone_storage=true>
**Storage**: ✓ Cloned in <time> - Independent storage, changes won't affect source
</if>
<if new_storage=true>
**Storage**: ✓ New empty storage created - OS installation may be required
</if>
<if share_storage=true>
**Storage**: ⚠️ Shared PVC `<source-pvc>` - Keep source VM stopped to avoid data corruption
</if>
**Next**: Start with `"Start VM <target-vm-name> in namespace <target-namespace>"`
On cloning failure:
Document Consultation (OPTIONAL - when cloning fails):
## ❌ VM Cloning Failed
**Error**: <error-message>
**Source**: `<source-vm-name>` (<source-namespace>) → **Target**: `<target-vm-name>` (<target-namespace>)
**Common Causes**:
- Insufficient storage quota - Namespace lacks storage capacity
- Insufficient RBAC permissions - ServiceAccount lacks create permissions
- Storage class not available - Target namespace cannot access storage class
- PVC clone not supported - Storage class doesn't support cloning
- Source VM still running - Some storage backends require source VM stopped
**Troubleshooting** (see [storage-errors.md](references/troubleshooting/storage-errors.md)):
1. Check storage quota: `resources_list` for ResourceQuota in target namespace
2. Check permissions: `resources_list` to verify RBAC (note: `oc auth can-i` has no MCP equivalent)
3. Check storage class: `resources_get` for StorageClass config, `resources_list` for available classes
4. Check source VM status: vm-inventory skill `"Show status of VM <source-vm-name>"`
5. Check DataVolume status: `resources_get` for DataVolume phase and status
**Partial Resources** (may need cleanup):
- VirtualMachine: `<target-vm-name>`
- DataVolume: `<target-vm-name>-rootdisk`
**Cleanup**: `"Delete VM <target-vm-name> in namespace <target-namespace>"`
Would you like help troubleshooting this error?
User request: "Create 3 copies of template-vm named web-01, web-02, web-03" Limit: Maximum 5 clones per batch request. If user requests more, refuse and explain the limit exists to prevent resource exhaustion. Workflow: Validate source once, generate/check target names, ask storage strategy once, then process each clone individually through Steps 3-5 with separate confirmation per VM. Stop on first failure.
User request: "Clone production-vm from production to staging namespace" Note: Storage cloned across namespaces, network policies/quotas may differ, RBAC required in both namespaces
Allow modifications during clone: instance type/size, storage size, network config, cloud-init customization
Issue 1: Target VM Name Already Exists - Choose different name, delete existing VM (if safe), use vm-inventory to check
Issue 2: Insufficient Storage Quota - Check quotas, request increase, use shared storage (if appropriate), delete unused PVCs
Issue 3: Storage Class Not Accessible - Verify storage class exists in target namespace, check cross-namespace cloning support, use different storage class, contact admin
Issue 4: PVC Clone Not Supported - Storage class doesn't support CSI volume cloning; use "new empty storage" option, snapshot and restore, or check storage class capabilities
Issue 5: Source VM Running During Clone - Stop source VM first, use snapshot-based cloning, check storage backend requirements
openshift-virtualization - OpenShift MCP server with core and kubevirt toolsetsresources_get (from openshift-virtualization) - Get source VM and storage details
resources_create_or_update (from openshift-virtualization) - Create cloned VM and storage
resources_list (from openshift-virtualization) - List DataVolumes, PVCs, VMs
vm-create - Create new VMs from scratch (alternative to cloning)vm-inventory - List and verify source/target VMsvm-lifecycle-manager - Start cloned VMs after creationvm-delete - Clean up failed clones or unwanted copiesIMPORTANT: This skill creates new resources that consume cluster capacity. You MUST:
Before Cloning
Configuration Confirmation
Never Auto-Execute
Why This Matters:
User: "Clone web-server to web-server-test in namespace dev"
Agent: [Validates source VM web-server (production), checks target name availability]
[Discovers 50Gi storage, presents storage options]
"Select storage strategy (1-4):"
User: "1"
Agent: [Shows: Source web-server (u1.medium, 2 vCPU, 4Gi) → Target web-server-test (dev, 50Gi clone)]
"Proceed with VM cloning? (yes/no)"
User: "yes"
Agent: "📦 Creating storage... ⏳ Cloning (5-10 min)..."
"✓ VirtualMachine web-server-test created in dev"
"⏳ Storage cloning... Succeeded"
"✓ VM Cloned Successfully - Source: web-server (production), Target: web-server-test (dev)"
"Storage: ✓ Cloned in 7m23s - Independent storage"
"Next: Start VM web-server-test in namespace dev"
User: "Clone template-vm to app-01 with empty storage"
Agent: [Validation complete, presents options]
"Select storage strategy (1-4):"
User: "3"
Agent: "Proceed with VM cloning? (yes/no)"
User: "yes"
Agent: "✓ VM Cloned Successfully"
"Storage: ✓ New empty storage created - OS installation may be required"
User: "Create 3 copies of template-vm named web-01, web-02, web-03 in production"
Agent: [Validates source, checks all names, asks storage strategy once]
"Storage strategy for all clones: Clone Storage (1)"
## Clone 1 of 3: web-01
"Source: template-vm → Target: web-01 (production), 30Gi clone"
"Proceed with VM cloning? (yes/no)"
User: "yes"
Agent: "✓ web-01 cloned"
## Clone 2 of 3: web-02
"Source: template-vm → Target: web-02 (production), 30Gi clone"
"Proceed with VM cloning? (yes/no)"
User: "yes"
Agent: "✓ web-02 cloned"
[... repeats for each VM with individual confirmation ...]
User: "Clone db-vm to db-test"
Agent: "Select storage strategy (1-4):"
User: "2"
Agent: "⚠️ WARNING: Shared Storage is Dangerous"
"Risks: Data corruption if both VMs run simultaneously"
"Proceed with shared storage anyway? (yes/cancel)"
User: "cancel"
Agent: "VM cloning cancelled. No resources created."
references/README.md (opens in a new tab)references/SOURCES.md (opens in a new tab)references/troubleshooting/INDEX.md (opens in a new tab)references/troubleshooting/lifecycle-errors.md (opens in a new tab)references/troubleshooting/network-errors.md (opens in a new tab)references/troubleshooting/runtime-errors.md (opens in a new tab)references/troubleshooting/scheduling-errors.md (opens in a new tab)references/troubleshooting/storage-errors.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
inheritOther plugins' skills for the same job
npx claudepluginhub rhecosystemappeng/agentic-catalog --plugin rh-virt10 skills in this plugin
/vm-createCreate new virtual machines in OpenShift Virtualization with automatic instance type resolution and OS selection.
Use when:
- "Create a new VM"
- "Deploy a virtual machine with [OS]"
- "Set up a VM in namespace [name]"
- "Provision a [size] VM"
This skill handles VM creation with intelligent defaults for OpenShift Virtualization.
NOT for managing existing VMs (use vm-lifecycle-manager or vm-delete instead).
/vm-deletePermanently delete virtual machines and their associated resources from OpenShift Virtualization.
Use when:
- "Delete VM [name]"
- "Remove virtual machine [name]"
- "Destroy VM [name]"
- "Clean up VM [name]"
This skill handles permanent VM deletion with strict safety confirmations and typed verification.
NOT for power management (use vm-lifecycle-manager to stop VMs).
/vm-