74 Commits
Author SHA1 Message Date
Pavel Czerný dfa57cab08 B #7938: Fix VLAN authorization for unchanged values (#4457) 2026-08-27 11:10:39 +02:00
d48a32e252 F #7490: VLAN Groups for VNET multi-tenancy
This PR adds Group VLAN authorization rules for Virtual Network self-provisioning
through VN Template instantiation and VNET updates derived from a VN Template.

The feature lets administrators define VLAN usage policies at group level. These policies are
evaluated when users instantiate VN Templates or update VNETs that were instantiated from a VN
Template. Direct VNET allocation is not treated as the tenant self-provisioning path; the intended
multi-tenant model is to expose network creation through reservations and VN Template
instantiation, while direct VNET allocation remains an admin-controlled operation.

Group VLAN rules are stored under `VLAN_RULES` as `RULE` vector attributes.

Rule format:

```txt
RULE = [
  ID          = "5,6,100-200",
  SCOPE       = "CVLAN",
  VNTEMPLATE  = "10,20-30"
]

Fields:

- ID: VLAN values allowed by the rule. Supports single values and ranges, comma-separated.
    - Examples: "5", "5,6,100-200"

- SCOPE: VLAN attribute scope controlled by the rule.
    - Supported scopes: VLAN_ID, OUTER_VLAN_ID, CVLAN, VLAN_TAGGED_ID, ANY

- VNTEMPLATE: optional VN Template IDs where the rule applies.
    - Supports single values and ranges, comma-separated.
    - -1 or missing value means the rule applies to any VN Template.

Examples:

RULE = [
  ID = "100-200",
  SCOPE = "VLAN_ID",
  VNTEMPLATE = "10"
]

Allows VLAN_ID values from 100 to 200 when instantiating or updating VNETs derived from VN Template
10.

RULE = [
  ID = "300,400-450",
  SCOPE = "ANY",
  VNTEMPLATE = "-1"
]

Allows the listed VLAN IDs/ranges for any supported VLAN scope and any VN Template.

Rules are parsed into an internal structured representation when group VLAN data is loaded or
updated. Each rule is normalized into:

- scope
- VLAN ID ranges
- VN Template ID ranges

This avoids reparsing raw template attributes during authorization checks.

Validation is applied to these input scopes:

- VLAN_ID
- OUTER_VLAN_ID
- CVLAN
- VLAN_TAGGED_ID

VLAN_ID and OUTER_VLAN_ID are validated as single integer values. CVLAN and VLAN_TAGGED_ID accept
range expressions such as 5,6-10.

For each requested VLAN value or range:

1. The input is parsed into one or more test ranges.
2. Rules are scanned for matching scope, including ANY.
3. Rules are filtered by VN Template ID:
    - empty/-1 VNTEMPLATE matches all templates
    - explicit ranges match only included template IDs

4. A requested range is accepted only if it is fully covered by a single rule range.
5. The check passes when all requested ranges are covered.

Automatic VLAN selection is rejected when the user belongs to a group with VLAN rules matching the
target VN Template, including global rules. This avoids bypassing explicit group VLAN policy
through automatic allocation.

VNETs instantiated from VN Templates now preserve the source VN Template ID as a first-class VNET
attribute:

<VNET>
  ...
  <TEMPLATE_ID>...</TEMPLATE_ID>
  ...
</VNET>

TEMPLATE_ID = -1 means the VNET was created directly and was not instantiated from a VN Template.

This ID is immutable from user template updates:

- it is removed from the VNET template body on insert/update
- it is serialized as a top-level VNET attribute
- update operations use the stored value to validate VLAN authorization

A database migrator moves legacy TEMPLATE/TEMPLATE_ID values to top-level VNET/TEMPLATE_ID.

The tenant self-provisioning model for VNETs is based on controlled entry points:

- VNET reservations
- VN Template instantiation

Group VLAN authorization is enforced on VN Template instantiation and on updates to VNETs that were
instantiated from a VN Template.

Direct VNET allocation is not considered the tenant-facing self-provisioning path. It should remain
admin-controlled, as unrestricted VNET creation can expose other sensitive network attributes such
as PHYDEV, BRIDGE, and driver-specific configuration in addition to VLAN IDs.

Existing VNETs created from VN Templates may have the source template ID stored inside TEMPLATE/
TEMPLATE_ID. The migration step moves that value to top-level VNET/TEMPLATE_ID and removes it from
the template body.

This PR also updates the AR operations (add/del/update) so tenants can easily managed the VNET instantiations.

Existing directly-created VNETs will have no source VN Template and are treated as TEMPLATE_ID =
-1.

Existing group objects without VLAN rules are initialized with an empty VLAN_RULES section,
preserving current behavior until rules are explicitly configured.

Configuration compatibility:

- VLAN_ID, CVLANS, and AR/VLAN_ID are no longer expected to be handled through generic VNET
  restricted attributes for the VN Template instantiation flow.

- OneCfg migration/update handling for configuration files will be addressed separately before
    release.

co-authored-by: Pavel Czerny <pczerny@opennebula.io>
co-authored-by: Miguel E. Ruiz <mruiz@opennebula.io>
co-authored-by: dcarracedo <dcarracedo@opennebula.io>
2026-06-24 11:26:36 +02:00
Pavel Czerný 87d55b2cf9 F #7678: Dummy NIC interface for VM (#4251) 2026-06-12 14:29:08 +02:00
Ruben S. Montero 41fbb21f61 F #1536, #7253: Minor fixes
* Fix range wrapping in multi-leases ranges (i.e. not use 8,9,0)
* Skip reservations and shared AR's in fsck.
* Do not reserve MAC addresses on VNET reservations
* Release MAC ID's on virtual network drop (with existing AR's)
* NEXT_INDEX is an internal attribute (cannot be set by user)
* Check size on update
2026-05-27 13:36:54 +02:00
Ruben S. Montero 2b9100999a F #1536, #7253: Fix global MAC accounting and AR allocation edge cases
* Skip global MAC ID release for reservation ARs because the parent AR owns the bitmap entry.
* Reject global MAC address ranges whose SIZE crosses the reserved 20-bit host block.
* Release reserved global MAC IDs when AR initialization fails after MAC assignment.
* Treat shared ARs as having no global MAC ID so bitmap release paths ignore them.
* Wrap multi-lease range scans correctly so allocation can find ranges starting at index 0.
* Keep IP6 in expanded security-group rules by removing allocator-only NEXT_INDEX from copied AR fields.
* Remove the leftover VNC bitmap debug dump from onedb fsck.
2026-05-27 11:54:08 +02:00
8fc632ec4e F #1536, #7253: Implement global MAC adress space and MAC parsing
New configuration attribue MAC_GLOBAL_SPACE in oned.conf to enable the global
MAC address space generation mode.

MAC addresses are generated from a global pool preventing collisions across
VNETs. This does not apply to IP networks and limits the number of VNETs to
2^20, with a max of 2^20 leases per VNET.

This commit also implementes:
  * A round-robin assignment of addresses. (jukka.jokiniva@qt.io)
  * Optimizes the storing of the BitMap - do not store leading zeros

co-authored-by: Pavel Czerny <pczerny@opennebula.io>
co-authored-by: Jukka Jokiniva <jukka.jokiniva@qt.io>
2026-05-26 18:02:39 +02:00
Ruben S. Montero ebbb7be5d4 M #-: Bump version 7.3.80 2026-03-30 09:58:53 +02:00
deb127c59b F one#6534: Support for assigning IPs to several VMs
This commit adds support for sharing IPs among several VMs. When a AR is
marked as shared several VMs can request the same IP address either
through a NIC or NIC_ALIAS.

- Shared AR's cannot assign IP address automatically, an specific IP
  needs to be requested.
- Shared AR's have some restrictions:
      - Shared AR cannot use external IPAM
      - Shared AR can only be of type IP4 or IP6_STATIC
      - Shared AR cannot update IPAM or SHARED attribute
      - Shared AR cannot make reservations
      - Shared AR cannot hold by mac
- NICs / NIC_ALIAS using Shared IP will include SHARED=YES

co-authored-by: Jorge Miguel Lobo Escalona <jlobo@opennebula.io>
co-authored-by: MarioRobres <mrobres@opennebula.io>
2026-02-10 10:28:06 +01:00
Tino Vázquez a64f071808 M #-: Bump year 2025 2025-02-28 11:56:18 +01:00
Tino Vázquez 05d147c524 M #-: Bump version 6.10.0
Also bump copyright year to 2024
2024-07-29 14:27:11 +02:00
Pavel Czerný 2fe396ae15 L #-: Add Astyle linting
* Add AStyle to smoke tests
* Format C++ files using AStyle
2024-06-03 11:40:24 +02:00
Ruben S. Montero 0a7a03e098 F 6441: Introduce FLOATING_ONLY for Virtual Router
The new attribute does not allocate extra IPs on NICs with FLOATING_IP =
yes and FLOATING_ONLY = yes. The NIC will only containg a random MAC
address and VROUTER_IP/MAC.

This commit also checks that network mode auto is not used for NIC of a
VROUTER

(cherry picked from commit 18c7816074)
2023-12-22 19:42:03 +01:00
Pavel Czerný 03add6d9ac F #6103: CppCheck version 2.10 - solved issues (#2492)
* Update smoke test checkout action

(cherry picked from commit 466d336d7e)
2023-02-14 09:51:04 +01:00
Pavel Czerný 6ee3a5ef5b F #6103: More CppCheck issues solved (#2477)
(cherry picked from commit 3fd059c543)
2023-02-02 12:54:45 +01:00
Tino Vázquez 3376afdaf0 M #-: Bump year 2023 2023-01-09 12:23:19 +01:00
865908de1c F #5989: Live update of Virtual Network attributes
co-authored-by: Pavel Czerný <pczerny@opennebula.systems>
co-authored-by: Frederick Borges <fborges@opennebula.io>
co-authored-by: Christian González <cgonzalez@opennebula.io>

* VNET updates trigger a driver action on running VMs with NICs in the
  network.

* VNET includes a sets with VM status: updated, outdated, error and
  updating. With VMs in each state.

* VNET flags error situations with a new state UPDATE_FAILURE.

* The same procedure is applied when an AR is updated (only VMs in that
  AR are updated).

* A new options in the one.vn.recover API call enable to recover or
  retry this VM update operations.

* The following attributes can be live-updated per VNET driver:
    - PHYDEV (novlan, vlan, ovs driver)
    - MTU (vlan, ovs driver)
    - VLAN_ID (vlan, ovs driver)
    - QINQ_TYPE (ovs driver)
    - CVLANS (ovs driver)
    - VLAN_TAGGED_ID (ovs driver)
    - OUTER_VLAN_ID (ovs driver)
    - INBOUND_AVG_BW (SG, ovs driver + KVM)
    - INBOUND_PEAK_BW (SG, ovs driver + KVM)
    - INBOUND_PEAK_KB (SG, ovs driver + KVM)
    - OUTBOUND_AVG_BW (SG, ovs driver + KVM)
    - OUTBOUND_PEAK_BW (SG, ovs driver + KVM)
    - OUTBOUND_PEAK_KB (SG, ovs driver + KVM)

* New API call one.vm.updatenic, allows to update individual NICs
  without the need of detach/attach (only QoS supported).

* Update operations for: 802.1Q, bridge, fw, ovswitch, ovswitch_vxlan
  and vxlan network drivers.

* VNET attributes (old values) stored in VNET_UPDATE to allow
  implementation of update operations. The attribute is removed after a
  successful update.

* Updates to CLI onevnet (--retry option) / onevm (nicupdate command)

* XSD files updated to reflect the new data model

* Ruby and JAVA bindings updated: new VNET state and recover option, new
  VM API call.

* Suntone and Fireedge implementation (lease status, recover option, new
  states)

TODO: Virtual Functions does not support this functionality

iii
2022-11-16 15:06:49 +01:00
Tino Vazquez f7d53e75ff M #-: Bump version 6.3.85 2022-04-07 19:49:58 +02:00
Pavel Czerný de6d7dd150 B #2187: Increase AR size from 32 bit to 64 bit (#1295) 2021-06-24 10:52:46 +02:00
f1a48bdc0d F #5270, #5272: Support for Google Compute and DigitalOcean
co-authored-by: Alejandro Huertas <ahuertas@opennebula.io>
co-authored-by: Juan Antonio <jescobar@opennebula.io>
co-authored-by: Sergio Betanzos <sbetanzos@opennebula.io>
2021-05-01 21:53:09 +02:00
Vlastimil Holer 096754b63f M #-: Bump year to 2021 (#778) 2021-02-09 16:07:56 +01:00
Ruben S. MonteroandPavel Czerný 565094961a F #4936: oned refactor
* Remove duplicit methods from NebulaUtil

    * Const correctness

    * Fix minor code quality issues

    * Remove ObjectCollection::clone()

    * Minor SSLUtil interface change

co-authored-by: Pavel Czerný <pczerny@opennebula.systems>
2020-07-05 22:01:32 +02:00
Pavel Czerný 0292f690c4 F #4936: Fix valgrind issues (#64) 2020-07-02 22:52:05 +02:00
Pavel Czerný daaf132a43 F #4936: Remove 'using namespace std' from headers (#60) 2020-07-02 22:42:10 +02:00
Vlastimil Holer f3c50a5d89 M #-: Year bump to 2020 (#4634) 2020-04-30 15:00:02 +02:00
Pavel Czerný 36c79d643b F #2837: Add --force option to 'onevnet rmar' (#4511) 2020-04-14 10:49:06 +02:00
Ruben S. Montero c78e2f2006 F #3064: Do not expose internal attribute in AddressRange class 2019-09-17 17:19:04 +02:00
Alejandro Huertas Herrero 2c9bbb9642 B #3070: delete IPAM ars when deleting vnet (#3719) 2019-09-17 15:53:02 +02:00
Alejandro Huertas Herrero 536672833a F #3064: pass decrypted attributes to IPAM driver (#3706) 2019-09-16 15:51:38 +02:00
Alejandro Huertas e997d2b2b3 F #3064: encrypt address range template
The address range template in address range pool is encrypted
2019-09-13 11:35:53 +02:00
Ruben S. MonteroandAlejandro Huertas 3c2df22ad7 F #3064: separate encrypted attrs by objects
* There are encrypted attributes for VMs, Hosts and VNets
    * For VMs the user template is also encrypted
    * For VNets its address ranges attributes are also encrypted

Co-authored-by: Alejandro Huertas <ahuertas@opennebula.systems>
2019-09-12 16:25:23 +02:00
Ruben S. MonteroandPavel Czerny a742b95d83 F #3064: Unified secret handling
Co-authored-by: Pavel Czerny <pczerny@opennebula.systems>
2019-09-03 16:46:36 +02:00
Vlastimil Holer 441cf1f7f9 Bump version to 5.7.85, year to 2019 2019-01-16 11:47:59 +01:00
Alejandro Huertas Herrero 7e36bc7c74 F #2490: Add new unregister address range functionality
* Modify the IPAM driver
    * Modify AddressRangePool to call the new action script
    * Add example dummy script
2018-10-18 15:20:47 +02:00
juanmont 098ce33e79 F #1976: Test access rights to the security groups of a VNet and its ARs 2018-04-27 16:31:12 +02:00
Vlastimil Holer a4c0447ccf Bump year to 2018 (#1623) 2018-01-02 18:27:37 +01:00
Javi Fontan 8de979e42c Bump version 5.3.80 2017-05-25 16:07:35 +02:00
Ruben S. Montero ba40cffd61 F #5027: Operations (hold, release, reserve...) for IP6 no-slaac ARs 2017-02-21 16:50:45 +01:00
Ruben S. Montero 948d1d98c4 F #5027: New address range types for IP6 no SLAAC. Basic lease
functionality
2017-02-17 23:49:05 +01:00
Guillaume Oberlé f8874bb320 feature #4446: Reservations are handled always by OpenNebula's internal
IPAM. Add consistency check to IPAM results. Log error messages from
IPAM drivers. Remove unused internal AR attribute (ipam_mad)

Signed-off-by: Ruben S. Montero <rsmontero@opennebula.org>
2016-08-26 17:21:07 +02:00
Guillaume Oberlé 5ebe8c5e0d feature #4446: IPAM driver - OpenNebula core message parsing
Signed-off-by: Ruben S. Montero <rsmontero@opennebula.org>
2016-08-19 13:26:08 +02:00
Guillaume Oberlé 1772a358f5 feature #4446: Extends IPAMRequest to include driver formatting.
Implements IPAM AddressRange (callbacks still missing).

Signed-off-by: Ruben S. Montero <rsmontero@opennebula.org>
2016-08-18 21:42:24 +02:00
Guillaume Oberlé f8615d6e5c Feature #4446: Redesign of AddressRange class to include multiple
implementations. When managing leases 4 abstract methos have been added
to the interface:
  - from_vattr, to notify/request a new network from IPAM
  - allocate_addr, to set an address as used
  - get_addr, to request a free address
  - free_addr, to set an address as unused

This commits also includes an AddressRange implementation based on
OpenNebula's internal IPAM

Signed-off-by: Ruben S. Montero <rsmontero@opennebula.org>
2016-08-17 19:22:53 +02:00
Javi Fontan e1f6dee180 Update copyright notice year 2016-05-04 12:33:23 +02:00
Carlos Martín b8c5fd4cd7 Feature #3848: Remove VLAN=YES from sunstone 2016-03-31 16:24:45 +02:00
Ruben S. Montero 5761be4d10 feature #4217: Simplify Template, Attribute and PoolObjectSQL class interfaces 2016-02-05 00:33:37 +01:00
Carlos Martín 034943e6b1 Feature #4215: Filter VR leases in onevnet show 2016-01-07 16:58:54 +01:00
Jaime Melis e20fb5c4c4 Fix copyright in banners 2015-09-23 16:51:10 +02:00
Jaime Melis 8d00b74177 Change year to 2015 2015-02-24 12:27:59 +01:00
Carlos Martín 788c909c0a Feature #3540: Show vnet start-end ranges for mac, ip, ipv6 2015-02-11 19:01:24 +01:00
Ruben S. Montero 18786ec0e6 feature #3175: Cache SECURITY_GROUP parsing 2014-11-11 16:27:46 +01:00