Commit b64cc8d1 authored by Leigh Stoller's avatar Leigh Stoller

Use php constants (define) for all the GENIRESPONSE error codes

and get rid of hardwired constants from the code.
parent 1011fe4f
......@@ -81,10 +81,12 @@ function Do_GetStats()
while ($row = mysql_fetch_array($query_result)) {
$exitcode = $row[0];
$count = $row[1];
if ($exitcode == 8) {
if ($exitcode == GENIRESPONSE_TIMEDOUT) {
$breakdown["timedout"][$key] = $count;
}
elseif ($exitcode == 1 || ($exitcode >= 24 && $exitcode < 30)) {
elseif ($exitcode == GENIRESPONSE_BADARGS ||
($exitcode >= GENIRESPONSE_VLAN_UNAVAILABLE &&
$exitcode <= GENIRESPONSE_NO_MAPPING)) {
$breakdown["mapping"][$key] += $count;
}
else {
......@@ -239,6 +241,9 @@ function Do_GetStats()
if ($exitcode >= 0 && $exitcode <= count($geni_response_codes)) {
$reason = $geni_response_codes[$exitcode];
}
elseif ($exitcode == GENIRESPONSE_STITCHER_ERROR) {
$reason = "Stitcher Failed";
}
if ($aggregate_urn && $aggregate_urn != "") {
$cluster = $urn_mapping[$aggregate_urn];
}
......
......@@ -85,6 +85,14 @@ $geni_response_codes =
"Insufficient Memory",
"No Mapping Possible",
);
define("GENIRESPONSE_BADARGS", 1);
define("GENIRESPONSE_TIMEDOUT", 8);
define("GENIRESPONSE_VLAN_UNAVAILABLE", 24);
define("GENIRESPONSE_INSUFFICIENT_BANDWIDTH", 25);
define("GENIRESPONSE_INSUFFICIENT_NODES", 26);
define("GENIRESPONSE_INSUFFICIENT_MEMORY", 27);
define("GENIRESPONSE_NO_MAPPING", 28);
define("GENIRESPONSE_STITCHER_ERROR", 101);
class Instance
{
......
......@@ -132,25 +132,25 @@ function Do_GetInstanceStatus()
# Reflect errors back to the user.
$webtask = WebTask::LookupByObject($instance->uuid());
if ($webtask && $webtask->exited()) {
if ($webtask->exitcode() == 26) {
if ($webtask->exitcode() == GENIRESPONSE_INSUFFICIENT_NODES) {
$blob["reason"] = "Not enough free nodes, please try again later.";
$blob["reason"] .= "\n\n";
}
elseif ($webtask->exitcode() == 25) {
elseif ($webtask->exitcode() == GENIRESPONSE_INSUFFICIENT_BANDWIDTH) {
$blob["reason"] = "Not enough available bandwidth for a link.\n\n";
}
elseif ($webtask->exitcode() == 28) {
elseif ($webtask->exitcode() == GENIRESPONSE_NO_MAPPING) {
$blob["reason"] = "Your topology could not be mapped to physical ".
"resources. Clicking the 'Sliver' button above will provide ".
"lots of info, some of which might be useful in figuring out ".
"why it failed.\n\n";
}
elseif ($webtask->exitcode() == 8) {
elseif ($webtask->exitcode() == GENIRESPONSE_TIMEDOUT) {
$blob["reason"] = "Your experiment timed out while setting up, ".
"most likely because one or more nodes failed to boot. The ".
"node consoles may provide more information.\n\n";
}
elseif ($webtask->exitcode() == 1) {
elseif ($webtask->exitcode() == GENIRESPONSE_BADARGS) {
#
# This is GENIRESPONSE_BADARGS which typically means an error
# in the input rspec, something the user must have put in it.
......@@ -158,6 +158,14 @@ function Do_GetInstanceStatus()
$blob["reason"] = "Your topology source contains invalid ".
"values.\n\n";
}
elseif ($webtask->exitcode() == GENIRESPONSE_STITCHER_ERROR) {
#
# This is GENIRESPONSE_STITCHER_ERROR which is a catch all.
#
$blob["reason"] = "Your multi-site topology could not be ".
"stitched together. Please look closely at the ".
"error message below to see what went wrong.\n\n";
}
else {
$blob["reason"] = "";
}
......
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