Commit 2a174bdc authored by Tarun Prabhu's avatar Tarun Prabhu

Fixes the issue of missing interfaces as needed for the post-assign phase....

Fixes the issue of missing interfaces as needed for the post-assign phase. removed dangling XStr usage, although I need to trace down more illegal uses if any exist.
parent 1cf2819c
...@@ -61,6 +61,7 @@ extern name_vclass_map vclass_map; ...@@ -61,6 +61,7 @@ extern name_vclass_map vclass_map;
map<string,DOMElement*>* advertisement_elements= new map<string,DOMElement*>(); map<string,DOMElement*>* advertisement_elements= new map<string,DOMElement*>();
map<string, string>* pIfacesMap = new map<string, string>(); map<string, string>* pIfacesMap = new map<string, string>();
map<string, string> shortNodeNames;
DOMElement* advt_root = NULL; DOMElement* advt_root = NULL;
...@@ -149,16 +150,13 @@ int parse_advertisement(tb_pgraph &pg, tb_sgraph &sg, char *filename) { ...@@ -149,16 +150,13 @@ int parse_advertisement(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
XMLDEBUG("Found rspec ver. " << rspecVersion << endl); XMLDEBUG("Found rspec ver. " << rspecVersion << endl);
bool is_physical; bool is_physical;
XStr type (advt_root->getAttribute(XStr("type").x())); string type = XStr(advt_root->getAttribute(XStr("type").x())).c();
if (strcmp(type.c(), "advertisement") != 0) { if (type != "advertisement") {
cout << "*** Rspec type must be \"advertisement\" in " << filename cout << "*** Rspec type must be \"advertisement\" in " << filename
<< " (found " << type.c() << ")" << endl; << " (found " << type << ")" << endl;
exit(EXIT_FATAL);
} }
// XXX: Not sure about datetimes, so they are strings for now
XStr generated (advt_root->getAttribute(XStr("generated").x()));
XStr valid_until (advt_root->getAttribute(XStr("valid_until").x()));
/* /*
* These three calls do the real work of populating the assign data * These three calls do the real work of populating the assign data
* structures * structures
...@@ -229,6 +227,11 @@ bool populate_nodes(DOMElement *root, ...@@ -229,6 +227,11 @@ bool populate_nodes(DOMElement *root,
string componentId = rspecParser->readPhysicalId(elt, hasComponentId); string componentId = rspecParser->readPhysicalId(elt, hasComponentId);
string componentManagerId = rspecParser->readComponentManagerId(elt,hasCMId); string componentManagerId = rspecParser->readComponentManagerId(elt,hasCMId);
bool hasComponentName;
string componentName
= rspecParser->readComponentName (elt, hasComponentName);
shortNodeNames.insert(pair<string,string>(componentId, componentName));
if (!hasComponentId || !hasCMId) { if (!hasComponentId || !hasCMId) {
is_ok = false; is_ok = false;
continue; continue;
...@@ -499,7 +502,7 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg, ...@@ -499,7 +502,7 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg,
string src_iface = interfaces[0].physicalIfaceId; string src_iface = interfaces[0].physicalIfaceId;
string dst_node = interfaces[1].physicalNodeId; string dst_node = interfaces[1].physicalNodeId;
string dst_iface = interfaces[1].physicalIfaceId; string dst_iface = interfaces[1].physicalIfaceId;
if (src_node == "" || src_iface == "") { if (src_node == "" || src_iface == "") {
cout << "*** Physical link " << componentId cout << "*** Physical link " << componentId
<< " must have a component id and component interface id " << " must have a component id and component interface id "
...@@ -550,7 +553,19 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg, ...@@ -550,7 +553,19 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg,
int typeCount; int typeCount;
vector<link_type> types = rspecParser->readLinkTypes(elt, typeCount); vector<link_type> types = rspecParser->readLinkTypes(elt, typeCount);
string str_first_type = types[0].typeName; string str_first_type = types[0].typeName;
/* Create srcmac and dstmacs which are needed by the code which
* parsers assign's output
*/
string srcMac = "(null)", dstMac = "(null)";
if (shortNames[src_iface] != "(null)") {
srcMac = shortNodeNames[src_node] + "/" + shortNames[src_iface];
}
if (shortNames[dst_iface] != "(null)") {
dstMac = shortNodeNames[dst_node] + "/" + shortNames[dst_iface];
}
/* /*
* Create the actual link object * Create the actual link object
*/ */
...@@ -561,10 +576,8 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg, ...@@ -561,10 +576,8 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg,
tb_plink *phys_link = tb_plink *phys_link =
new tb_plink(componentId.c_str(), new tb_plink(componentId.c_str(),
tb_plink::PLINK_NORMAL, str_first_type.c_str(), tb_plink::PLINK_NORMAL, str_first_type.c_str(),
"(null)", "(null)", srcMac.c_str(), dstMac.c_str(),
shortNames[src_iface].c_str(), shortNames[src_iface], shortNames[dst_iface]);
shortNames[dst_iface].c_str());
// src_iface.c_str(), dst_iface.c_str());
phys_link->delay_info.bandwidth = bandwidth; phys_link->delay_info.bandwidth = bandwidth;
phys_link->delay_info.delay = latency; phys_link->delay_info.delay = latency;
......
...@@ -136,17 +136,13 @@ int parse_request(tb_vgraph &vg, char *filename) { ...@@ -136,17 +136,13 @@ int parse_request(tb_vgraph &vg, char *filename) {
request_root = doc->getDocumentElement(); request_root = doc->getDocumentElement();
bool is_physical; bool is_physical;
XStr type (request_root->getAttribute(XStr("type").x())); string type = XStr (request_root->getAttribute(XStr("type").x())).c();
if (strcmp(type.c(), "request") != 0) { if (type != "request") {
cout << "*** RSpec type must be \"request\" in " << filename cout << "*** RSpec type must be \"request\" in " << filename
<< " (found " << type.c() << ")" << endl; << " (found " << type << ")" << endl;
exit (EXIT_FATAL); exit (EXIT_FATAL);
} }
// NOTE: Not sure about datetimes. They are strings for now
XStr generated (request_root->getAttribute(XStr("generated").x()));
XStr valid_until(request_root->getAttribute(XStr("valid_until").x()));
// Initialize the rspec parser with the correct object depending // Initialize the rspec parser with the correct object depending
// on the version of the rspec. // on the version of the rspec.
int rspecVersion = rspec_parser_helper::getRspecVersion(request_root); int rspecVersion = rspec_parser_helper::getRspecVersion(request_root);
......
...@@ -51,6 +51,13 @@ string rspec_parser :: readPhysicalId (const DOMElement* tag, ...@@ -51,6 +51,13 @@ string rspec_parser :: readPhysicalId (const DOMElement* tag,
return (this->getAttribute(tag, "component_id", hasComponentId)); return (this->getAttribute(tag, "component_id", hasComponentId));
} }
// Returns the component name
string rspec_parser::readComponentName (const DOMElement* tag,
bool& hasComponentName)
{
return (this->getAttribute(tag, "component_name", hasComponentName));
}
// Returns the client_id Sets an out parameter to true if an ID is present // Returns the client_id Sets an out parameter to true if an ID is present
string rspec_parser :: readVirtualId (const DOMElement* tag, bool& hasClientId) string rspec_parser :: readVirtualId (const DOMElement* tag, bool& hasClientId)
{ {
......
...@@ -89,6 +89,7 @@ class rspec_parser : public rspec_parser_helper ...@@ -89,6 +89,7 @@ class rspec_parser : public rspec_parser_helper
virtual std::string readVirtualId (const xercesc::DOMElement*, bool&); virtual std::string readVirtualId (const xercesc::DOMElement*, bool&);
virtual std::string readComponentManagerId (const xercesc::DOMElement*, virtual std::string readComponentManagerId (const xercesc::DOMElement*,
bool&); bool&);
virtual std::string readComponentName (const xercesc::DOMElement*, bool&);
virtual std::string readVirtualizationType (const xercesc::DOMElement*, virtual std::string readVirtualizationType (const xercesc::DOMElement*,
bool&); bool&);
......
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