mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 11:22:55 +09:00
feature #2858: Better check for class types. Single AR addtion to prevent out-of-sync NETs
This commit is contained in:
1 parent
ab6de3ae02
commit
8f752d3dd7
2 files changed
+21
-5
No files matched your search
@@ -90,7 +90,7 @@ void AddressRangePool::update_ar(vector<Attribute *> ars)
|
||||
|
||||
for (it = ars.begin(); it != ars.end(); it++)
|
||||
{
|
||||
VectorAttribute * va = static_cast<VectorAttribute *>(*it);
|
||||
VectorAttribute * va = dynamic_cast<VectorAttribute *>(*it);
|
||||
|
||||
if (va == 0)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ int AddressRangePool::rm_ar(unsigned int ar_id, string& error_msg)
|
||||
|
||||
for (it_ar=ars.begin(); it_ar!=ars.end(); it_ar++)
|
||||
{
|
||||
VectorAttribute *ar = static_cast<VectorAttribute *>(*it_ar);
|
||||
VectorAttribute *ar = dynamic_cast<VectorAttribute *>(*it_ar);
|
||||
|
||||
if (ar == 0)
|
||||
{
|
||||
|
||||
@@ -591,7 +591,7 @@ int VirtualNetwork::add_var(vector<Attribute *> &var, string& error_msg)
|
||||
{
|
||||
for (vector<Attribute *>::iterator it=var.begin(); it!=var.end(); it++)
|
||||
{
|
||||
VectorAttribute * oar = static_cast<VectorAttribute *>(*it);
|
||||
VectorAttribute * oar = dynamic_cast<VectorAttribute *>(*it);
|
||||
|
||||
if (oar == 0)
|
||||
{
|
||||
@@ -617,9 +617,25 @@ int VirtualNetwork::add_ar(VirtualNetworkTemplate * ars_tmpl, string& error_msg)
|
||||
{
|
||||
vector<Attribute *> var;
|
||||
|
||||
if (ars_tmpl->get("AR", var) > 0)
|
||||
if (ars_tmpl->get("AR", var) <= 0)
|
||||
{
|
||||
return add_var(var, error_msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const VectorAttribute * ar = dynamic_cast<const VectorAttribute *>(var[0]);
|
||||
|
||||
if (ar == 0)
|
||||
{
|
||||
error_msg = "Wrong AR definition";
|
||||
return -1;
|
||||
}
|
||||
|
||||
VectorAttribute * nar = ar->clone();
|
||||
|
||||
if (ar_pool.from_vattr(nar, error_msg) != 0)
|
||||
{
|
||||
delete nar;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user