Chapter 2. Quick Start Example
2.1. Creating a Basic Virtualization Environment with the CLI
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
- List all data centers in the environment. This example uses the
Default
data center.[RHEVM shell (connected)]# list datacenters id : 5e3b55d8-c585-11e1-a7df-001a4a400e0d name : Default description: The default Data Center
- 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.[RHEVM shell (connected)]# list clusters id : 99408929-82cf-4dc7-a532-9d998063fa95 name : Default description: The default server cluster
- 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
- 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.[RHEVM shell (connected)]# list networks --show-all id : 00000000-0000-0000-0000-000000000009 name : ovirtmgmt description : Management Network data_center-id: 5e3b55d8-c585-11e1-a7df-001a4a400e0d mtu : 0 required : True status-state : operational stp : False usages-usage : VM
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!
- 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
- 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.[RHEVM shell (connected)]# show storagedomain DataStorage id : xxxx name : DataStorage master : False status-state : unattached ...
- 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
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
- 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
- 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.[RHEVM shell (connected)]# show storagedomain --name ISOStorage id : xxxx name : ISOStorage master : False status-state : unattached ...
- 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
- 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
- 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
- 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
- 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 Please provide the REST API password for the admin@internal oVirt Engine user (CTRL+D to abort):
- 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
- 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
- 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
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).
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
.[RHEVM shell (connected)]# show event '60' id : 60 description : New Tag foo was created by admin@internal. code : 432 correlation_id: 3e4d4350 custom_id : -1 flood_rate : 30 origin : oVirt severity : normal time : 2013-07-03 10:57:43.257000+03:00 user-id : fdfc627c-d875-11e0-90f0-83df133b58cc
- Access your virtual machine with the
console
command.[RHEVM shell (connected)]# console MyVM
Important
Ensure your client machine has a console application installed to match the virtual machine'sdisplay-type
. Protocols available include SPICE (default) and VNC.