Skip to content
Hands-on IT IT Drills

Appendix B: Final Exam

Goal: Four tasks without instructions that tie together everything from the book. · Duration: approx. 60 min · Prerequisite: Day 0–15

Rules of Play

  • You work in ~/one-lab/pruefung. The OneFlow service notes-service from Day 9 is running.
  • Every task has check commands. Only when they show what is written there is the task solved.
  • The solutions are in ~/one-lab/code/loesung/pruefung/.
mkdir -p ~/one-lab/pruefung
cd ~/one-lab/pruefung

Exercise 1: Team rot

Team rot gets a group team-rot with a user rot-dev (password lab-rot-pass-123) and may have exactly one VM at a time. It should be able to use the alpine template.

Check:

B="--user rot-dev --password lab-rot-pass-123"
onetemplate instantiate alpine --name rot1 --user-inputs GRUSS=r $B
onetemplate instantiate alpine --name rot2 --user-inputs GRUSS=r $B

Expected (the IDs will differ):

VM ID: 52
[one.template.instantiate] User [3] : group [101] limit of 1 reached for VMS quota in VM.

Solution

onegroup create team-rot
oneuser create rot-dev lab-rot-pass-123
oneuser chgrp rot-dev team-rot
printf 'VM = [ VMS = "1" ]\n' > quota.txt
onegroup quota team-rot quota.txt

You already shared the template, image, and security group with everyone on Day 8 (604). That is why the first VM works without further sharing. Clean up afterwards:

onevm terminate --hard rot1 $B

Save your progress? Sign up for free

Exercise 2: Quitting time for the API

The service’s first API VM should be powered off on weekdays at 10 p.m. (UTC).

Check:

V=$(onevm list --no-header | grep api_0 | awk '{print $1}')
onevm show $V | sed -n '/^SCHEDULED ACTIONS/,/^$/p'

Expected (date and remaining time will differ):

SCHEDULED ACTIONS
   ID   ACTION  ARGS   SCHEDULED           REPEAT   END STATUS
    1 poweroff     - 11/13 22:00 Weekly 1,2,3,4,5  None Next in 1.04 days

Solution

onevm poweroff $V --schedule "11/13 22:00" --weekly 1,2,3,4,5

Expected:

VM 30: poweroff scheduled at 2026-11-13 22:00:00 +0000

Every onevm action can be scheduled this way, like the backup on Day 7. 1,2,3,4,5 is Monday through Friday.

Save your progress? Sign up for free

Exercise 3: How many are running?

Write a Python script zustand.py that uses the XML-RPC API to count how many VMs are in which state, with names instead of numbers.

Check:

python3 zustand.py

Expected (the number depends on what is currently running):

ACTIVE 3

Solution

cat > zustand.py <<'EOF'
#!/usr/bin/env python3
"""Zählt die VMs pro Zustand über die XML-RPC-API."""
import collections
import xml.etree.ElementTree as ET
import xmlrpc.client

SESSION = "oneadmin:lab-one-pass-123"
NAMEN = {"1": "PENDING", "3": "ACTIVE", "8": "POWEROFF", "9": "UNDEPLOYED"}
one = xmlrpc.client.ServerProxy("http://localhost:2633/RPC2")

ok, body, code = one.one.vmpool.info(SESSION, -2, -1, -1, -1)[:3]
if not ok:
    raise SystemExit(f"Fehler {code}: {body}")
zahl = collections.Counter(vm.findtext("STATE") for vm in ET.fromstring(body).findall("VM"))
for state, n in sorted(zahl.items()):
    print(NAMEN.get(state, state), n)
EOF

For states, the plain pool data is enough; you do not need infoextended from Day 13 here.

Save your progress? Sign up for free

Exercise 4: Room for logs

The first API VM gets an additional, non-persistent disk logs with 256 MB while it is running.

Check:

onevm show $V | sed -n '/^VM DISKS/,/^$/p' | grep logs
IP=$(onevm show $V | grep -o 'ETH0_IP="[0-9.]*' | cut -d'"' -f2)
ssh $IP "grep sd /proc/partitions"

Expected:

  2 default    sdb    logs                                -/256M    file   NO
   8        0     262144 sda

Solution

oneimage create --name logs --type DATABLOCK --size 256 --datastore default
onevm disk-attach $V --image logs

As on Day 7, the disk is called sda inside the VM and sdb for OpenNebula.

Save your progress? Sign up for free

You made it

When all four exercises pass their check commands, you have completed all the drills. You can:

  • install OpenNebula, name its parts, and read their logs,
  • create images, datastores, templates, and networks and understand when data survives,
  • configure VMs via the context and build appliances and your own images from them,
  • master the lifecycle, snapshots, and backups,
  • separate teams with permissions and quotas,
  • build and scale services with OneFlow,
  • use OneGate, hooks, OpenTofu, and the APIs for automation,
  • operate a host, back it up, and plan an upgrade.

Clean up when you no longer need the lab: log out and delete the lab VM in your hypervisor. Everything OpenNebula created lives inside it.