Chapter 2. Quick Start Example
2.1. Creating a Basic Virtualization Environment with the CLI Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
This chapter provides an example to demonstrate the CLI's ability to add a virtual machine within a basic Red Hat Virtualization environment. This example uses the following prerequisites:
- A networked and configured Red Hat Enterprise Linux host for use as a hypervisor;
- A networked and configured NFS storage server with two shares:
/exports/data
- The data storage domain; and/exports/iso
- The ISO storage domain.
- A networked and configured Red Hat Virtualization Manager;
- An installation of the CLI on either the Red Hat Virtualization Manager or a client machine; and,
- An ISO file containing a desired virtual machine operating system to install. This chapter uses Red Hat Enterprise Linux Server 6 for our installation ISO example.
Note
Red Hat Virtualization Manager generates a globally unique identifier (GUID) for each resource. Identifier codes in this example might appear different to the identifier codes in your Red Hat Virtualization environment.
Procedure 2.1. Quick Start Example
- Load the CLI shell and connect to your Red Hat Virtualization Manager.
ovirt-shell -c --url https://[rhevm-host]/ovirt-engine/api --username [user]@[domain] --ca-file certificate/authority/path/name
# ovirt-shell -c --url https://[rhevm-host]/ovirt-engine/api --username [user]@[domain] --ca-file certificate/authority/path/name
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - List all data centers in the environment. This example uses the
Default
data center.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - List all host clusters and note down the relevant cluster ID or cluster name, which will be required when adding the host and for creating a virtual machine. This example uses the
Default
cluster to group resources in your Red Hat Virtualization environment.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - List all CPU profiles and note down the relevant CPU profile ID, which will be required when creating a virtual machine. This example uses the
Default
CPU profile.[RHEVM shell (connected)]# list cpuprofiles id : 0000001a-001a-001a-001a-00000000035e name : Default
[RHEVM shell (connected)]# list cpuprofiles id : 0000001a-001a-001a-001a-00000000035e name : Default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - List all logical networks with the
show-all
option to view the details of the logical networks in the environment. Red Hat Virtualization Manager creates a default logical network calledovirtmgmt
for management traffic. This example uses theovirtmgmt
logical network on theDefault
data center.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note thedata_center-id
value matches theid
for theDefault
data center. - Add the Red Hat Enterprise Linux host to the virtualization environment as a new hypervisor. The host is activated automatically.
[RHEVM shell (connected)]# add host --name MyHost --address host.example.com --cluster-name Default --root_password p@55w0rd!
[RHEVM shell (connected)]# add host --name MyHost --address host.example.com --cluster-name Default --root_password p@55w0rd!
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add an NFS share as a data storage domain by creating, attaching, and activating the NFS share. An NFS data storage domain is an exported NFS share attached to a data center. It provides storage for virtual machines. Ensure to substitute
storage-address
andstorage-path
with the correct values for the NFS server.- Create a data storage domain.
[RHEVM shell (connected)]# add storagedomain --host-name MyHost --type data --storage-type nfs --storage_format v3 --storage-address x.x.x.x --storage-path /exports/data --name DataStorage
[RHEVM shell (connected)]# add storagedomain --host-name MyHost --type data --storage-type nfs --storage_format v3 --storage-address x.x.x.x --storage-path /exports/data --name DataStorage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify that the created storage domain is available. The creation process might take several minutes. Once the
status-state
isunattached
, you can proceed to the next step.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Attach the data storage domain to the data center. The storage domain is activated automatically.
[RHEVM shell (connected)] # add storagedomain --datacenter-identifier Default --name DataStorage
[RHEVM shell (connected)] # add storagedomain --datacenter-identifier Default --name DataStorage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
If the storage domain is not activated, activate it manually using the following command:[RHEVM shell (connected)]# action storagedomain DataStorage --datacenter-identifier Default activate
[RHEVM shell (connected)]# action storagedomain DataStorage --datacenter-identifier Default activate
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Add an NFS share as the ISO storage domain by creating, attaching, and activating the NFS share. An NFS ISO storage domain is an exported NFS share attached to a data center. It provides storage for DVD/CD-ROM ISO and virtual floppy disk (VFD) image files. Ensure to substitute
storage-address
andstorage-path
with the correct values for the NFS server.- Create an ISO storage domain.
[RHEVM shell (connected)]# add storagedomain --host-name MyHost --type iso --storage-type nfs --storage_format v3 --storage-address x.x.x.x --storage-path /exports/iso --name ISOStorage
[RHEVM shell (connected)]# add storagedomain --host-name MyHost --type iso --storage-type nfs --storage_format v3 --storage-address x.x.x.x --storage-path /exports/iso --name ISOStorage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify that the created storage domain is available. The creation process might take a while. Once the
status-state
isunattached
, you can proceed to the next step.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Attach the ISO storage domain to the data center. The storage domain is activated automatically.
[RHEVM shell (connected)] # add storagedomain --datacenter-identifier Default --name ISOStorage
[RHEVM shell (connected)] # add storagedomain --datacenter-identifier Default --name ISOStorage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Create a new virtual machine.
[RHEVM shell (connected)]# add vm --name MyVM --cluster-name Default --template-name Blank --memory 536870912 --os-boot boot.dev=hd --cpu_profile-id 0000001a-001a-001a-001a-00000000035e
[RHEVM shell (connected)]# add vm --name MyVM --cluster-name Default --template-name Blank --memory 536870912 --os-boot boot.dev=hd --cpu_profile-id 0000001a-001a-001a-001a-00000000035e
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the
add nic
command to add a new network interface. Add thevm-identifier
option to attach the interface as a sub-resource ofMyVM
and anetwork-name
option to connect to theovirtmgmt
network.[RHEVM shell (connected)]# add nic --vm-identifier MyVM --name nic1 --network-name ovirtmgmt --bootable true
[RHEVM shell (connected)]# add nic --vm-identifier MyVM --name nic1 --network-name ovirtmgmt --bootable true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the
add disk
command to add a new virtual hard disk. Add thevm-identifier
option to attach the disk as a sub-resource ofMyVM
.[RHEVM shell (connected)]# add disk --vm-identifier MyVM --provisioned_size 8589934592 --interface virtio --format cow --storage_domains-storage_domain storage_domain.name=DataStorage
[RHEVM shell (connected)]# add disk --vm-identifier MyVM --provisioned_size 8589934592 --interface virtio --format cow --storage_domains-storage_domain storage_domain.name=DataStorage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - On the Manager, upload ISO images to the
ISOStorage
domain for the virtual machines to use. Red Hat Virtualization Manager provides an ISO uploader tool that ensures images are uploaded into the correct directory path with the correct user permissions.engine-iso-uploader --iso-domain=ISOStorage upload rhel-server-6.6-x86_64-dvd.iso
# engine-iso-uploader --iso-domain=ISOStorage upload rhel-server-6.6-x86_64-dvd.iso Please provide the REST API password for the admin@internal oVirt Engine user (CTRL+D to abort):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In the CLI shell, use the
list files
command to list the available ISO files in the storage domain.[RHEVM shell (connected)]# list files --storagedomain-identifier ISOStorage
[RHEVM shell (connected)]# list files --storagedomain-identifier ISOStorage
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add a virtual CD-ROM drive for your installation media. Add the
vm-identifier
option to attach the CD-ROM as a sub-resource ofMyVM
.[RHEVM shell (connected)]# add cdrom --vm-identifier MyVM --file-id rhel-server-6.6-x86_64-dvd.iso
[RHEVM shell (connected)]# add cdrom --vm-identifier MyVM --file-id rhel-server-6.6-x86_64-dvd.iso
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the virtual machine. The virtual environment is complete and the virtual machine contains all necessary components to function.
[RHEVM shell (connected)]# action vm MyVM start --vm-os-boot boot.dev=cdrom
[RHEVM shell (connected)]# action vm MyVM start --vm-os-boot boot.dev=cdrom
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note the use of thevm-os-boot
option. This changes the boot device tocdrom
for this initial boot session. After installation, the virtual machine restarts and restores the boot device back tohd
. - Use the
list events
with an additionalquery
option to display specific event types. Thestart
action for the virtual machine adds several entries in theevents
collection.[RHEVM shell (connected)]# list events --query "type=153" id : 105 description: MyVM was started by admin (Host: MyHost).
[RHEVM shell (connected)]# list events --query "type=153" id : 105 description: MyVM was started by admin (Host: MyHost).
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The"type=153"
query refers to events where a user starts a virtual machine. - Use the
show event
command to display comprehensive details of an event. This command can be used to show events bytype
,name
, andid
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Access your virtual machine with the
console
command.[RHEVM shell (connected)]# console MyVM
[RHEVM shell (connected)]# console MyVM
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Important
Ensure your client machine has a console application installed to match the virtual machine'sdisplay-type
. Protocols available include SPICE (default) and VNC.