Commit df603900 authored by Tarun Prabhu's avatar Tarun Prabhu

Modified the command line parameters to accept a format for the ptop/vtop

files. The rspec version  passed from the command line isn't being used right
now and the schema is validated against that provided in the schemaLocation tag in
the XML document. This is a bad idea and we should figure out a clean way of e
nsuring that we don't get passed nasty XMLs.
parent e4173cfa
......@@ -429,38 +429,40 @@ void print_help() {
cout << " -v <viz> - Produce graphviz files with given prefix." <<
endl;
#endif
cout << " -r - Don't allow trivial links." << endl;
cout << " -p - Disable pclasses." << endl;
cout << " -d - Enable dynamic pclasses." << endl;
cout << " -r - Don't allow trivial links." << endl;
cout << " -p - Disable pclasses." << endl;
cout << " -d - Enable dynamic pclasses." << endl;
#ifdef PER_VNODE_TT
cout << " -P - Prune unusable pclasses." << endl;
cout << " -P - Prune unusable pclasses." << endl;
#endif
cout << " -T - Doing some scoring self-testing." << endl;
cout << " -H <float> - Try <float> times harder." << endl;
cout << " -o - Allow overloaded pnodes to be considered." << endl;
cout << " -t <float> - Start the temperature at <float> instead of melting."
cout << " -T - Doing some scoring self-testing." << endl;
cout << " -H <float> - Try <float> times harder." << endl;
cout << " -o - Allow overloaded pnodes to be considered." << endl;
cout << " -t <float> - Start the temperature at <float> instead of melting."
<< endl;
cout << " -u - Print a summary of the solution." << endl;
cout << " -c <float> - Use the 'connected' pnode finding algorithm " <<
cout << " -u - Print a summary of the solution." << endl;
cout << " -c <float> - Use the 'connected' pnode finding algorithm " <<
"<float>*100%" << endl << " of the time." << endl;
cout << " -n - Don't anneal - just do the prechecks." << endl;
cout << " -x <file> - Specify a text ptop file" << endl;
#ifdef WITH_XML
cout << " -X <file> - Specify a XML ptop file" << endl;
#endif
cout << " -y <file> - Specify a text top file" << endl;
cout << " -n - Don't anneal - just do the prechecks." << endl;
cout << " -x <file> - Specify a text ptop file" << endl;
// #ifdef WITH_XML
// cout << " -X <file> - Specify a XML ptop file" << endl;
// #endif
cout << " -y <file> - Specify a text top file" << endl;
// #ifdef WITH_XML
// cout << " -Y <file> - Specify a XML vtop file" << endl;
// #endif
#ifdef WITH_XML
cout << " -Y <file> - Specify a XML vtop file" << endl;
// cout << " -q <file> - Specify a rspec ptop file" << endl;
// cout << " -w <file> - Specify a rspec vtop file" << endl;
cout << " -W <file> - Specify the output rspec file" << endl;
cout << " -f <T>[/<T>] - Specify the ptop and vtop file formats ";
cout << "(text|xml|rspec-<ver>)" << endl;
#endif
#ifdef WITH_XML
cout << " -q <file> - Specify a rspec ptop file" << endl;
cout << " -w <file> - Specify a rspec vtop file" << endl;
cout << " -W <file> - Specify the output rspec file" << endl;
#endif
cout << " -F - Apply additional checking to fixed nodes" << endl;
cout << " -D - Dump configuration options" << endl;
cout << " cparams - You probably don't want to touch these!" << endl;
cout << " -F - Apply additional checking to fixed nodes" << endl;
cout << " -D - Dump configuration options" << endl;
cout << " cparams - You probably don't want to touch these!" << endl;
cout << " If you must, see config.h in the source for a list"
<< endl;
exit(EXIT_FATAL);
......@@ -850,8 +852,12 @@ int main(int argc,char **argv) {
char* ptopFilename = "";
char* vtopFilename = "";
char* vtopOutputFilename = 0;
const char* delims = "/";
char* ptopFileFormat = "";
char* vtopFileFormat = "";
while ((ch = getopt(argc,argv,"s:v:l:t:rpPTdH:oguc:nx:X:y:Y:q:w:W:FD")) != -1) {
while ((ch = getopt(argc,argv,"s:v:l:t:rpPTdH:oguc:nx:y:W:FDf:")) != -1) {
switch (ch) {
case 's':
if (sscanf(optarg,"%d",&seed) != 1) {
......@@ -918,15 +924,15 @@ int main(int argc,char **argv) {
dump_config = true;
break;
case 'x':
#ifdef WITH_XML
/*#ifdef WITH_XML
ptop_xml_input = false;
#endif
#endif*/
if (strcmp(optarg, "") == 0) {
print_help();
}
ptopFilename = optarg;
break;
#ifdef WITH_XML
/*#ifdef WITH_XML
case 'X':
ptop_xml_input = true;
if (strcmp(optarg, "") == 0) {
......@@ -934,42 +940,42 @@ int main(int argc,char **argv) {
}
ptopFilename = optarg;
break;
#endif
#endif*/
case 'y':
#ifdef WITH_XML
/*#ifdef WITH_XML
vtop_xml_input = false;
#endif
if (strcmp(optarg, "") == 0) {
print_help();
}
vtopFilename = optarg;
break;
#ifdef WITH_XML
case 'Y':
vtop_xml_input = true;
#endif*/
if (strcmp(optarg, "") == 0) {
print_help();
}
vtopFilename = optarg;
break;
#endif
// #ifdef WITH_XML
// case 'Y':
// vtop_xml_input = true;
// if (strcmp(optarg, "") == 0) {
// print_help();
// }
// vtopFilename = optarg;
// break;
// #endif
// #ifdef WITH_XML
// case 'q':
// ptop_rspec_input = true;
// if (strcmp(optarg, "") == 0) {
// print_help();
// }
// ptopFilename = optarg;
// break;
//
// case 'w':
// vtop_rspec_input = true;
// if (strcmp(optarg, "") == 0) {
// print_help();
// }
// vtopFilename = optarg;
// break;
#ifdef WITH_XML
case 'q':
ptop_rspec_input = true;
if (strcmp(optarg, "") == 0) {
print_help();
}
ptopFilename = optarg;
break;
case 'w':
vtop_rspec_input = true;
if (strcmp(optarg, "") == 0) {
print_help();
}
vtopFilename = optarg;
break;
case 'W':
if (strcmp(optarg, "") == 0) {
print_help();
......@@ -981,7 +987,48 @@ int main(int argc,char **argv) {
check_fixed_nodes = true;
break;
default:
case 'f':
if (strcmp(optarg, "") == 0) {
print_help();
}
ptopFileFormat = strtok(optarg, delims);
vtopFileFormat = strtok(NULL, delims);
if (strcmp(ptopFileFormat, "text") == 0) {
ptop_xml_input = false;
}
#ifdef WITH_XML
else if (strstr(ptopFileFormat, "rspec") != NULL) {
ptop_rspec_input = true;
}
else {
ptop_xml_input = true;
}
#endif
if (vtopFileFormat == NULL)
{
vtop_xml_input = ptop_xml_input;
vtop_rspec_input = ptop_rspec_input;
}
else
{
if (strcmp(vtopFileFormat, "text") == 0) {
vtop_xml_input = false;
}
#ifdef WITH_XML
else if (strstr(vtopFileFormat, "rspec") != NULL) {
vtop_rspec_input = true;
}
else {
vtop_xml_input = true;
}
#endif
}
break;
default:
print_help();
}
}
......
......@@ -86,21 +86,16 @@ int parse_ptop_rspec(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
/*
* Enable some of the features we'll be using: validation, namespaces, etc.
*/
/* XXX: The schema to validate against is specificed in the xml document
* This could lead to security problems. There are some ways around it,
* but they aren't exactly elegant. But we do need to take care of it at
* some point
*/
parser->setValidationScheme(XercesDOMParser::Val_Always);
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setValidationSchemaFullChecking(true);
/*
* Must validate against the ptop schema
*/
parser -> setExternalSchemaLocation ("http://www.protogeni.net/resources/rspec/0.1 " SCHEMA_LOCATION);
/*
* Just use a custom error handler - must admin it's not clear to me why
* we are supposed to use a SAX error handler for this, but this is what
* the docs say....
*/
ParseErrorHandler* errHandler = new ParseErrorHandler();
parser->setErrorHandler(errHandler);
......@@ -131,8 +126,8 @@ int parse_ptop_rspec(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
XStr type (advertisement_root->getAttribute(XStr("type").x()));
if (strcmp(type.c(), "advertisement") == 0)
is_physical = true;
else if (strcmp(type.c(), "request") == 0)
is_physical = false;
else if (strcmp(type.c(), "request") == 0)
is_physical = false;
// XXX: Not sure what to do with the datetimes, so they are strings for now
XStr generated (advertisement_root->getAttribute(XStr("generated").x()));
......@@ -142,23 +137,21 @@ int parse_ptop_rspec(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
* These three calls do the real work of populating the assign data
* structures
*/
// clock_t startNode = clock();
XMLDEBUG("starting node population" << endl);
if (!populate_nodes_rspec(advertisement_root,pg,sg,unavailable)) {
cerr << "Error reading nodes from physical topology " << filename << endl;
exit(EXIT_FATAL);
cerr << "Error reading nodes from physical topology "
<< filename << endl;
exit(EXIT_FATAL);
}
XMLDEBUG("finishing node population" << endl);
// //cerr << "Time taken : " << (clock() - startNode) / CLOCKS_PER_SEC << endl;
// clock_t startLink = clock();
XMLDEBUG("starting link population" << endl);
if (!populate_links_rspec(advertisement_root,pg,sg,unavailable)) {
cerr << "Error reading links from physical topology " << filename << endl;
exit(EXIT_FATAL);
cerr << "Error reading links from physical topology "
<< filename << endl;
exit(EXIT_FATAL);
}
XMLDEBUG("finishing link population" << endl);
// //cerr << "Time taken : " << (clock() - startLink) / CLOCKS_PER_SEC << endl;
// TODO: We need to do something about these policies
//populate_policies(root);
......
......@@ -89,21 +89,16 @@ int parse_vtop_rspec(tb_vgraph &vg, char *filename) {
/*
* Enable some of the features we'll be using: validation, namespaces, etc.
*/
/* XXX: The schema to validate against is specificed in the xml document
* This could lead to security problems. There are some ways around it,
* but they aren't exactly elegant. But we do need to take care of it at
* some point
*/
parser->setValidationScheme(XercesDOMParser::Val_Always);
parser->setDoNamespaces(true);
parser->setDoSchema(true);
parser->setValidationSchemaFullChecking(true);
/*
* Must validate against the ptop schema
*/
parser -> setExternalSchemaLocation ("http://www.protogeni.net/resources/rspec/0.1 " SCHEMA_LOCATION);
/*
* Just use a custom error handler - must admin it's not clear to me why
* we are supposed to use a SAX error handler for this, but this is what
* the docs say....
*/
ParseErrorHandler* errHandler = new ParseErrorHandler();
parser->setErrorHandler(errHandler);
......@@ -117,7 +112,9 @@ int parse_vtop_rspec(tb_vgraph &vg, char *filename) {
* If there are any errors, do not go any further
*/
if (errHandler->sawError()) {
cerr << "There were " << parser -> getErrorCount () << " errors in your file. Please correct the errors and try again." << endl;
cerr << "There were " << parser -> getErrorCount ()
<< " errors in your file."
<< "Please correct the errors and try again." << endl;
exit(EXIT_FATAL);
}
else {
......@@ -136,39 +133,35 @@ int parse_vtop_rspec(tb_vgraph &vg, char *filename) {
exit (EXIT_FATAL);
}
// XXX: Not sure what to do with the datetimes, so they are strings for now
XStr generated (request_root->getAttribute(XStr("generated").x()));
XStr valid_until(request_root->getAttribute(XStr("valid_until").x()));
// XXX: Not sure what to do with the datetimes, they are strings for now
XStr generated (request_root->getAttribute(XStr("generated").x()));
XStr valid_until(request_root->getAttribute(XStr("valid_until").x()));
map< pair<string, string>, pair<string, string> > fixed_interfaces;
map< pair<string, string>, pair<string, string> > fixed_interfaces;
//map< pair<string, string>, pair<string, string> >();
/*
* These three calls do the real work of populating the assign data
* structures
*/
// clock_t startNode = clock();
XMLDEBUG("starting node population" << endl);
if (!populate_nodes_rspec(request_root,vg, &fixed_interfaces)) {
cerr << "Error reading nodes from virtual topology " << filename << endl;
exit(EXIT_FATAL);
}
XMLDEBUG("finishing node population" << endl);
// //cerr << "Time taken : " << (clock() - startNode) / CLOCKS_PER_SEC << endl;
// clock_t startLink = clock();
XMLDEBUG("starting link population" << endl);
if (!populate_links_rspec(request_root,vg, &fixed_interfaces)) {
cerr << "Error reading links from virtual topology " << filename << endl;
exit(EXIT_FATAL);
}
XMLDEBUG("finishing link population" << endl);
// //cerr << "Time taken : " << (clock() - startLink) / CLOCKS_PER_SEC << endl;
/* TODO: We need to do something about policies at some point. */
/*
* These three calls do the real work of populating the assign data
* structures
*/
XMLDEBUG("starting node population" << endl);
if (!populate_nodes_rspec(request_root,vg, &fixed_interfaces)) {
cerr << "Error reading nodes from virtual topology " << filename << endl;
exit(EXIT_FATAL);
}
XMLDEBUG("finishing node population" << endl);
XMLDEBUG("starting link population" << endl);
if (!populate_links_rspec(request_root,vg, &fixed_interfaces)) {
cerr << "Error reading links from virtual topology " << filename << endl;
exit(EXIT_FATAL);
}
XMLDEBUG("finishing link population" << endl);
/* TODO: We need to do something about policies at some point. */
//populate_policies(root);
cerr << "RSpec parsing finished" << endl;
cerr << "RSpec parsing finished" << endl;
}
/*
......
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