2014-05-09 23:20:09 +04:00
/* -------------------------------------------------------------------------- */
2024-07-29 15:25:20 +03:00
/* Copyright 2002-2024, OpenNebula Project, OpenNebula Systems */
2014-05-09 23:20:09 +04:00
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
# ifndef ADDRESS_RANGE_POOL_H_
# define ADDRESS_RANGE_POOL_H_
# include <string>
# include <vector>
# include <map>
2014-11-11 18:27:46 +03:00
# include <set>
2014-05-09 23:20:09 +04:00
2019-09-12 19:24:23 +03:00
# include "VirtualNetworkTemplate.h"
2014-05-29 14:44:41 +04:00
# include "PoolObjectSQL.h"
2014-05-09 23:20:09 +04:00
2014-05-10 21:46:27 +04:00
class VectorAttribute ;
2014-05-29 14:44:41 +04:00
class AddressRange ;
2014-05-10 21:46:27 +04:00
2014-05-09 23:20:09 +04:00
class AddressRangePool
{
2014-05-10 03:22:02 +04:00
public :
2014-05-09 23:20:09 +04:00
AddressRangePool ( ) ;
virtual ~ AddressRangePool ( ) ;
2014-05-27 19:19:36 +04:00
// *************************************************************************
// Inititalization functions
// *************************************************************************
2014-05-09 23:20:09 +04:00
/**
2014-05-29 17:36:20 +04:00
* Builds the address range from a VectorAttribute . This function is used
* to create address ranges .
2014-05-09 23:20:09 +04:00
* @ param ars the vector of address ranges
* @ param error_msg describing the error
* @ return 0 on success
*/
2020-07-02 23:42:10 +03:00
int from_vattr ( VectorAttribute * ar , std : : string & error_msg ) ;
2014-05-09 23:20:09 +04:00
/**
* Builds the address range set from its XML representation . This function
* is used to rebuild the address ranges from the DB .
* @ param node xmlNode for the template
* @ return 0 on success
*/
int from_xml_node ( const xmlNodePtr node ) ;
2014-05-27 19:19:36 +04:00
// *************************************************************************
// Address Range management interface
// *************************************************************************
2014-05-22 22:20:33 +04:00
/**
* Removes an address range from the pool if it does not contain any used
* leases
* @ param arid of the address range to be removed
2020-04-14 11:49:06 +03:00
* @ param force force remove , even if active leases exists
2014-05-22 22:20:33 +04:00
* @ return 0 on success , - 1 if not exists or has used addresses
*/
2020-07-02 23:42:10 +03:00
int rm_ar ( unsigned int ar_id , bool force , std : : string & error_msg ) ;
2014-05-22 22:20:33 +04:00
2019-09-17 16:53:02 +03:00
/**
* Removes all address ranges from the pool if it does not contain any used
* leases
* @ return 0 on success , - 1 if not exists or has used addresses
*/
2020-07-02 23:42:10 +03:00
int rm_ars ( std : : string & error_msg ) ;
2019-09-17 16:53:02 +03:00
2014-05-23 02:24:14 +04:00
/**
* Updates the given address ranges
2014-06-16 19:56:50 +04:00
* @ param ars vector of address ranges as VectorAttributes obtained from
* template in the form AR = [ . . . ] . Only one AR is processed .
2014-09-04 15:38:11 +04:00
* @ param keep_restricted If true , the restricted attributes of the
* current template will override the new template
2014-06-16 19:56:50 +04:00
* @ param error_msg If the action fails , this message contains
* the reason .
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:35:29 +03:00
* @ param update_attr Updated attributes with old values . Caller must
* release the pointer .
2014-06-16 19:56:50 +04:00
* @ return 0 on success
2014-05-23 02:24:14 +04:00
*/
2020-07-02 23:42:10 +03:00
int update_ar ( std : : vector < VectorAttribute * > ars , bool keep_restricted ,
2024-06-03 12:40:24 +03:00
std : : set < int > & update_ids , std : : unique_ptr < VectorAttribute > & update_attr ,
std : : string & error_msg ) ;
2014-05-10 21:46:27 +04:00
/**
2014-05-29 14:44:41 +04:00
* Allocates a new * empty * address range . It is not added to the pool as it
* needs to be initialized . Only the AR_ID is set .
2016-08-17 20:22:53 +03:00
* @ param ipam_mad sets the type of AddressRange to be created : internal ,
* IPAM . . .
2014-05-29 14:44:41 +04:00
* @ return the new address range .
2014-05-10 21:46:27 +04:00
*/
2020-07-02 23:42:10 +03:00
AddressRange * allocate_ar ( const std : : string & ipam_mad ) ;
2014-05-27 19:19:36 +04:00
2014-05-29 14:44:41 +04:00
/**
* Adds a new address range to the pool . It should be allocated by the
* allocate_ar ( ) function .
* @ param ar the new address range ;
* @ return 0 on success
*/
int add_ar ( AddressRange * ar ) ;
2014-05-27 19:19:36 +04:00
// *************************************************************************
// Address allocation interface
// *************************************************************************
2014-05-10 03:22:02 +04:00
2014-05-10 21:46:27 +04:00
/**
* Allocates an address in a suitable address range from the pool
* @ param ot the type of the object requesting the address ( VM or NET )
* @ param obid the id of the object requesting the address
* @ param nic the NIC attribute to be filled with lease attributes
* @ param inherit attributes to be added to the NIC
* @ return 0 if success
*/
2014-05-10 23:06:59 +04:00
int allocate_addr ( PoolObjectSQL : : ObjectType ot , int obid ,
2024-06-03 12:40:24 +03:00
VectorAttribute * nic , const std : : set < std : : string > & inherit ) ;
2014-05-10 21:46:27 +04:00
/**
2017-02-21 18:50:45 +03:00
* Allocates an address in a suitable address range from the pool by mac / ip
* @ param mac / ip the specific MAC / IP address requested
2014-05-10 21:46:27 +04:00
* @ param ot the type of the object requesting the address ( VM or NET )
* @ param obid the id of the object requesting the address
* @ param nic the NIC attribute to be filled with lease attributes
* @ param inherit attributes to be added to the NIC
* @ return 0 if success
*/
2020-07-02 23:42:10 +03:00
int allocate_by_mac ( const std : : string & mac , PoolObjectSQL : : ObjectType ot ,
int obid , VectorAttribute * nic ,
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:35:29 +03:00
const std : : set < std : : string > & inherit ) ;
2014-05-10 21:46:27 +04:00
2020-07-02 23:42:10 +03:00
int allocate_by_ip ( const std : : string & ip , PoolObjectSQL : : ObjectType ot ,
int obid , VectorAttribute * nic ,
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:35:29 +03:00
const std : : set < std : : string > & inherit ) ;
2014-05-10 21:46:27 +04:00
2020-07-02 23:42:10 +03:00
int allocate_by_ip6 ( const std : : string & ip , PoolObjectSQL : : ObjectType ot ,
int obid , VectorAttribute * nic ,
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:35:29 +03:00
const std : : set < std : : string > & inherit ) ;
2014-05-19 02:28:27 +04:00
/**
* Holds an address from the specified address range .
* @ param arid of the address range
2017-02-21 18:50:45 +03:00
* @ param mac / ip the mac / ip to hold
2014-05-19 02:28:27 +04:00
* @ return 0 on success
*/
2020-07-02 23:42:10 +03:00
int hold_by_mac ( unsigned int arid , const std : : string & mac ) ;
2014-05-19 02:28:27 +04:00
2020-07-02 23:42:10 +03:00
int hold_by_ip ( unsigned int arid , const std : : string & ip ) ;
2017-02-21 18:50:45 +03:00
2020-07-02 23:42:10 +03:00
int hold_by_ip6 ( unsigned int arid , const std : : string & ip ) ;
2017-02-21 18:50:45 +03:00
2014-05-19 02:28:27 +04:00
/**
* Holds an address from the first address range containing the MAC
2017-02-21 18:50:45 +03:00
* @ param mac / ip the mac / ip to hold
2014-05-19 02:28:27 +04:00
* @ return 0 on success
*/
2020-07-02 23:42:10 +03:00
int hold_by_mac ( const std : : string & mac ) ;
2014-05-19 02:28:27 +04:00
2020-07-02 23:42:10 +03:00
int hold_by_ip ( const std : : string & ip ) ;
2017-02-21 18:50:45 +03:00
2020-07-02 23:42:10 +03:00
int hold_by_ip6 ( const std : : string & ip ) ;
2017-02-21 18:50:45 +03:00
2014-05-10 21:46:27 +04:00
/**
2017-02-21 18:50:45 +03:00
* Frees the given address by MAC / IP on the given address range
2014-05-10 21:46:27 +04:00
* @ param arid the ID of the address range
* @ param ot the type of the object requesting the address ( VM or NET )
* @ param obid the id of the object requesting the address
2017-02-21 18:50:45 +03:00
* @ param mac / ip the specific MAC / IP address requested
2014-05-10 21:46:27 +04:00
*/
void free_addr ( unsigned int arid , PoolObjectSQL : : ObjectType ot , int obid ,
2024-06-03 12:40:24 +03:00
const std : : string & mac ) ;
2014-05-10 21:46:27 +04:00
2014-05-19 19:59:06 +04:00
void free_addr_by_ip ( unsigned int arid , PoolObjectSQL : : ObjectType ot ,
2024-06-03 12:40:24 +03:00
int obid , const std : : string & ip ) ;
2014-05-19 19:59:06 +04:00
2017-02-21 18:50:45 +03:00
void free_addr_by_ip6 ( unsigned int arid , PoolObjectSQL : : ObjectType ot ,
2024-06-03 12:40:24 +03:00
int obid , const std : : string & ip ) ;
2017-02-21 18:50:45 +03:00
2014-05-19 19:59:06 +04:00
/**
2017-02-21 18:50:45 +03:00
* Frees the given address by MAC / IP from all address ranges containing
* the MAC / IP
2014-05-19 19:59:06 +04:00
* @ param ot the type of the object requesting the address ( VM or NET )
* @ param obid the id of the object requesting the address
2017-02-21 18:50:45 +03:00
* @ param mac / ip the specific MAC / IP address requested
2014-05-19 19:59:06 +04:00
*/
2020-07-02 23:42:10 +03:00
void free_addr ( PoolObjectSQL : : ObjectType ot , int obid ,
const std : : string & mac ) ;
2014-05-19 19:59:06 +04:00
2020-07-02 23:42:10 +03:00
void free_addr_by_ip ( PoolObjectSQL : : ObjectType ot , int id ,
const std : : string & ip ) ;
2014-05-19 19:59:06 +04:00
2020-07-02 23:42:10 +03:00
void free_addr_by_ip6 ( PoolObjectSQL : : ObjectType ot , int id ,
const std : : string & ip ) ;
2017-02-21 18:50:45 +03:00
2014-05-27 19:19:36 +04:00
/**
* Frees all the addressed owned by the given object
* @ param ot the type of the object requesting the address ( VM or NET )
* @ param obid the id of the object requesting the address
2014-05-30 14:56:35 +04:00
* @ return the number of addresses freed
2014-05-27 19:19:36 +04:00
*/
2014-05-30 14:56:35 +04:00
int free_addr_by_owner ( PoolObjectSQL : : ObjectType ot , int obid ) ;
2014-05-27 19:19:36 +04:00
2014-06-02 21:18:05 +04:00
/**
* Frees the given address range
* @ param arid the ID of the address range
* @ param ot the type of the object requesting the address ( VM or NET )
* @ param obid the id of the object requesting the address
* @ param mac the first MAC address in the range
* @ param rsize size of the address range
*/
2014-06-03 17:13:26 +04:00
int free_addr_by_range ( unsigned int arid , PoolObjectSQL : : ObjectType ot ,
2024-06-03 12:40:24 +03:00
int obid , const std : : string & mac , unsigned int rsize ) ;
2014-06-02 21:18:05 +04:00
2014-10-10 18:52:51 +04:00
/**
* From a Security Group rule that uses this vnet , creates a new rule
* copy for each AR .
*
* @ param rule original rule
* @ param new_rules vector where the new rules will be placed . Rules must
* be deleted by the caller
*/
void process_security_rule (
2020-07-02 23:42:10 +03:00
VectorAttribute * rule ,
std : : vector < VectorAttribute * > & new_rules ) ;
2014-10-10 18:52:51 +04:00
2014-05-27 19:19:36 +04:00
// *************************************************************************
// Address reservation
// *************************************************************************
/**
* Reserve a given number of addresses from the first address range with
* enough free addresses to allocate the reservation
* @ param vid the id of the VNET making the reservation
* @ param size number of addresses to reserve
* @ param rar a new address range to place the reservation
* @ return 0 on success
*/
2014-05-30 20:59:25 +04:00
int reserve_addr ( int vid , unsigned int rsize , AddressRange * rar ) ;
2014-05-27 19:19:36 +04:00
2014-05-29 14:44:41 +04:00
/**
* Reserve a given number of addresses from the given address range
* @ param vid the id of the VNET making the reservation
* @ param rsize number of addresses to reserve
* @ param ar_id the address range to reserve the addresses from
* @ param rar a new address range to place the reservation
* @ return 0 on success
*/
2014-05-30 20:59:25 +04:00
int reserve_addr ( int vid , unsigned int rsize , unsigned int ar_id ,
2024-06-03 12:40:24 +03:00
AddressRange * rar ) ;
2014-05-29 14:44:41 +04:00
2014-05-30 01:55:51 +04:00
/**
2017-02-21 18:50:45 +03:00
* Reserve a number of addresses from an address range from a given ip / mac
2014-05-30 01:55:51 +04:00
* @ param vid the id of the VNET making the reservation
* @ param rsize number of addresses to reserve
* @ param ar_id the address range to reserve the addresses from
2017-02-21 18:50:45 +03:00
* @ param mac / ip the first MAC / IP in the reservation
2014-05-30 01:55:51 +04:00
* @ param rar a new address range to place the reservation
* @ return 0 on success
*/
2017-02-21 18:50:45 +03:00
int reserve_addr_by_mac ( int vid , unsigned int rsize , unsigned int ar_id ,
2024-06-03 12:40:24 +03:00
const std : : string & mac , AddressRange * rar ) ;
2017-02-21 18:50:45 +03:00
2014-05-30 20:59:25 +04:00
int reserve_addr_by_ip ( int vid , unsigned int rsize , unsigned int ar_id ,
2024-06-03 12:40:24 +03:00
const std : : string & ip , AddressRange * rar ) ;
2014-05-30 01:55:51 +04:00
2017-02-21 18:50:45 +03:00
int reserve_addr_by_ip6 ( int vid , unsigned int rsize , unsigned int ar_id ,
2024-06-03 12:40:24 +03:00
const std : : string & ip , AddressRange * rar ) ;
2017-02-21 18:50:45 +03:00
2014-05-27 19:19:36 +04:00
// *************************************************************************
// Helpers & Formatting
// *************************************************************************
2014-05-10 23:44:39 +04:00
/**
* Return the number of used addresses
*/
unsigned int get_used_addr ( ) const
{
return used_addr ;
}
2014-06-03 18:09:26 +04:00
/**
* Return the total number addresses
*/
unsigned int get_size ( ) const ;
2014-06-02 21:18:05 +04:00
/**
* Return the parent id of an address range
* @ param ar_id of the address range
* @ return the parent ar id , - 1 if none
*/
int get_ar_parent ( int ar_id ) const ;
2014-05-22 22:20:33 +04:00
/**
* Gets an attribute from the Address Range
* @ param name of the attribute
* @ param value of the attribute
* @ param ar_id to get the attribute from
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:35:29 +03:00
* @ return 0 on success
2014-05-22 22:20:33 +04:00
*/
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:35:29 +03:00
int get_attribute ( const std : : string & name , std : : string & value , int ar_id ) const ;
2014-05-17 03:17:58 +04:00
2014-06-02 21:18:05 +04:00
/**
* Gets an attribute from the Address Range , int version
* @ param name of the attribute
* @ param value of the attribute
* @ param ar_id to get the attribute from
* @ return 0 on success
*/
2020-07-02 23:42:10 +03:00
int get_attribute ( const std : : string & name , int & value , int ar_id ) const ;
2014-06-02 21:18:05 +04:00
2014-11-11 18:27:46 +03:00
/**
* Gets a reference to a the security group set of an AR
* @ return a reference to the security group set or empty set if error
*/
2020-07-02 23:42:10 +03:00
const std : : set < int > & get_security_groups ( int ar_id ) const ;
2014-11-11 18:27:46 +03:00
2018-04-27 17:31:12 +03:00
/**
* Gets a the security group set of all ARs
* @ param sgs set with all the SG ids
*/
2020-07-05 23:01:32 +03:00
void get_all_security_groups ( std : : set < int > & sgs ) const ;
2018-04-27 17:31:12 +03:00
2014-05-27 19:19:36 +04:00
/**
* Generate a XML representation of the Address Range Pool
* @ param sstream where the ARPool is written
* @ param extended true to include lease information
2014-09-11 19:00:27 +04:00
* @ param vm_ids list of VM the user can access VNET usage info from .
* A vector containing just - 1 means all VMs .
* @ param vnet_ids list of VNET the user can access reservation info from .
* A vector containing just - 1 means all VNETs .
2016-01-07 18:58:54 +03:00
* @ param vrs list of VRouter the user can access VNET usage info from .
* A vector containing just - 1 means all VRouters .
2014-05-27 19:19:36 +04:00
* @ return the string with the XML
*/
2020-07-02 23:42:10 +03:00
std : : string & to_xml ( std : : string & sstream ,
bool extended ,
const std : : vector < int > & vms ,
const std : : vector < int > & vnets ,
const std : : vector < int > & vrs ) const ;
2014-05-27 19:19:36 +04:00
2019-09-12 17:25:23 +03:00
/**
* Encrypt all secret attributes
*/
2019-09-12 19:24:23 +03:00
void encrypt ( const std : : string & one_key )
{
ar_template . encrypt ( one_key ) ;
} ;
2019-09-12 17:25:23 +03:00
/**
* Decrypt all secret attributes
*/
2019-09-12 19:24:23 +03:00
void decrypt ( const std : : string & one_key )
{
ar_template . decrypt ( one_key ) ;
} ;
2019-09-12 17:25:23 +03:00
2014-05-09 23:20:09 +04:00
private :
2014-05-10 21:46:27 +04:00
/**
* Stores the Address Ranges in a template form . This template is used
* to store the pool in the DB
*/
2019-09-12 19:24:23 +03:00
VirtualNetworkTemplate ar_template ;
2014-05-09 23:20:09 +04:00
2014-05-10 21:46:27 +04:00
/**
* ID for the next Address Range
*/
2014-05-09 23:20:09 +04:00
unsigned int next_ar ;
2014-05-10 21:46:27 +04:00
/**
* Map to access each range
*/
2020-07-02 23:42:10 +03:00
std : : map < unsigned int , AddressRange * > ar_pool ;
2014-05-10 23:44:39 +04:00
/**
* Used addresses
*/
unsigned int used_addr ;
2016-08-17 20:22:53 +03:00
/**
* Allocates a new * empty * address range . It is not added to the pool as it
* needs to be initialized .
* @ param ipam_mad sets the type of AddressRange to be created : internal ,
* IPAM . . .
* @ param ar_id for the AddressRange
* @ return the new address range .
*/
2020-07-02 23:42:10 +03:00
AddressRange * allocate_ar ( const std : : string & ipam_mad , unsigned int ar_id ) ;
2014-05-09 23:20:09 +04:00
} ;
# endif