2008-06-17 16:27:32 +00:00
/* -------------------------------------------------------------------------- */
2023-01-09 12:23:19 +01:00
/* Copyright 2002-2023, OpenNebula Project, OpenNebula Systems */
2008-06-17 16:27:32 +00: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 ATTRIBUTE_H_
# define ATTRIBUTE_H_
# include <string>
# include <map>
# include <sstream>
2009-03-06 12:10:15 +00:00
# include <algorithm>
2008-06-17 16:27:32 +00:00
2016-03-03 12:32:36 +01:00
# include "NebulaUtil.h"
2008-06-17 16:27:32 +00:00
/**
* Attribute base class for name - value pairs . This class provides a generic
2009-03-06 12:10:15 +00:00
* interface to implement
2008-06-17 16:27:32 +00:00
*/
class Attribute
{
public :
2023-03-08 15:52:20 +01:00
Attribute ( const std : : string & aname )
: attribute_name ( aname )
2008-06-17 16:27:32 +00:00
{
2023-03-08 15:52:20 +01:00
one_util : : toupper ( attribute_name ) ;
2011-05-08 02:13:37 +02:00
// FIX Attribute name if it does not conform XML element
// naming conventions
int size = attribute_name . size ( ) ;
2017-06-15 17:06:43 +02:00
if ( ( size > 0 & & ! ( isalpha ( aname [ 0 ] ) | | aname [ 0 ] = = ' _ ' ) ) | |
2011-05-08 02:13:37 +02:00
( size > = 3 & & ( aname [ 0 ] = = ' X ' & & aname [ 1 ] = = ' M ' & & aname [ 2 ] = = ' L ' ) ) )
{
2012-12-24 02:41:17 +01:00
attribute_name . insert ( 0 , " ONE_ " ) ;
2011-05-08 02:13:37 +02:00
}
2008-06-17 16:27:32 +00:00
} ;
virtual ~ Attribute ( ) { } ;
enum AttributeType
{
SIMPLE = 0 ,
VECTOR = 1
} ;
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
* Gets the name of the attribute .
* @ return the attribute name
*/
2020-07-02 22:42:10 +02:00
const std : : string & name ( ) const
2008-06-17 16:27:32 +00:00
{
return attribute_name ;
} ;
/**
2020-09-15 11:16:00 +02:00
* Marshall the attribute in a single string .
* @ return a string holding the attribute value .
2008-06-17 16:27:32 +00:00
*/
2020-09-15 11:16:00 +02:00
virtual std : : string marshall ( const char * _sep = 0 ) const = 0 ;
2009-03-06 12:10:15 +00:00
2009-01-26 18:25:15 +00:00
/**
2023-09-14 15:36:26 +02:00
* Write the attribute using a simple XML format .
2009-01-26 18:25:15 +00:00
*/
2019-01-30 00:10:18 +01:00
virtual void to_xml ( std : : ostringstream & s ) const = 0 ;
virtual void to_json ( std : : ostringstream & s ) const = 0 ;
virtual void to_token ( std : : ostringstream & s ) const = 0 ;
2008-06-17 16:27:32 +00:00
/**
* Builds a new attribute from a string .
*/
2020-07-02 22:42:10 +02:00
virtual void unmarshall ( const std : : string & sattr , const char * _sep = 0 ) = 0 ;
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
* Returns the attribute type
*/
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 13:35:29 +01:00
virtual AttributeType type ( ) const = 0 ;
2008-06-17 16:27:32 +00:00
2011-04-10 23:55:49 +02:00
/**
* Clones the current attribute
*/
virtual Attribute * clone ( ) const = 0 ;
2008-06-17 16:27:32 +00:00
2019-09-16 15:51:38 +02:00
/**
* Encrypt all secret attributes
*/
2020-07-02 22:42:10 +02:00
virtual void encrypt ( const std : : string & one_key , const std : : set < std : : string > & eas ) { } ;
2019-09-16 15:51:38 +02:00
/**
* Decrypt all secret attributes
*/
2020-07-02 22:42:10 +02:00
virtual void decrypt ( const std : : string & one_key , const std : : set < std : : string > & eas ) { } ;
2019-09-16 15:51:38 +02:00
2011-04-10 23:55:49 +02:00
protected :
2019-09-16 15:51:38 +02:00
2008-06-17 16:27:32 +00:00
/**
* The attribute name .
*/
2020-07-02 22:42:10 +02:00
std : : string attribute_name ;
2023-03-08 15:52:20 +01:00
static const std : : string EMPTY_ATTRIBUTE ;
2008-06-17 16:27:32 +00:00
} ;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/**
2009-03-06 12:10:15 +00:00
* The SingleAttribute class represents a simple attribute in the form
* NAME = VALUE .
2008-06-17 16:27:32 +00:00
*/
class SingleAttribute : public Attribute
{
public :
2023-01-31 13:46:09 +01:00
SingleAttribute ( const std : : string & name )
: Attribute ( name )
{ }
2008-06-17 16:27:32 +00:00
2023-01-31 13:46:09 +01:00
SingleAttribute ( const std : : string & name , const std : : string & value )
: Attribute ( name )
, attribute_value ( value )
{ }
2009-03-06 12:10:15 +00:00
2023-01-31 13:46:09 +01:00
SingleAttribute ( const SingleAttribute & sa )
: Attribute ( sa . attribute_name )
, attribute_value ( sa . attribute_value )
{ }
2011-04-10 23:55:49 +02:00
2008-06-17 16:27:32 +00:00
~ SingleAttribute ( ) { } ;
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
* Returns the attribute value , a string .
*/
2020-07-02 22:42:10 +02:00
const std : : string & value ( ) const
2008-06-17 16:27:32 +00:00
{
return attribute_value ;
} ;
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
2020-09-15 11:16:00 +02:00
* Marshall the attribute in a single string .
* @ return a string holding the attribute value .
2009-03-06 12:10:15 +00:00
*/
2020-09-15 11:16:00 +02:00
std : : string marshall ( const char * _sep = 0 ) const override
2008-06-17 16:27:32 +00:00
{
2020-09-15 11:16:00 +02:00
return attribute_value ;
2008-06-17 16:27:32 +00:00
} ;
2009-03-06 12:10:15 +00:00
2009-01-26 18:25:15 +00:00
/**
* Write the attribute using a simple XML format :
2009-03-06 12:10:15 +00:00
*
* < attribute_name > attribute_value < / attribute_name >
*
2019-01-30 00:10:18 +01:00
* @ paran s the stream to write the attribute .
2009-01-26 18:25:15 +00:00
*/
2020-03-04 16:05:57 +01:00
void to_xml ( std : : ostringstream & s ) const override
2009-01-26 18:25:15 +00:00
{
2019-01-30 00:10:18 +01:00
s < < " < " < < attribute_name < < " > " < < one_util : : escape_xml ( attribute_value )
< < " </ " < < attribute_name < < " > " ;
2009-03-06 12:10:15 +00:00
2019-01-30 00:10:18 +01:00
}
2009-03-06 12:10:15 +00:00
2020-03-04 16:05:57 +01:00
void to_json ( std : : ostringstream & s ) const override
2019-01-30 00:10:18 +01:00
{
2019-09-16 15:51:38 +02:00
one_util : : escape_json ( attribute_value , s ) ;
2019-01-30 00:10:18 +01:00
}
2020-03-04 16:05:57 +01:00
void to_token ( std : : ostringstream & s ) const override
2019-01-30 00:10:18 +01:00
{
if ( attribute_name . empty ( ) | | attribute_value . empty ( ) )
{
return ;
}
one_util : : escape_token ( attribute_name , s ) ;
s < < " = " ;
one_util : : escape_token ( attribute_value , s ) ;
s < < std : : endl ;
2009-01-26 18:25:15 +00:00
}
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
* Builds a new attribute from a string .
2009-03-06 12:10:15 +00:00
*/
2020-07-02 22:42:10 +02:00
void unmarshall ( const std : : string & sattr , const char * _sep = 0 ) override
2008-06-17 16:27:32 +00:00
{
attribute_value = sattr ;
} ;
2008-11-13 16:21:17 +00:00
/**
* Replaces the attribute value from a string .
*/
2020-07-02 22:42:10 +02:00
void replace ( const std : : string & sattr )
2008-11-13 16:21:17 +00:00
{
attribute_value = sattr ;
} ;
2008-06-17 16:27:32 +00:00
/**
* Returns the attribute type
2009-03-06 12:10:15 +00: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 13:35:29 +01:00
AttributeType type ( ) const override
2008-06-17 16:27:32 +00:00
{
return SIMPLE ;
} ;
2009-03-06 12:10:15 +00:00
2011-04-10 23:55:49 +02:00
/**
* Clones the current attribute
*/
2020-03-04 16:05:57 +01:00
Attribute * clone ( ) const override
2011-04-10 23:55:49 +02:00
{
2012-12-24 02:41:17 +01:00
return new SingleAttribute ( * this ) ;
2011-04-10 23:55:49 +02:00
} ;
2019-09-16 15:51:38 +02:00
/**
* Encrypt all secret attributes
*/
2020-07-02 22:42:10 +02:00
void encrypt ( const std : : string & one_key ,
const std : : set < std : : string > & eas ) override ;
2019-09-16 15:51:38 +02:00
/**
* Decrypt all secret attributes
*/
2020-07-02 22:42:10 +02:00
void decrypt ( const std : : string & one_key ,
const std : : set < std : : string > & eas ) override ;
2019-09-16 15:51:38 +02:00
2008-06-17 16:27:32 +00:00
private :
2020-07-02 22:42:10 +02:00
std : : string attribute_value ;
2008-06-17 16:27:32 +00:00
} ;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/**
2009-03-06 12:10:15 +00:00
* The VectorAttribute class represents an array attribute in the form
* NAME = [ VAL_NAME_1 = VAL_VALUE_1 , . . . , VAL_NAME_N = VAL_VALUE_N ] .
2008-06-17 16:27:32 +00:00
*/
class VectorAttribute : public Attribute
{
public :
2023-01-31 13:46:09 +01:00
VectorAttribute ( const std : : string & name )
: Attribute ( name )
{ }
2008-06-17 16:27:32 +00:00
2020-07-02 22:42:10 +02:00
VectorAttribute ( const std : : string & name ,
2023-01-31 13:46:09 +01:00
const std : : map < std : : string , std : : string > & value )
: Attribute ( name )
, attribute_value ( value )
{ }
2023-03-08 15:52:20 +01:00
VectorAttribute ( const VectorAttribute & va ) = default ;
2023-01-31 13:46:09 +01:00
VectorAttribute ( const VectorAttribute * va )
: Attribute ( va - > attribute_name )
, attribute_value ( va - > attribute_value )
{ }
2016-03-01 12:09:15 +01:00
2023-03-08 15:52:20 +01:00
VectorAttribute & operator = ( const VectorAttribute & va ) = default ;
2008-06-17 16:27:32 +00:00
~ VectorAttribute ( ) { } ;
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
* Returns the attribute value , a string .
*/
2020-07-02 22:42:10 +02:00
const std : : map < std : : string , std : : string > & value ( ) const
2008-06-17 16:27:32 +00:00
{
return attribute_value ;
} ;
2009-03-06 12:10:15 +00:00
2008-06-17 16:27:32 +00:00
/**
2012-06-02 02:58:46 +02:00
* Returns the string value
* @ param name of the attribute
2008-06-17 16:27:32 +00:00
*
2023-03-08 15:52:20 +01:00
* @ return copy of the value of the attribute if found , empty otherwise
*
* @ note Non const version must return copy , as subsequent call to replace or remove
* may change the value
*/
std : : string vector_value ( const std : : string & name ) ;
/**
* Returns the string value
* @ param name of the attribute
*
* @ return reference of the value of the attribute if found , empty otherwise
*
* @ note It ' s safe to return reference here , as we are using
* the const object , which can ' t change the value
2008-06-17 16:27:32 +00:00
*/
2023-03-08 15:52:20 +01:00
const std : : string & vector_value ( const std : : string & name ) const ;
2009-03-06 12:10:15 +00:00
2015-02-18 12:16:16 +01:00
/**
2016-02-04 13:10:42 +01:00
* Returns the value of the given element of the VectorAttribute
2012-12-24 02:41:17 +01:00
*
2016-02-04 13:10:42 +01:00
* @ param name of the attribute
* @ param value , not set if the element is not found of has invalid type
2012-03-06 18:44:22 +01:00
*
* @ return 0 on success , - 1 otherwise
*/
2016-02-04 13:10:42 +01:00
template < typename T >
2020-07-02 22:42:10 +02:00
int vector_value ( const std : : string & name , T & value ) const
2016-02-04 13:10:42 +01:00
{
2020-07-02 22:42:10 +02:00
auto it = attribute_value . find ( name ) ;
2014-05-02 14:11:36 +02:00
2016-02-04 13:10:42 +01:00
if ( it = = attribute_value . end ( ) )
{
return - 1 ;
}
2013-10-17 12:35:19 +02:00
2016-02-04 13:10:42 +01:00
if ( it - > second . empty ( ) )
{
return - 1 ;
}
2021-06-24 10:52:46 +02:00
if ( std : : is_unsigned < T > : : value )
{
// Do not accept negative values for unsigned
if ( one_util : : trim ( it - > second ) [ 0 ] = = ' - ' )
{
return - 1 ;
}
}
2020-07-02 22:42:10 +02:00
std : : istringstream iss ( it - > second ) ;
2016-02-04 13:10:42 +01:00
iss > > value ;
if ( iss . fail ( ) | | ! iss . eof ( ) )
{
return - 1 ;
}
return 0 ;
}
2020-03-04 16:05:57 +01:00
/**
* Returns the value of the given element of the VectorAttribute .
* If element is invalid , returns default value
*
* @ param name of the attribute
* @ param value always set , if element is invalid set default_value
* @ param default_value used if element is invalid
*/
template < typename T >
2020-07-02 22:42:10 +02:00
void vector_value ( const std : : string & name ,
T & value ,
const T & default_value ) const
2020-03-04 16:05:57 +01:00
{
if ( vector_value ( name , value ) ! = 0 )
{
value = default_value ;
}
}
2020-07-02 22:42:10 +02:00
int vector_value ( const std : : string & name , std : : string & value ) const ;
2016-02-04 13:10:42 +01:00
2020-07-02 22:42:10 +02:00
int vector_value ( const std : : string & name , bool & value ) const ;
2012-07-16 17:15:22 +02:00
2012-05-29 00:36:13 +02:00
/**
2016-04-19 16:22:37 +02:00
* Returns the value of the given element of the VectorAttribute
2012-05-29 00:36:13 +02:00
*
* @ param name Name of the attribute
2012-07-16 17:15:22 +02:00
* @ param value Integer value , if an error occurred the string returned is
2016-02-04 13:10:42 +01:00
* empty and value is not set
2012-05-29 00:36:13 +02:00
*
* @ return the value in string form on success , " " otherwise
*/
2016-02-04 13:10:42 +01:00
template < typename T >
2023-03-08 15:52:20 +01:00
const std : : string & vector_value_str ( const std : : string & name , T & value ) const
2016-02-04 13:10:42 +01:00
{
2020-07-02 22:42:10 +02:00
auto it = attribute_value . find ( name ) ;
2016-02-04 13:10:42 +01:00
if ( it = = attribute_value . end ( ) )
{
2023-03-08 15:52:20 +01:00
return EMPTY_ATTRIBUTE ;
2016-02-04 13:10:42 +01:00
}
if ( it - > second . empty ( ) )
{
2023-03-08 15:52:20 +01:00
return EMPTY_ATTRIBUTE ;
2016-02-04 13:10:42 +01:00
}
2020-07-02 22:42:10 +02:00
std : : istringstream iss ( it - > second ) ;
2016-02-04 13:10:42 +01:00
iss > > value ;
if ( iss . fail ( ) | | ! iss . eof ( ) )
{
2023-03-08 15:52:20 +01:00
return EMPTY_ATTRIBUTE ;
2016-02-04 13:10:42 +01:00
}
return it - > second ;
}
2012-07-16 18:28:58 +02:00
2008-06-17 16:27:32 +00:00
/**
* Marshall the attribute in a single string . The string MUST be freed
2009-03-06 12:10:15 +00:00
* by the calling function . The string is in the form :
2008-06-17 16:27:32 +00:00
* " VAL_NAME_1=VAL_VALUE_1,...,VAL_NAME_N=VAL_VALUE_N " .
* @ return a string ( allocated in the heap ) holding the attribute value .
2009-03-06 12:10:15 +00:00
*/
2020-09-15 11:16:00 +02:00
std : : string marshall ( const char * _sep = 0 ) const override ;
2009-03-06 12:10:15 +00:00
2009-01-26 18:25:15 +00:00
/**
* Write the attribute using a simple XML format :
2009-03-06 12:10:15 +00:00
*
2009-01-26 18:25:15 +00:00
* < attribute_name >
* < val_name_1 > val_value_1 < / val_name_1 >
* . . .
* < val_name_n > val_value_n < / val_name_n >
2009-03-06 12:10:15 +00:00
* < / attribute_name >
2009-01-26 18:25:15 +00:00
*/
2020-03-04 16:05:57 +01:00
void to_xml ( std : : ostringstream & s ) const override ;
2008-06-17 16:27:32 +00:00
2020-03-04 16:05:57 +01:00
void to_json ( std : : ostringstream & s ) const override ;
2019-01-30 00:10:18 +01:00
2020-03-04 16:05:57 +01:00
void to_token ( std : : ostringstream & s ) const override ;
2014-05-08 15:48:16 +02:00
2008-06-17 16:27:32 +00:00
/**
* Builds a new attribute from a string of the form :
* " VAL_NAME_1=VAL_VALUE_1,...,VAL_NAME_N=VAL_VALUE_N " .
2009-03-06 12:10:15 +00:00
*/
2020-07-02 22:42:10 +02:00
void unmarshall ( const std : : string & sattr , const char * _sep = 0 ) override ;
2008-11-13 16:21:17 +00:00
/**
* Replace the value of the given attribute with the provided map
*/
2020-07-02 22:42:10 +02:00
void replace ( const std : : map < std : : string , std : : string > & attr ) ;
2008-11-13 16:21:17 +00:00
2014-07-10 16:24:25 +02:00
/**
* The attributes from vattr will be copied to this vector
* @ param attr Vector attribute to merge
* @ param replace True to replace existing values , false to copy values
* only if they don ' t exist in this vector attribute
*/
2023-09-14 15:36:26 +02:00
void merge ( const VectorAttribute * vattr , bool replace ) ;
2014-07-10 16:24:25 +02:00
2009-04-03 23:34:33 +00:00
/**
* Replace the value of the given vector attribute
*/
2016-02-04 13:10:42 +01:00
template < typename T >
2023-03-08 15:52:20 +01:00
void replace ( const std : : string & name , const T & value )
2013-10-17 12:35:19 +02:00
{
2020-07-02 22:42:10 +02:00
std : : ostringstream oss ;
2013-10-17 12:35:19 +02:00
oss < < value ;
replace ( name , oss . str ( ) ) ;
}
2020-07-02 22:42:10 +02:00
void replace ( const std : : string & name , bool value )
2013-01-17 23:14:34 +01:00
{
if ( value = = true )
{
2016-02-04 13:10:42 +01:00
replace ( name , " YES " ) ;
2013-01-17 23:14:34 +01:00
}
else
{
2016-02-04 13:10:42 +01:00
replace ( name , " NO " ) ;
2013-01-17 23:14:34 +01:00
}
}
2020-07-02 22:42:10 +02:00
void replace ( const std : : string & name , const std : : string & value ) ;
2016-02-04 13:10:42 +01:00
2012-06-13 18:42:42 +02:00
/**
2020-10-16 12:33:20 +02:00
* Removes the given attribute from the vector
* @ param name of the attribute
2012-06-13 18:42:42 +02:00
*/
2020-07-02 22:42:10 +02:00
void remove ( const std : : string & name ) ;
2012-06-13 18:42:42 +02:00
2008-06-17 16:27:32 +00:00
/**
* Returns the attribute type
2009-03-06 12:10:15 +00: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 13:35:29 +01:00
AttributeType type ( ) const override
2008-06-17 16:27:32 +00:00
{
return VECTOR ;
} ;
2011-04-10 23:55:49 +02:00
/**
* Clones the current attribute
*/
2020-03-04 16:05:57 +01:00
VectorAttribute * clone ( ) const override
2011-04-10 23:55:49 +02:00
{
2012-12-24 02:41:17 +01:00
return new VectorAttribute ( * this ) ;
2011-04-10 23:55:49 +02:00
} ;
2014-05-08 15:48:16 +02:00
/**
* Clear the vector attribute values
*/
void clear ( )
{
attribute_value . clear ( ) ;
}
2018-03-26 18:58:04 +02:00
/**
* @ return true if the vector attribute contains no values
*/
2020-09-25 12:08:42 +02:00
bool empty ( ) const
2018-03-26 18:58:04 +02:00
{
return attribute_value . empty ( ) ;
}
2019-09-16 15:51:38 +02:00
/**
* Encrypt all secret attributes
*/
2020-07-02 22:42:10 +02:00
void encrypt ( const std : : string & one_key ,
const std : : set < std : : string > & eas ) override ;
2019-09-16 15:51:38 +02:00
/**
* Decrypt all secret attributes
*/
2020-07-02 22:42:10 +02:00
void decrypt ( const std : : string & one_key ,
const std : : set < std : : string > & eas ) override ;
2019-09-16 15:51:38 +02:00
2008-06-17 16:27:32 +00:00
private :
2009-03-06 12:10:15 +00:00
2015-07-01 15:15:40 -04:00
static const char * magic_sep ;
2009-03-06 12:10:15 +00:00
2015-07-01 15:15:40 -04:00
static const int magic_sep_size ;
2008-06-17 16:27:32 +00:00
2020-07-02 22:42:10 +02:00
std : : map < std : : string , std : : string > attribute_value ;
2008-06-17 16:27:32 +00:00
} ;
# endif /*ATTRIBUTE_H_*/