mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-27 13:57:23 +03:00
F #2347: Dump VMGroups in scheduler output for DEBUG
This commit is contained in:
parent
70ce346937
commit
d73a57dab7
@ -74,23 +74,15 @@ public:
|
||||
return va->vector_value("NAME");
|
||||
}
|
||||
|
||||
Policy policy()
|
||||
{
|
||||
string p = va->vector_value("POLICY");
|
||||
/**
|
||||
* @return the policy of this role
|
||||
*/
|
||||
Policy policy();
|
||||
|
||||
if ( p == "AFFINED" )
|
||||
{
|
||||
return AFFINED;
|
||||
}
|
||||
else if ( p == "ANTI_AFFINED" )
|
||||
{
|
||||
return ANTI_AFFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
std::string policy_s()
|
||||
{
|
||||
return va->vector_value("POLICY");
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* VMS set Interface */
|
||||
@ -238,6 +230,11 @@ public:
|
||||
return by_id.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to write a the roles in an output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& os, VMGroupRoles& roles);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
|
@ -29,7 +29,6 @@ struct VMGroupRule_compare;
|
||||
class VMGroupRule
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Placement policy rules for roles
|
||||
* AFFINED: VMs of all roles are placed in the same hypervisor
|
||||
@ -43,7 +42,6 @@ public:
|
||||
ANTI_AFFINED= 0x02
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return policy name
|
||||
*/
|
||||
@ -145,6 +143,16 @@ public:
|
||||
return roles;
|
||||
}
|
||||
|
||||
std::string get_policy() const
|
||||
{
|
||||
return policy_to_s(policy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to write a the rule in an output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& os, const VMGroupRule& rule);
|
||||
|
||||
private:
|
||||
|
||||
friend class VMGroupRule_compare;
|
||||
|
@ -144,6 +144,8 @@ protected:
|
||||
|
||||
virtual int do_scheduled_actions();
|
||||
|
||||
virtual void do_vm_groups();
|
||||
|
||||
private:
|
||||
Scheduler(Scheduler const&){};
|
||||
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
return oid;
|
||||
};
|
||||
|
||||
friend ostream& operator<<(ostream& os, VMGroupXML& vmg);
|
||||
|
||||
private:
|
||||
// ------------------------------------------------------------------------
|
||||
// VMGroup Attributes
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "VMGroupXML.h"
|
||||
#include <iomanip>
|
||||
|
||||
void VMGroupXML::init_attributes()
|
||||
{
|
||||
@ -51,7 +52,7 @@ void VMGroupXML::init_attributes()
|
||||
rules.insert(rule);
|
||||
}
|
||||
|
||||
rules.clear();
|
||||
srules.clear();
|
||||
|
||||
xpaths(srules, "/VM_GROUP/TEMPLATE/ANTI_AFFINED");
|
||||
|
||||
@ -67,3 +68,46 @@ void VMGroupXML::init_attributes()
|
||||
}
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& os, VMGroupXML& vmg)
|
||||
{
|
||||
VMGroupRule::rule_set::iterator rit;
|
||||
VMGroupRoles::role_iterator it;
|
||||
|
||||
os << left << setw(4) << vmg.oid << " "
|
||||
<< left << setw(8) << vmg.name<< " "
|
||||
<< left << setw(26)<< "ROLES" << "\n"
|
||||
<< setfill(' ') << setw(14) << " " << setfill('-') << setw(26) << '-'
|
||||
<< "\n";
|
||||
|
||||
for ( it = vmg.roles.begin() ; it != vmg.roles.end() ; ++it )
|
||||
{
|
||||
os << setfill(' ') << setw(14) << ' '
|
||||
<< left << setw(3) << (*it)->id() << " "
|
||||
<< left << setw(8) << (*it)->name() << " "
|
||||
<< left << setw(12)<< (*it)->policy_s() << "\n";
|
||||
}
|
||||
|
||||
os << setfill(' ') << setw(14) << ' ' << left << "RULES" << "\n"
|
||||
<< setfill(' ') << setw(14) << ' ' << setfill('-') << setw(26) << '-'
|
||||
<< "\n";
|
||||
|
||||
for ( rit = vmg.rules.begin() ; rit != vmg.rules.end(); ++rit )
|
||||
{
|
||||
const std::bitset<VMGroupRoles::MAX_ROLES>& rroles = (*rit).get_roles();
|
||||
|
||||
os << setfill(' ') << setw(14) << ' ' << left << setw(14)
|
||||
<< (*rit).get_policy() << " ";
|
||||
|
||||
for (int i = 0 ; i <VMGroupRoles::MAX_ROLES ; ++i)
|
||||
{
|
||||
if ( rroles[i] == 1 )
|
||||
{
|
||||
os << right << setw(3) << i << " ";
|
||||
}
|
||||
}
|
||||
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <pthread.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
#include "Scheduler.h"
|
||||
#include "SchedulerTemplate.h"
|
||||
@ -1394,6 +1395,30 @@ int Scheduler::do_scheduled_actions()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Scheduler::do_vm_groups()
|
||||
{
|
||||
map<int, ObjectXML*>::const_iterator it;
|
||||
const map<int, ObjectXML*> vmgrps = vmgpool->get_objects();
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
for (it = vmgrps.begin(); it != vmgrps.end() ; ++it)
|
||||
{
|
||||
oss << "\nVMGroups\n"
|
||||
<< left << setw(4)<< "ID" << left << setw(8) << "NAME \n"
|
||||
<< setfill('-') << setw(40) << '-' << setfill(' ') << "\n";
|
||||
|
||||
VMGroupXML * grp = static_cast<VMGroupXML*>(it->second);
|
||||
|
||||
oss << *grp;
|
||||
}
|
||||
|
||||
NebulaLog::log("VMGRP", Log::DEBUG, oss);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Scheduler::do_action(const string &name, void *args)
|
||||
{
|
||||
int rc;
|
||||
@ -1420,6 +1445,10 @@ void Scheduler::do_action(const string &name, void *args)
|
||||
return;
|
||||
}
|
||||
|
||||
profile(true);
|
||||
do_vm_groups();
|
||||
profile(false,"Setting VM groups placement constraints.");
|
||||
|
||||
match_schedule();
|
||||
|
||||
profile(true);
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include "VMGroupRole.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* VMGroupRole */
|
||||
@ -35,6 +37,27 @@ VMGroupRole::VMGroupRole(VectorAttribute *_va):va(_va)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VMGroupRole::Policy VMGroupRole::policy()
|
||||
{
|
||||
string p = va->vector_value("POLICY");
|
||||
|
||||
if ( p == "AFFINED" )
|
||||
{
|
||||
return AFFINED;
|
||||
}
|
||||
else if ( p == "ANTI_AFFINED" )
|
||||
{
|
||||
return ANTI_AFFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VMGroupRole::add_vm(int vm_id)
|
||||
{
|
||||
std::pair<std::set<int>::iterator, bool> rc;
|
||||
@ -309,3 +332,20 @@ int VMGroupRoles::names_to_ids(const std::string& rnames, std::set<int>& keyi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
ostream& operator<<(ostream& os, VMGroupRoles& roles)
|
||||
{
|
||||
VMGroupRoles::role_iterator it;
|
||||
|
||||
for ( it = roles.begin() ; it != roles.end() ; ++it )
|
||||
{
|
||||
os << right << setw(3) << (*it)->id() << " "
|
||||
<< right << setw(12) << (*it)->name() << " "
|
||||
<< right << setw(12) << (*it)->policy_s() << "\n";
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "VMGroupRole.h"
|
||||
#include "VMGroupRule.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* VMGroupRule */
|
||||
@ -70,3 +72,24 @@ std::string VMGroupRule::policy_to_s(Policy policy)
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
ostream& operator<<(ostream& os, const VMGroupRule& rule)
|
||||
{
|
||||
os << right << setw(14) << VMGroupRule::policy_to_s(rule.policy) << " ";
|
||||
|
||||
for (int i = 0 ; i <VMGroupRoles::MAX_ROLES ; ++i)
|
||||
{
|
||||
if ( rule.roles[i] == 1 )
|
||||
{
|
||||
os << right << setw(3) << i << " ";
|
||||
}
|
||||
}
|
||||
|
||||
os << '\n';
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user