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

  1. 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
  2. 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
    
  3. 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
    
  4. 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
    
  5. 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 called ovirtmgmt for management traffic. This example uses the ovirtmgmt logical network on the Default 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 the data_center-id value matches the id for the Default data center.
  6. 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!
  7. 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 and storage-path with the correct values for the NFS server.
    1. 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
    2. Verify that the created storage domain is available. The creation process might take several minutes. Once the status-state is unattached, you can proceed to the next step.
      [RHEVM shell (connected)]# show storagedomain DataStorage
      id             : xxxx
      name           : DataStorage
      master         : False
      status-state   : unattached
      ...
      
    3. 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
      
  8. 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 and storage-path with the correct values for the NFS server.
    1. 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
    2. Verify that the created storage domain is available. The creation process might take a while. Once the status-state is unattached, you can proceed to the next step.
      [RHEVM shell (connected)]# show storagedomain --name ISOStorage
      id             : xxxx
      name           : ISOStorage
      master         : False
      status-state   : unattached
      ...
      
    3. 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
  9. 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
  10. Use the add nic command to add a new network interface. Add the vm-identifier option to attach the interface as a sub-resource of MyVM and a network-name option to connect to the ovirtmgmt network.
    [RHEVM shell (connected)]# add nic --vm-identifier MyVM --name nic1 --network-name ovirtmgmt --bootable true
    
  11. Use the add disk command to add a new virtual hard disk. Add the vm-identifier option to attach the disk as a sub-resource of MyVM.
    [RHEVM shell (connected)]# add disk --vm-identifier MyVM --provisioned_size 8589934592 --interface virtio --format cow --storage_domains-storage_domain storage_domain.name=DataStorage
  12. 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):
  13. 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
  14. Add a virtual CD-ROM drive for your installation media. Add the vm-identifier option to attach the CD-ROM as a sub-resource of MyVM.
    [RHEVM shell (connected)]# add cdrom --vm-identifier MyVM --file-id rhel-server-6.6-x86_64-dvd.iso
  15. 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 the vm-os-boot option. This changes the boot device to cdrom for this initial boot session. After installation, the virtual machine restarts and restores the boot device back to hd.
  16. Use the list events with an additional query option to display specific event types. The start action for the virtual machine adds several entries in the events 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.
  17. Use the show event command to display comprehensive details of an event. This command can be used to show events by type, name, and id.
    [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
    
  18. 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's display-type. Protocols available include SPICE (default) and VNC.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.