Bookmark this page

Lab: Managing Virtual Machine Images

Performance Checklist

In this lab, you will import a virtual machine image, take a snapshot of a virtual machine, and export a virtual machine.

Outcomes

You should be able to:

  • Upload a virtual machine image into Red Hat Virtualization, using the Administration Portal.

  • Take a snapshot of an existing virtual machine.

  • Use the Administration Portal to export a virtual machine as an OVA file onto an RHV host.

Log in to workstation as the student user with student as the password.

On workstation, run the lab snapimex-review start command. This command runs a start script that determines if the Red Hat Virtualization environment is configured and working.

[student@workstation ~]$ lab snapimex-review start
  1. On workstation, download the http://materials.example.com/rhel7-minimal-sealed.qcow2 virtual machine image to the ~/Downloads/ directory, if it does not already exist. Upload rhel7-minimal-sealed.qcow2 to the production data center. Use rhel7-image as the alias and nfs-data as the storage domain. The size of 3 GB will be automatically assigned.

    1. Check to see if rhel7-minimal-sealed.qcow2 already exists in the ~/Downloads/ directory.

      [student@workstation ~]$ ls ~/Downloads/
      rhel7-minimal-sealed.qcow2

      Download the http://materials.example.com/rhel7-minimal-sealed.qcow2 virtual machine image, if necessary.

      [student@workstation ~]$ wget -nc -P ~/Downloads/ \ 
      http://materials.example.com/rhel7-minimal-sealed.qcow2
      ...output omitted...
      HTTP request sent, awaiting response... 200 OK
      Length: 1210712064 (1.1G)
      Saving to: ‘/home/student/Downloads/rhel7-minimal-sealed.qcow2’
      ...output omitted...
    2. Open the Administration Portal at https://rhvm.lab.example.com. If necessary, log in as admin in the internal profile. Use redhat as the password.

    3. In the menu, click Storage, and then click Disks.

    4. Select UploadStart. The Upload Image window displays.

    5. In the Upload Image window, click Choose File, and then select the /home/student/Downloads/rhel7-minimal-sealed.qcow2 virtual machine image file. The value of 3 GB will be automatically assigned in the Size (GiB) field. Enter rhel7-image in the Alias text field. Choose production for the Data Center. Verify that the value of the Storage Domain field is nfs-data. Use the default values for the other fields.

    6. In a previous guided exercise, you should have downloaded the ovirt-engine certificate. Click the Test Connection button to verify this. If clicking the Test Connection button returns a green success box, then you are ready to upload. If clicking the Test Connection button returns an orange warning box, click the ovirt-engine certificate link within the warning box. Check the box next to Trust this CA to identify websites and then click the OK button. Once complete, click the Test Connection button again. It should return a green success box.

      Important

      If you accidentally forget to check the box next to Trust this CA to identify websites, the following procedure will bring up that window again:

      1. Open Preferences for Firefox, and then select Privacy & Security in the left menu.

      2. Scroll down to the Security section, and then click the View Certificates... button.

      3. In the Certificate Manager window, scroll down to lab.example.com, click rhvm.lab.example.com.34088 so that it is highlighted, and then click the Delete or Distrust button.

      4. Back on the Preferences tab for Privacy & Security, scroll up to the Cookies and Site Data section, and then click the Clear Data... button.

      5. Accept the default selections and click the Clear button. Confirm your choice by clicking the Clear Now button in the new window that displays.

    7. Click the OK button to start the upload process.

    8. Verify that the value of the Status field for the rhel7-image virtual machine image is OK. It may take up to a minute to upload this image.

  2. Create a new virtual machine named rhel-lab-vm. Use clustertwo. The operating system should use Red Hat Enterprise Linux 7.x x64, the instance type should use Small, and Optimized for should use Server. Attach the rhel7-image virtual machine image as a bootable disk. Associate the first network interface with the prod-vm-net logical network.

    1. In the menu, click Compute, and then click Virtual Machines.

    2. To create a new virtual machine, click New. The New Virtual Machine window displays.

    3. In the New Virtual Machine window, set the values of the fields according to the following table.

      FieldValue
      Clusterclustertwo
      Operating System MenuRed Hat Enterprise Linux 7.x x64
      Instance TypeSmall
      Optimized forServer
      Namerhel-lab-vm
      Attach Virtual Disksrhel7-image (check the box under OS)
      nic1prod-vm-net

      To attach the virtual disk, click on the Attach button. Select the rhel7-image image. Make sure to check the box under OS to indicate that this is a bootable disk. Click OK.

      Click OK to create the virtual machine.

    4. Verify that the virtual machine list includes the rhel-lab-vm virtual machine.

  3. Create a snapshot of the rhel-lab-vm virtual machine. Use rhel-lab-vm-snapshot for the snapshot description.

    1. Right-click the row for the rhel-lab-vm virtual machine, and then click Create Snapshot. The Create Snapshot window displays.

    2. Enter rhel-lab-vm-snapshot as a description of the snapshot in the Description field. Select the virtual disk by clicking on the check box in the Disks to include section. Click OK to create the snapshot.

    3. In the Virtual Machines tab, click on the name of the rhel-lab-vm virtual machine. Select the Snapshots tab. Click on the General link in the rhel-lab-vm-snapshot row. Verify that the value of the Status field is OK. It may take up to a minute to create this snapshot.

  4. Modify /etc/motd on the rhel-lab-vm virtual machine to contain the string RHV managed virtual machine.

    1. In the menu, click Compute, and then select Virtual Machines.

    2. Right-click the row for the rhel-lab-vm virtual machine, and then select Run. Verify that the value of the Status field for the rhel-lab-vm virtual machine is Up. It may take up to a minute for the rhel-lab-vm virtual machine to start.

    3. Right-click the row for the rhel-lab-vm virtual machine, and then select Console. The Opening console.vv window appears. Choose Open with, and then select Remote Viewer. Click OK to open the console for rhel-lab-vm. Click on Allow.

    4. Log in to the rhel-lab-vm virtual machine as root using redhat as the password.

    5. Verify that the /etc/motd file for the rhel-lab-vm virtual machine is empty.

      [root@localhost ~]# cat /etc/motd
    6. Modify the /etc/motd file to contain the string RHV managed virtual machine.

      [root@localhost ~]# echo 'RHV managed virtual machine' > /etc/motd
    7. Power off the rhel-lab-vm virtual machine.

      [root@localhost ~]# systemctl poweroff
  5. Revert the rhel-lab-vm virtual machine back to the rhel-lab-vm-snapshot snapshot.

    1. In the Administration Portal, click Compute, and then select Virtual Machines.

    2. Verify that the value of the Status field for the rhel-lab-vm virtual machine is Down. If the rhel-lab-vm virtual machine is still running, right-click on the name, and then select Shutdown. You may need to scroll the virtual machine list window to the right in order to see the Status field. It may take a minute for the virtual machine to shut down.

    3. Click on the name of the rhel-lab-vm virtual machine.

    4. Click on the Snapshots tab.

    5. Select the rhel-lab-vm-snapshot snapshot. Click the Preview drop-down menu, and then select Custom.... The Custom Preview Snapshot window displays.

    6. Select the radio button for the rhel-lab-vm-snapshot snapshot. Select the check box for rhel7-image. Click OK to preview the rhel-lab-vm-snapshot snapshot.

    7. In the Snapshots tab, click on General for the rhel-lab-vm-snapshot snapshot. Verify that the value of the Status field is IN_PREVIEW. Click Commit. The Commit Snapshot window displays. Click on OK.

    8. In the menu, click Events. Verify that the message Committing a Snapshot-Preview for VM rhel-lab-vm has been completed displays. This confirms that RHV-M successfully restored the rhel-lab-vm-snapshot snapshot in the rhel-lab-vm virtual machine.

  6. Verify that the /etc/motd file is empty to determine if the rhel-lab-vm virtual machine is using the rhel-lab-vm-snapshot snapshot.

    1. In the menu, click Compute, and then select Virtual Machines.

    2. Right-click the row for the rhel-lab-vm virtual machine, and then select Run. Verify that the value of the Status field for the rhel-lab-vm virtual machine is Up. It may take up to a minute for the rhel-lab-vm virtual machine to start.

    3. Right-click the row for the rhel-lab-vm virtual machine, and then select Console. The Opening console.vv window displays. Choose Open with, and then select Remote Viewer. Click OK to open the console for rhel-lab-vm. Click on Allow.

    4. Log in to the rhel-lab-vm virtual machine as root using redhat as the password.

    5. Verify that the /etc/motd file for the rhel-lab-vm virtual machine is empty.

      [root@rhel-lab-vm ~]$ cat /etc/motd
    6. Log out from rhel-lab-vm.

      [root@rhel-lab-vm ~]$ logout
  7. Export the rhel-lab-vm virtual machine as an OVA file to the /var/lib/libvirt/images/ directory, on hostc.lab.example.com.

    1. In the menu, click Compute and then click Virtual Machines.

    2. Click the row for the rhel-lab-vm virtual machine. Click on the three vertical dots next to Create Snapshot, and then select Export as OVA.

    3. The Export Virtual Machines(s) As Virtual Appliance window displays. Verify that the Host is hostc.lab.example.com. In the Directory field, enter /var/lib/libvirt/images/. Confirm that the Name is rhel-lab-vm.ova. Click on OK. A message displays to confirm that the OVA has been created.

    4. From workstation log in to hostc.lab.example.com as the root user.

      [student@workstation ~]$ ssh root@hostc.lab.example.com
       Last login: Tue Aug 13 06:26:29 2019 from 172.25.250.14
      
       node status: OK
       See `nodectl check` for more information
      
       Admin Console: https://172.24.0.12:9090/ or https://172.25.250.12:9090/
      [root@hostc ~]#
    5. Locate the rhel-lab-vm.ova on hostc.lab.example.com.

      [root@hostc ~]# ll /var/lib/libvirt/images
      total 1182364
      -rw-------. 1 root root 1210857984 Aug 13 06:26 rhel-lab-vm.ova 
    6. Log out from hostc.lab.example.com.

      [root@hostc ~]$ logout

Evaluation

On workstation, run the lab snapimex-review grade command to confirm that you have completed this exercise successfully.

[student@workstation ~]$ lab snapimex-review grade

Finish

On workstation, run the lab snapimex-review finish script to complete this lab.

[student@workstation ~]$ lab snapimex-review finish

This concludes the lab.

Revision: rh318-4.3-c05018e