function print_rspec($obj, $pretty, $filterToAM)
{
    $args = array_keys($obj);
    // How many AMs reported actual results
    $amc = 0;
    foreach ($args as $arg) {
        if (is_array($obj[$arg]) and array_key_exists('value', $obj[$arg]) and array_key_exists('code', $obj[$arg]) and is_array($obj[$arg]['code']) and array_key_exists('geni_code', $obj[$arg]['code']) and $obj[$arg]['code']['geni_code'] == 0) {
            $amc = $amc + 1;
        }
    }
    foreach ($args as $arg) {
        $arg_url = $arg;
        $am_id = am_id($arg_url);
        $arg_name = am_name($arg_url);
        $arg_urn = am_urn($arg_url);
        if (is_array($obj[$arg]) and array_key_exists('value', $obj[$arg])) {
            $xml = $obj[$arg]['value'];
        } else {
            $xml = "";
        }
        $code = -1;
        if (is_array($obj[$arg]) and array_key_exists('code', $obj[$arg]) and is_array($obj[$arg]['code']) and array_key_exists('geni_code', $obj[$arg]['code'])) {
            $code = $obj[$arg]['code']['geni_code'];
        }
        if (is_array($obj[$arg]) and array_key_exists('output', $obj[$arg])) {
            $output = $obj[$arg]['output'];
        } else {
            if (!is_array($obj[$arg]) or !array_key_exists('code', $obj[$arg])) {
                $output = (string) $obj[$arg];
            } else {
                $output = "";
            }
        }
        /* If pretty, keep output clean by only printing RSpec for
              aggregates which have a slice (ie code!=12 or code !==2).
              Also don't print if no code was returned (ie code!=-1) because
              something catastrophic happened.
              -- unless there are no aggregates with resources, in which case
              we print the error.
           */
        // error_log("Aggregate listresources code is " . $code);
        if (!(($code == -1 or $code == 12 or $code == 2) and $pretty)) {
            if ($pretty) {
                print "<div class='aggregate' id='aggT_" . $am_id . "'>Aggregate <b>" . $arg_name . "'s</b> Resources:</div>";
            } else {
                print "<div class='aggregate' id='aggT_" . $am_id . "'>Aggregate <b>" . $arg_name . "'s</b> Raw Resources:</div>";
            }
            print "<div class='resources' id='agg_" . $am_id . "'>";
            if ($code == 0) {
                if ($pretty) {
                    /* Parsed into a table */
                    print_rspec_pretty($xml, False, $filterToAM, $arg_urn, $am_id);
                } else {
                    //	  /* As plain XML but with newlines after each block */
                    //	  $xml = str_replace(">", ">\n", $xml);
                    print_xml($xml);
                }
            } else {
                if ($output == "") {
                    $output = "[None. Return code: " . $code . "]";
                }
                echo "<p>Returned: <i>{$output}</i></p>";
            }
            print "</div>\n";
        }
    }
}
Example #2
0
                break;
            }
        }
        if (!$knownAM) {
            error_log("Bound RSpec uses unknown AM {$am_urn}!");
            // This is going to fail later - almost certainly (all my tests do).
            // Some cases get you a results page with a clear error message.
            // Others give an SCS error about failing to find a path.
            // Doing this error message here cuts off that later work, but also stops
            // before the submit problem report page, which might be useful.
            //create_sliver_error("Your RSpec requires using an unknown aggregate: $am_urn.");
        }
    }
} else {
    $am_url = $am[SR_ARGUMENT::SERVICE_URL];
    $am_name = am_name($am_url);
    $am_urls = array($am_url);
    $am_names = array($am_name);
}
/*
    STEP 2: PREPARE
    At this point, we can assume that verification is done and that the
    sliver is ready to be created.
*/
// prepare temporary directory to hold all files related to invocation
$omni_invocation_dir = prepare_temp_dir($user->username);
if (is_null($omni_invocation_dir)) {
    // FIXME: What to do if directory can't be created?
    error_log("Could not create temporary directory for omni session: {$omni_invocation_dir}");
    create_sliver_error("Could not create temporary directory for omni session: {$omni_invocation_dir}");
}
Example #3
0
    }
} else {
    $msg = $retVal;
}
$success = $obj[0];
$fail = $obj[1];
if (count($success)) {
    if (count($am_urls) == 1) {
        log_event($log_url, $user, "Renewed resources from slice " . $slice_name . " at " . $AM_name, $log_attributes);
    } else {
        log_event($log_url, $user, "Renewed resources from slice " . $slice_name, $log_attributes);
    }
}
//if terminated obj[1] is failed nodes; so on terminated want to append the AM to $obj[1]
//error_log("RenewSliver msg = " . $msg . " obj " . print_r($obj, true));
if (preg_match("/" . AM_CLIENT_TIMED_OUT_MSG . "/", $msg) == 1) {
    $rrht = $obj[1];
    $rrht[] = am_name($am_url);
    $obj[1] = $rrht;
}
// Set headers for download
header("Cache-Control: public");
header("Content-Type: application/json");
/* json_encode accepts JSON_PRETTY_PRINT in PHP 5.4, but
 * we've got 5.3. Use a third-party utility instead.
 */
