mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
F #3064: Do not expose internal attribute in AddressRange class
This commit is contained in:
parent
ed7c16813e
commit
c78e2f2006
@ -391,12 +391,9 @@ public:
|
||||
}
|
||||
|
||||
/*
|
||||
* Get address range vector attribute representation
|
||||
* Decrypts the address range attributes
|
||||
*/
|
||||
VectorAttribute * get_attr()
|
||||
{
|
||||
return attr;
|
||||
}
|
||||
void decrypt();
|
||||
|
||||
/*
|
||||
* add_ar from AddressRangePool needs to access the internal representation
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "Attribute.h"
|
||||
#include "Template.h"
|
||||
|
||||
class AddressRange;
|
||||
|
||||
/**
|
||||
* The IPAMRequest class represents a request for the IPAM driver. The request
|
||||
* is in the form
|
||||
@ -39,6 +41,11 @@ public:
|
||||
|
||||
IPAMRequest(VectorAttribute * _ar_vattr, const std::string& _address_xml);
|
||||
|
||||
IPAMRequest(AddressRange * _ar) : IPAMRequest(_ar,
|
||||
"<ADDRESS><MAC/><IP/><IP6_GLOBAL/><IP6_ULA/><IP6/><SIZE/></ADDRESS>"){};
|
||||
|
||||
IPAMRequest(AddressRange * _ar, const std::string& _address_xml);
|
||||
|
||||
virtual ~IPAMRequest(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -18,11 +18,14 @@
|
||||
#include "VirtualNetworkTemplate.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
#include "AddressRange.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
IPAMRequest::IPAMRequest(VectorAttribute * _ar_vattr,
|
||||
const std::string& _address_xml)
|
||||
IPAMRequest::IPAMRequest(VectorAttribute * _ar_vattr, const std::string& _axml)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
string one_key;
|
||||
|
||||
Nebula::instance().get_configuration_attribute("ONE_KEY", one_key);
|
||||
@ -32,9 +35,20 @@ IPAMRequest::IPAMRequest(VectorAttribute * _ar_vattr,
|
||||
_ar_vattr->decrypt(one_key, ea.second);
|
||||
}
|
||||
|
||||
_ar_vattr->to_xml(oss);
|
||||
|
||||
ar_xml = oss.str();
|
||||
address_xml = _axml;
|
||||
}
|
||||
|
||||
|
||||
IPAMRequest::IPAMRequest(AddressRange * _ar, const std::string& _address_xml)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
_ar_vattr->to_xml(oss);
|
||||
_ar->decrypt();
|
||||
|
||||
_ar->to_xml(oss);
|
||||
|
||||
ar_xml = oss.str();
|
||||
address_xml = _address_xml;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "VirtualNetworkPool.h"
|
||||
#include "NebulaLog.h"
|
||||
#include "NebulaUtil.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm>
|
||||
@ -2051,3 +2052,19 @@ void AddressRange::remove_all_except_restricted(VectorAttribute* va)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void AddressRange::decrypt()
|
||||
{
|
||||
string one_key;
|
||||
|
||||
Nebula::instance().get_configuration_attribute("ONE_KEY", one_key);
|
||||
|
||||
for ( auto ea : VirtualNetworkTemplate::encrypted )
|
||||
{
|
||||
attr->decrypt(one_key, ea.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ int AddressRangeIPAM::allocate_addr(unsigned int index, unsigned int rsize,
|
||||
|
||||
address_xml = oss.str();
|
||||
|
||||
IPAMRequest ir(get_attr(), address_xml);
|
||||
IPAMRequest ir(this, address_xml);
|
||||
|
||||
ipamm->trigger(IPMAction::ALLOCATE_ADDRESS, &ir);
|
||||
|
||||
@ -101,7 +101,7 @@ int AddressRangeIPAM::get_addr(unsigned int& index, unsigned int rsize,
|
||||
|
||||
address_xml = oss.str();
|
||||
|
||||
IPAMRequest ir(get_attr(), address_xml);
|
||||
IPAMRequest ir(this, address_xml);
|
||||
|
||||
ipamm->trigger(IPMAction::GET_ADDRESS, &ir);
|
||||
|
||||
@ -158,7 +158,7 @@ int AddressRangeIPAM::free_addr(unsigned int index, std::string& error_msg)
|
||||
|
||||
address_xml = oss.str();
|
||||
|
||||
IPAMRequest ir(get_attr(), address_xml);
|
||||
IPAMRequest ir(this, address_xml);
|
||||
|
||||
ipamm->trigger(IPMAction::FREE_ADDRESS, &ir);
|
||||
|
||||
|
@ -215,7 +215,7 @@ int AddressRangePool::rm_ar(unsigned int ar_id, string& error_msg)
|
||||
{
|
||||
IPAMManager * ipamm = Nebula::instance().get_ipamm();
|
||||
|
||||
IPAMRequest ir(ar_ptr->get_attr());
|
||||
IPAMRequest ir(ar_ptr);
|
||||
|
||||
ipamm->trigger(IPMAction::UNREGISTER_ADDRESS_RANGE, &ir);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user