The command-line interface (CLI) tools you'll use for OpenShift Virtualization are :
- virtctl : A CLI tool specifically designed for managing VMs in OpenShift Virtualization.
- oc : The general OpenShift CLI that can also manage VMs as Kubernetes resources.
VMware provides a number of command-line tools for managing and interacting with its infrastructure.
The primary CLI tools for managing a VMware environment are :
- vim-cmd : Used directly on ESXi hosts for managing virtual machines.
- esxcli : Another tool used on ESXi hosts, but for a broader range of system management tasks.
- govc : A command-line tool to interact with vSphere environments, which includes vCenter and ESXi hosts.
- PowerCLI : A PowerShell-based tool for managing VMware infrastructure.
Below are some common VMware and OpenShift Virtualization CLI examples for managing virtual machines, networks, and hosts using these tools.
The purpose of this blog is to highlight the many similarities between the CLI tools used to manage these two platforms. It demonstrates that the similarities outweigh the differences, making it relatively easy for an experienced VMware Admin to become familiar with the OpenShift Virtualization CLI.
The tools I have primarily used and am most familiar with are vim-cmd and govc for VMware, as well as virtctl for OpenShift. Most of the examples below will focus on using these tools.
There are similar concepts for managing VM in VMWare using the vim-cmd tool as well as managing VMs in Openshift Virtualization.
The vim-cmd
utility in VMware ESXi provides a command-line interface to manage different aspects of the ESXi host and its components. vim-cmd
operates using namespaces, which group related commands for managing specific services, such as virtual machines, storage, networking, and more.
Each namespace contains multiple subcommands that are used to perform specific tasks.
Here are the key vim-cmd
namespaces available in ESXi and what they are used for :
- vmsvc – Virtual Machine Service
The vmsvc namespace is used to manage virtual machines (VMs) on the ESXi host. It provides commands for starting, stopping, getting information, and other VM operations.
Example Commands : vim-cmd vmsvc/getallvms: List all VMs on the host - hostsvc – Host Service
The hostsvc namespace is used to manage the ESXi host itself. This includes operations related to the host's services, networking, and maintenance tasks.
Example Commands : hostsvc/maintenance_mode_enter: Put the ESXi host into maintenance mode. - solo – Single Host Management
The solo namespace is used for general operations on the ESXi host. It includes system-related tasks, host configuration management, and host state information.
Example Commands: solo/registervm <vmx-path>: Register a VM on the ESXi host.
Here are some examples that compare the similarities and differences between the two interfaces.
Examples
- List All VMs
VMware : vim-cmd vmsvc/getallvms
OCPVirt : List all VMs in a Specific Namespace
oc get vms -n <namespace>
oc get vms --all-namespaces - stop a vm
VMWare :
OCPVirt :
virtctl stop <vm-name> - delete a vm
VMWare :
OCPVirt :
virtctl delete <vm-name> - start a VM
VMWare :
vim-cmd vmsvc/power.on <VMID>
govc vm.power -on <vm-name>
OCPVirt :
virtctl start<vm-name> - get summary / description of a VM
VMWare :
vim-cmd vmsvc/get.summary <VMID> - OCPVirt :
oc describe vm <vm-name> - create a VM
VMWare :
OCPVirt : - migrate a VM
VMWare :
OCPVirt :
virtctl migrate <vm-name> - create a VM
VMWare :
OCPVirt : - create a VM
VMWare :
OCPVirt : - create a VM
VMWare :
OCPVirt :