if ($obj != "") {
    print json_indent(json_encode($obj));
} else {
    print json_indent($msg);
}
Example #4
0
// Close the session here to allow multiple AJAX requests to run
// concurrently. If the session is left open, it holds the session
// lock, causing AJAX requests to run serially.
// DO NOT DO ANY SESSION MANIPULATION AFTER THIS POINT!
session_write_close();
// querying the AMs for sliver details info
$statRet = query_details($user, $ams, $sa_url, $slice, $slice_id);
$msg = $statRet[0];
$obj = $statRet[1];
// $good = $statRet[2];
$status_array = array();
if (count($obj) > 0) {
    // if (isset($obj) && $obj && is_array($obj)) {
    // fill in sliver details for each agg
    if (preg_match("/" . AM_CLIENT_TIMED_OUT_MSG . "/", $msg) == 1) {
        print "<i>" . AM_CLIENT_TIMED_OUT_MSG . " at aggregate " . am_name(key($obj)) . " </i><br/>\n";
    }
    $filterToAM = True;
    print_rspec($obj, True, $filterToAM);
    // Get the rspec in xml format without HTML clutter
    $xmlRspec = get_rspec_xml($obj, False, $filterToAM);
    /*
    if ($xmlRspec && $xmlRspec != "null") {
      print "<div id='jacksContainer-".hash('ripemd160', am_name(key($obj)))."' class='jacks resources' style='background-color: white'></div>";
    
      print "<script>
              $(document).ready(function() {
              var xml = \"$xmlRspec\";
                thisInstance = new window.Jacks({
                  mode: 'viewer',
                  source: 'rspec',
Example #5
0
function getInfoFromSliverStatusPG($obj, $status_array)
{
    $loginInfo = array();
    $pgKeyList = array();
    foreach ($obj as $am_url => $am_item) {
        $status_item = array();
        // AM url
        $status_item['url'] = $am_url;
        // AM name
        $status_item['am_name'] = am_name($am_url);
        if (!$am_item) {
            // "ERROR: empty sliver status!"
            continue;
        }
        if (!array_key_exists("users", $am_item)) {
            //    "ERROR: No 'users' key in sliver status!"
            continue;
        }
        if (!array_key_exists('geni_resources', $am_item)) {
            // "ERROR: Sliver Status lists no resources"
            continue;
        }
        $status_array[am_id($am_url)]['login_info'] = array();
        foreach ($am_item['users'] as $userDict) {
            if (!array_key_exists('login', $userDict)) {
                // "User entry had no 'login' key"
                continue;
            }
            //    } elseif (preg_match("/^Failed to get SliverStatus on urn*$/",$line,$fail)) {
            $pgKeyList[$userDict['login']] = array();
            if (!array_key_exists('keys', $userDict)) {
                continue;
            }
        }
        foreach ($userDict['keys'] as $k) {
            #XXX nriga Keep track of keys, in the future we can verify what key goes with
            # which private key
            $pgKeyList[$userDict['login']][] = $k['key'];
        }
    }
    return $status_array;
}