mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 20:02:38 +09:00
feature #2858: First version of AddressRangePool
This commit is contained in:
1 parent
771b41f39f
commit
c24dfec31a
5 files changed
+185
-5
No files matched your search
@@ -775,10 +775,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Add a new history record and deploy the VM
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "AddressRangePool.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
AddressRangePool::AddressRangePool():ar_template(false,'=',"AR_POOL"),next_ar(0)
|
||||
{};
|
||||
|
||||
AddressRangePool::~AddressRangePool()
|
||||
{
|
||||
map<unsigned int, AddressRange *>::iterator it;
|
||||
|
||||
for (it=ar_pool.begin(); it!=ar_pool.end(); it++)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int AddressRangePool::from_vattr(vector<Attribute *> ars, string& error_msg)
|
||||
{
|
||||
vector<Attribute *>::iterator it;
|
||||
|
||||
/* -------------------- Init the AR pool ---------------------------- */
|
||||
|
||||
for (it = ars.begin(); it != ars.end(); it++)
|
||||
{
|
||||
VectorAttribute * va = static_cast<VectorAttribute *>(*it);
|
||||
|
||||
if (va == 0)
|
||||
{
|
||||
error_msg = "Wrong AR format";
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddressRange * ar = new AddressRange(next_ar);
|
||||
|
||||
if (ar->from_vattr(va, error_msg) != 0)
|
||||
{
|
||||
delete ar;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ar_pool.insert(make_pair(next_ar++, ar));
|
||||
}
|
||||
|
||||
/* ---------------------- Template ---------------------------------- */
|
||||
|
||||
for (it = ars.begin(); it != ars.end(); it++)
|
||||
{
|
||||
ar_template.set(*it);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int AddressRangePool::from_xml_node(const xmlNodePtr node)
|
||||
{
|
||||
int rc = ar_template.from_xml_node(node);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
vector<Attribute*> var;
|
||||
|
||||
int num_ar = ar_template.get("AR", var);
|
||||
|
||||
for (int i = 0; i < num_ar; i++)
|
||||
{
|
||||
VectorAttribute * va = static_cast<VectorAttribute *>(var[i]);
|
||||
|
||||
AddressRange * ar = new AddressRange(0);
|
||||
|
||||
if (ar->from_vattr_db(va)!= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ar_pool.insert(make_pair(ar->ar_id(), ar));
|
||||
|
||||
ar_template.set(va);
|
||||
|
||||
if (ar->ar_id() > next_ar)
|
||||
{
|
||||
next_ar = ar->ar_id() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-1
@@ -27,7 +27,8 @@ source_files=[
|
||||
'RangedLeases.cc',
|
||||
'VirtualNetwork.cc',
|
||||
'VirtualNetworkPool.cc',
|
||||
'AddressRange.cc'
|
||||
'AddressRange.cc',
|
||||
'AddressRangePool.cc'
|
||||
]
|
||||
|
||||
# Build library
|
||||
|
||||
Reference in new issue
Block a user