1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

feature #3028: Adds PCI_DEVICES to HostShare

This commit is contained in:
Ruben S. Montero 2015-08-17 23:14:15 +02:00
parent 3ec2134ac3
commit 6b8a16fc76
3 changed files with 55 additions and 4 deletions

View File

@ -29,7 +29,7 @@ using namespace std;
class HostShareTemplate : public Template
{
public:
HostShareTemplate() : Template(false,'=',"DATASTORES"){};
HostShareTemplate(const char * name) : Template(false, '=', name){};
~HostShareTemplate(){};
};
@ -125,6 +125,8 @@ public:
void set_ds_monitorization(const vector<Attribute*> &ds_att);
void set_pci_monitorization(const vector<Attribute*> &pci_att);
private:
long long disk_usage; /**< Disk allocated to VMs (in MB). */
@ -146,6 +148,7 @@ private:
long long running_vms;/**< Number of running VMs in this Host */
HostShareTemplate ds_template;
HostShareTemplate pci_template;
// ----------------------------------------
// Friends

View File

@ -256,6 +256,7 @@ int Host::update_info(Template &tmpl,
vector<Attribute*>::iterator it;
vector<Attribute*> vm_att;
vector<Attribute*> ds_att;
vector<Attribute*> pci_att;
vector<Attribute*> local_ds_att;
int rc;
@ -465,6 +466,10 @@ int Host::update_info(Template &tmpl,
host_share.set_ds_monitorization(local_ds_att);
obj_template->remove("PCI", pci_att);
host_share.set_pci_monitorization(pci_att);
return 0;
}

View File

@ -41,7 +41,9 @@ HostShare::HostShare(long long _max_disk,long long _max_mem,long long _max_cpu):
used_disk(0),
used_mem(0),
used_cpu(0),
running_vms(0){};
running_vms(0),
ds_template("DATASTORES"),
pci_template("PCI_DEVICES"){};
ostream& operator<<(ostream& os, HostShare& hs)
{
@ -57,7 +59,7 @@ ostream& operator<<(ostream& os, HostShare& hs)
string& HostShare::to_xml(string& xml) const
{
string template_xml;
string ds_xml, pci_xml;
ostringstream oss;
oss << "<HOST_SHARE>"
@ -74,7 +76,8 @@ string& HostShare::to_xml(string& xml) const
<< "<USED_MEM>" << used_mem << "</USED_MEM>"
<< "<USED_CPU>" << used_cpu << "</USED_CPU>"
<< "<RUNNING_VMS>"<<running_vms <<"</RUNNING_VMS>"
<< ds_template.to_xml(template_xml)
<< ds_template.to_xml(ds_xml)
<< pci_template.to_xml(pci_xml)
<< "</HOST_SHARE>";
xml = oss.str();
@ -131,9 +134,33 @@ int HostShare::from_xml_node(const xmlNodePtr node)
return -1;
}
// ------------ DS Template ---------------
ObjectXML::get_nodes("/HOST_SHARE/PCI_DEVICES", content);
if( content.empty())
{
return -1;
}
rc += pci_template.from_xml_node( content[0] );
ObjectXML::free_nodes(content);
content.clear();
if (rc != 0)
{
return -1;
}
return 0;
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
void HostShare::set_ds_monitorization(const vector<Attribute*> &ds_att)
{
vector<Attribute*>::const_iterator it;
@ -145,3 +172,19 @@ void HostShare::set_ds_monitorization(const vector<Attribute*> &ds_att)
ds_template.set(*it);
}
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
void HostShare::set_pci_monitorization(const vector<Attribute*> &pci_att)
{
vector<Attribute*>::const_iterator it;
pci_template.erase("PCI");
for (it = pci_att.begin(); it != pci_att.end(); it++)
{
pci_template.set(*it);
}
}