feature #2858: Better check for class types. Single AR addtion to prevent out-of-sync NETs

This commit is contained in:
Ruben S. Montero committed 2014-05-29 15:57:56 +02:00
1 parent ab6de3ae02
commit 8f752d3dd7
2 files changed
+21 -5

No files matched your search

+2 -2
View File
@@ -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)
{
+19 -3
View File
@@ -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;