Commit 3a6d7b37 authored by Tarun Prabhu's avatar Tarun Prabhu

Fixed a bug dealing with exclusive nodes. Modified the parser to check for...

Fixed a bug dealing with exclusive nodes. Modified the parser to check for both an element exclusive and an attribute exclusive (did I mention that I am starting to detest v1?).

An unrelated bug which would have caused some nasty type-precheck failures also got fixed in the process.
parent 2274f810
......@@ -617,6 +617,7 @@ int mapping_precheck() {
if (type_table.find(this_type) == type_table.end()) {
// Yes, I know, goto is evil. But I'm not gonna indent the next
// 100 lines of code for this error case
cerr << "Can't be a goto now, can it? " << endl;
goto nosuchtype;
}
......@@ -634,6 +635,7 @@ int mapping_precheck() {
if (pnode->total_bandwidth >= v->total_bandwidth) {
matched_bw++;
} else {
cerr << "Not enough bandwidth? on " << pnode->name << endl;
potential_match = false;
}
......@@ -646,6 +648,7 @@ int mapping_precheck() {
} else {
if (v->typecount > type_iterator->second->get_max_load()) {
// Nope, this vnode is too demanding
cerr << "Max load? on " << pnode->name << endl;
potential_match = false;
}
}
......@@ -666,6 +669,7 @@ int mapping_precheck() {
if (fdit.either_violateable()) {
if (fdit.membership() !=
tb_featuredesire_set_iterator::BOTH) {
cerr << "not a fat chance " << fdit.membership() << " "<< fdit->name() << endl;
potential_match = false;
}
......@@ -712,9 +716,11 @@ int mapping_precheck() {
// Great, there are enough, too
matched_link_counts[type]++;
} else {
cerr << "link_counts? " << endl;
potential_match = false;
}
} else {
cerr << "Surely not! " << endl;
potential_match = false;
}
}
......
......@@ -110,7 +110,8 @@ emulab_extensions_parser::readVClasses (const DOMElement* elem)
return vclasses;
}
struct vclass emulab_extensions_parser::readVClass (const DOMElement* tag)
struct vclass
emulab_extensions_parser::readVClass (const DOMElement* tag)
{
vector<string> physTypes;
DOMNodeList* physNodes
......
......@@ -313,18 +313,26 @@ bool populate_nodes(DOMElement *root,
if (hasExclusive) {
fstring feature ("shared");
if (exclusive != "false") {
if (exclusive == "false" || exclusive == "0") {
p->features.push_front
(tb_node_featuredesire(feature, 1.0, true,
featuredesire::FD_TYPE_NORMAL));
}
else if (exclusive != "true" && exclusive != "1") {
static int syntax_error;
if ( !syntax_error ) {
syntax_error = 1;
cout << "WARNING: unrecognized exclusive attribute \""
<< exclusive << "\"; Asuming exclusive = \"true\"" << endl;
}
}
}
// Add the component_manager_uuid as a feature.
// We need to do this to handle external references
(p->features).push_front
(tb_node_featuredesire(XStr(componentManagerId.c_str()).f(),
1.0, false, featuredesire::FD_TYPE_NORMAL));
tb_node_featuredesire node_fd (XStr(componentManagerId.c_str()).f(),
0.9);//, false, featuredesire::FD_TYPE_NORMAL);
(p->features).push_front(node_fd);
// This has to be at the end becuase if we don't populate
// at least the interfaces, we get all kinds of crappy errors
......
......@@ -222,8 +222,6 @@ bool populate_node(DOMElement* elt,
string componentId = rspecParser->readPhysicalId(elt, hasComponentId);
string cmId = rspecParser->readComponentManagerId(elt, hasCMId);
cerr << "Got here with " << virtualId << " and " << cmId << endl;
// If a node has a component_uuid, it is a fixed node
if (hasComponentId) {
if(hasCMId) {
......@@ -267,8 +265,8 @@ bool populate_node(DOMElement* elt,
int typeCount;
vector<struct node_type> types = rspecParser->readNodeTypes(elt, typeCount);
bool no_type = (typeCount == 0);
string typeName = "";
int typeSlots = 0;
string typeName = rspecParser->convertType("pc");
int typeSlots = 1;
bool isStatic = false;
bool isUnlimited = false;
if (typeCount > 1) {
......@@ -330,13 +328,17 @@ bool populate_node(DOMElement* elt,
string nodeHint = rspecParser->readHintTo(elt, hasNodeHint);
tb_vnode *v = NULL;
if (no_type)
if (no_type) {
// If they gave no type, just assume it's a PC for
// now. This is not really a good assumption.
v = new tb_vnode(virtualId.c_str(), "pc", typeSlots);
else
cerr << "no type defaults to: " << typeName.c_str() << endl;
v = new tb_vnode(virtualId.c_str(), typeName.c_str(),
typeSlots);
}
else {
v = new tb_vnode(virtualId.c_str(),
typeName.c_str(), typeSlots);
}
// Construct the vertex
if (disallow_trivial_mix) {
......@@ -351,6 +353,7 @@ bool populate_node(DOMElement* elt,
bool hasExclusive;
string exclusive = rspecParser->readExclusive(elt, hasExclusive);
cerr << hasExclusive << " " << exclusive << endl;
if (hasExclusive) {
fstring desirename("shared");
......@@ -366,9 +369,9 @@ bool populate_node(DOMElement* elt,
if( !syntax_error ) {
syntax_error = 1;
cout << "Warning: unrecognised exclusive "
"attribute \"" << exclusive << "\"; will "
"assume exclusive=\"true\"\n";
cout << "WARNING: unrecognised exclusive "
"attribute \"" << exclusive << "\"; " <<
"Assuming exclusive=\"true\"\n";
}
}
}
......@@ -411,9 +414,10 @@ bool populate_node(DOMElement* elt,
// If a component manager has been specified, then the node must be
// managed by that CM. We implement this as a desire.
if (hasCMId) {
cerr << "Adding desire " << XStr(cmId.c_str()).f() << endl;
tb_node_featuredesire node_fd (XStr(cmId.c_str()).f(),
1.0, true, featuredesire::FD_TYPE_NORMAL);
node_fd.add_desire_user(0);
0.9);//, false, featuredesire::FD_TYPE_NORMAL);
node_fd.add_desire_user(0.9);
(v->desires).push_front(node_fd);
}
......
......@@ -295,7 +295,10 @@ string rspec_parser :: readSubnodeOf (const DOMElement* tag,
string rspec_parser :: readExclusive (const DOMElement* tag, bool& isExclusive)
{
return (this->readChild(tag, "exclusive", isExclusive));
if (this->hasChild(tag, "exclusive")) {
return (this->readChild(tag, "exclusive", isExclusive));
}
return (this->getAttribute(tag, "exclusive", isExclusive));
}
string rspec_parser :: readAvailable (const DOMElement* tag, bool& isAvailable)
......@@ -361,4 +364,18 @@ bool rspec_parser::readMultiplexOk (const DOMElement* tag)
{
return false;
}
// In the default case, just return the type as it is.
// Only in version 2 will we need to do something intelligent(?) with it
string rspec_parser::convertType (const string hwType) {
return hwType;
}
// Since assign doesn't really know what multiple types mean,
// we will only return the first. Hopefully, this will never ever
// really get used outside of v2.
string rspec_parser::convertType (const string hwType, const string slType) {
return hwType;
}
#endif
......@@ -130,8 +130,9 @@ class rspec_parser : public rspec_parser_helper
// Gets a map of the interface URNS to the short names
// that assign needs for fixed interfaces
std::map<std::string, std::string> getShortNames (void);
virtual std::map<std::string, std::string> getShortNames (void);
// These are functions needed to deal with extensions
virtual std::vector<struct rspec_emulab_extension::type_limit>
readTypeLimits (const xercesc::DOMElement*, int&);
......@@ -154,6 +155,12 @@ class rspec_parser : public rspec_parser_helper
virtual bool readTrivialOk (const xercesc::DOMElement* tag);
virtual std::vector<struct rspec_emulab_extension::policy>
readPolicies (const xercesc::DOMElement* tag, int& count);
// XXX: This is really, really bad. We shouldn't have a function which
// converts a single type name into the composite name that version 2
// expects but we need it when dealing with default types
virtual std::string convertType (const std::string, const std::string);
virtual std::string convertType (const std::string hwType);
};
......
......@@ -146,7 +146,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node,
for (int j = 0; j < sliverTypes->getLength(); j++) {
DOMElement* slNode = dynamic_cast<DOMElement*>(sliverTypes->item(j));
string slTypeName = this->getAttribute(slNode, "name");
string typeName = rspec_parser_helper::convertType(defHw, slTypeName);
string typeName = this->convertType(defHw, slTypeName);
struct node_type type = {typeName, 1, false};
types.push_back(type);
}
......@@ -181,7 +181,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node,
}
if (sliverTypes->getLength() == 0) {
string typeName = rspec_parser_helper::convertType(hwTypeName, defSl);
string typeName = this->convertType(hwTypeName, defSl);
struct node_type type = {typeName, typeSlots, isStatic};
types.push_back(type);
}
......@@ -189,8 +189,7 @@ rspec_parser_v2::readNodeTypes (const DOMElement* node,
for (int j = 0; j < sliverTypes->getLength(); j++) {
DOMElement* slNode = dynamic_cast<DOMElement*>(sliverTypes->item(j));
string slTypeName = this->getAttribute(slNode, "name");
string typeName = rspec_parser_helper::convertType(hwTypeName,
slTypeName);
string typeName = this->convertType(hwTypeName, slTypeName);
struct node_type type = {typeName, typeSlots, isStatic};
types.push_back(type);
......@@ -359,4 +358,15 @@ rspec_parser_v2::readPolicies (const DOMElement* tag, int& count)
return ((this->emulabExtensions)->readPolicies(tag, count));
}
string rspec_parser_v2::convertType (const string hwType, const string slType)
{
return rspec_parser_helper::convertType(hwType, slType);
}
string rspec_parser_v2::convertType (const string type)
{
return rspec_parser_helper::convertType(type);
}
#endif // #ifdef WITH_XML
......@@ -65,6 +65,8 @@ class rspec_parser_v2 : public rspec_parser
bool readMultiplexOk (const xercesc::DOMElement* tag);
std::vector<struct rspec_emulab_extension::policy>
readPolicies (const xercesc::DOMElement* tag, int& count);
std::string convertType (const std::string);
std::string convertType (const std::string, const std::string);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment