Skip to content
Hands-on IT IT Drills

Day 8: Users and Tenants

Goal: Create a team with its own group and its own user, share specific templates with it, set quotas, and check that it cannot touch other people’s VMs. · Duration: approx. 60 min · Prerequisite: Day 7

Briefing

  • Users belong to a group. Every object has an owner, a group, and permissions like Unix files: use, manage, admin for owner, group, and everyone else.
  • ACLs govern what a group may do in principle, such as creating VMs or using networks. OpenNebula creates them when a group is created.
  • Quotas limit how much a group or a user may consume: number of VMs, RAM, CPU, storage, addresses.
  • A VDC (Virtual Data Center) bundles groups with hosts, networks, and datastores. Every new group lands in the default VDC, which allows everything.
 Gruppe team-blau (Quota: 2 VMs, 512 MB, 1 CPU)
   └─ Benutzer blau-dev
        nutzt: Template alpine (OTHER u), Image Alpine (OTHER u), SG web (OTHER u)
        sieht nicht: db, notes, Templates notes/notes-db

Drill 1: Group and user

onegroup create team-blau
oneuser create blau-dev lab-blau-pass-123
oneuser chgrp blau-dev team-blau
oneuser list

Expected (shortened):

ID: 100
ID: 2
  ID NAME       ENAB GROUP    AUTH           VMS          MEMORY        CPU       PCI
   2 blau-dev   yes  team-bla core       0 /   -     0M /      -  0.0 /   -   0 /   -
   1 serveradmi yes  oneadmin server_c   0 /   -     0M /      -  0.0 /   -   0 /   -
   0 oneadmin   yes  oneadmin core             -               -          -         -

serveradmin is a technical user that Sunstone and OneFlow use to log in.

The CLI can use a different user for individual commands. A variable saves you the typing:

A="--user blau-dev --password lab-blau-pass-123"
onetemplate list $A
onevnet list $A

Expected:

  ID USER     GROUP    NAME                    REGTIME
  ID USER     GROUP    NAME            CLUSTERS   BRIDGE   STATE  LEASES OUTD ERRO
   1 oneadmin oneadmin intern          0          intern0  rdy         2    0    0
   0 oneadmin oneadmin vnet            0          minioneb rdy         2    0    0

No templates, but networks. Why? The ACLs of the new group:

oneacl list | grep '@100'

Expected:

   6     @100     -H-----------------     *     -m--    #0
   7     @100     --N----------------     *     u---    #0
   8     @100     -------D-----------     *     u---    #0
   9     @100     V--I-T---O-S-R--P-B     *     ---c     *
Rule Reads as
7 Group 100 may use (u) all networks (N)
8 … use all datastores (D)
9 … create (c) VMs, images, templates, and more, but only its own

It may only use other people’s templates if their permissions allow it.

Save your progress? Sign up for free

Drill 2: Sharing

Permissions are set as a number, as with chmod: owner, group, others, with 4 for use. 604 means: the owner may do everything as before, everyone else may use it.

onetemplate chmod alpine 604
oneimage chmod "Alpine Linux 3.20" 604
onetemplate show alpine | grep -A4 PERMISSIONS

Expected:

PERMISSIONS
OWNER          : um-
GROUP          : ---
OTHER          : u--
onetemplate instantiate alpine --name blau1 --user-inputs GRUSS=b $A

Expected:

[one.template.instantiate] User [2] : Not authorized to perform USE SECGROUP [100].

Something is still missing. Since Day 5, the security group web has been attached to the vnet network, and it also belongs to oneadmin. Starting a VM means using everything it consists of: template, images, networks, security groups.

onesecgroup chmod web 604
onetemplate instantiate alpine --name blau1 --user-inputs GRUSS=b $A

Expected:

VM ID: 23

Save your progress? Sign up for free

Drill 3: Quotas

Team blau gets at most two VMs, 512 MB, and one core:

mkdir -p ~/one-lab/tag08
cd ~/one-lab/tag08
printf 'VM = [ VMS = "2", MEMORY = "512", CPU = "1" ]\n' > quota.txt
onegroup quota team-blau quota.txt
onegroup list | grep team-blau

Expected:

 100 team-blau           1   1 /   2   256M /   512M   0.5 / 1.0   0 /   -

One VM is already running. Two more attempts:

onetemplate instantiate alpine --name blau2 --user-inputs GRUSS=b $A
onetemplate instantiate alpine --name blau3 --user-inputs GRUSS=b $A

Expected:

VM ID: 24
[one.template.instantiate] User [2] : group [100] limit of 2 reached for VMS quota in VM.

The quota applies at creation, not only at start.

Save your progress? Sign up for free

Checkpoint

onevm list $A

Expected: exactly blau1 and blau2, both owned by blau-dev. blau-dev does not see db and notes.

onegroup list | grep team-blau

Expected: 2 / 2 for the VMs.

Challenge

blau-dev wants to delete oneadmin’s database db. Can he? By name? By ID?

Solution

onevm terminate db $A
onevm terminate $(onevm show db | grep '^ID' | tr -dc 0-9) $A

Expected (the ID will differ):

VM named db not found.
[one.vm.action] User [2] : Not authorized to perform MANAGE VM [22].

By name, blau-dev does not find the VM at all; he cannot see it. He can guess the ID, but then he lacks the MANAGE permission. His own VMs, on the other hand, belong only to him:

onevm show blau1 $A | grep -A3 PERMISSIONS

Expected:

PERMISSIONS
OWNER               : um-
GROUP               : ---
OTHER               : ---

Not even colleagues from team-blau can see them. If they should, the user sets his umask (oneuser umask blau-dev 117); then the group additionally gets use and manage at creation.

Clean up:

onevm terminate --hard blau1 $A
onevm terminate --hard blau2 $A

Save your progress? Sign up for free

Enterprise Note

  • Group admins: onegroup create --admin_user creates an admin who may create users and distribute quotas within their group. That way, teams manage themselves, and the cloud admin only sets the framework.
  • Your own VDCs: For real tenant separation, you take the group out of the default VDC and give it its own VDC with exactly the hosts, networks, and datastores it should see. A customer then only sees their own hardware.
  • Authentication: Instead of local passwords, OpenNebula connects to LDAP/Active Directory or SAML. Groups can be derived from LDAP groups.
  • Showback: OpenNebula counts consumption per VM and user (oneshowback). With costs per CPU hour and GB, you get simple per-team billing.