Example #1
0
    $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}");
}
// Get the slice credential from the SA
$slice_credential = get_slice_credential($sa_url, $user, $slice_id);
// Get the slice URN via the SA
$slice_urn = $slice[SA_ARGUMENT::SLICE_URN];
// FIXME: This is the RSpec that will be used to call omni/stitcher.
// See proto-ch ticket #164 for storing all request RSpecs
$rspec_file = writeDataToTempDir($omni_invocation_dir, $rspec, OMNI_INVOCATION_FILE::REQUEST_RSPEC_FILE);
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$slice_users = get_all_members_of_slice_as_users($sa_url, $ma_url, $user, $slice_id);
// write out metadata file
$metadata = array('Omni invocation ID' => get_invocation_id_from_dir($omni_invocation_dir), 'User name' => $user->prettyName(), 'User username' => $user->username, 'User EPPN' => $user->eppn, 'User e-mail' => $user->email(), 'User UUID' => $user->account_id, 'Slice UUID' => $slice_id, 'Slice URN' => $slice_urn, 'Slice name' => $slice_name, 'Project UUID' => $project_id, 'Project name' => $project_name, 'Aggregate manager URLs' => $am_urls, 'Aggregate manager names' => $am_names, 'Request IP' => $_SERVER['REMOTE_ADDR'], 'Request browser' => $_SERVER['HTTP_USER_AGENT'], 'Request submitted' => date('r'));
$metadata_file = writeDataToTempDir($omni_invocation_dir, json_encode($metadata), OMNI_INVOCATION_FILE::METADATA_FILE);
/* write out metadata file that will be included in the body of a bug
   report e-mail - adjust this as necessary */
$metadata_email_report = array('User name' => $user->prettyName(), 'User username' => $user->username, 'Slice URN' => $slice_urn, 'Slice name' => $slice_name, 'Project name' => $project_name, 'Aggregate manager URLs' => $am_urls, 'Aggregate manager names' => $am_names, 'Request submitted' => date('r'));
$metadata_email_report_file = writeDataToTempDir($omni_invocation_dir, json_encode($metadata_email_report), OMNI_INVOCATION_FILE::METADATA_BUG_REPORT_EMAIL_FILE);
/*
Example #2
0
    $_SESSION['lasterror'] = "Slice " . $slice_name . " is expired.";
    relative_redirect('dashboard.php#slices');
}
if (!$user->isAllowed(SA_ACTION::GET_SLICE_CREDENTIAL, CS_CONTEXT_TYPE::SLICE, $slice_id)) {
    relative_redirect('home.php');
}
// TODO: Pass expiration to slicecred.py
$outside_key = db_fetch_outside_private_key_cert($user->account_id);
if (!$outside_key) {
    include "header.php";
    show_header('GENI Portal: Slices');
    include "tool-breadcrumbs.php";
    print "<h2>Cannot Download Slice Credential</h2>\n";
    print "This page allows you to download a slice credential file," . " for use in other tools (e.g. Omni).\n" . "This is advanced functionality, not required for typical GENI users.\n" . "Please" . " <button onClick=\"window.location='" . relative_url("downloadkeycert.php") . "'\">Download your key and certificate</button>" . " so that a credential can be retrieved.";
    include "footer.php";
    exit;
}
// Get the slice credential from the SA using the outside certificate
$slice_credential = get_slice_credential($sa_url, $user, $slice_id, $outside_key['certificate']);
// FIXME: slice name only unique within project. Need slice URN?
/* FIXME COMMENT: The URN would suck as part of a filename. Too many
 *                special characters.
 */
$cred_filename = $slice_name . "-cred.xml";
// Set headers for download
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename={$cred_filename}");
header("Content-Type: text/xml");
header("Content-Transfer-Encoding: binary");
print $slice_credential;
function query_sliverstatus($user, $ams, $sa_url, $slice, $slice_id)
{
    // Takes an arg am_id which may have multiple values. Each is treated
    // as the ID from the DB of an AM which should be queried
    // If no such arg is given, then query the DB and query all registered AMs
    if (!isset($ams) || is_null($ams) || count($ams) <= 0) {
        // Didnt get an array of AMs
        if (!isset($am) || is_null($am)) {
            // Nor a single am
            $ams = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER);
        } else {
            $ams = array();
            $ams[] = $am;
        }
    }
    if (!isset($ams) || is_null($ams) || count($ams) <= 0) {
        error_log("Found no AMs for query-sliverstatus!");
        $slivers_output = "No AMs registered.";
    }
    if (convert_boolean($slice['expired'])) {
        $msg = "Slice is expired";
        $good = false;
        $obj = array();
    } else {
        $slivers_output = "";
        // Get the slice credential from the SA
        $slice_credential = get_slice_credential($sa_url, $user, $slice_id);
        // Get the slice URN via the SA
        $slice_urn = $slice[SA_ARGUMENT::SLICE_URN];
        $am_urls = array();
        foreach ($ams as $am) {
            if (is_array($am)) {
                if (array_key_exists(SR_TABLE_FIELDNAME::SERVICE_URL, $am)) {
                    $am_url = $am[SR_TABLE_FIELDNAME::SERVICE_URL];
                } else {
                    error_log("Malformed array of AM URLs?");
                    continue;
                }
            } else {
                $am_url = $am;
            }
            $am_urls[] = $am_url;
        }
        $retVal = sliver_status($am_urls, $user, $slice_credential, $slice_urn);
        $good = FALSE;
        if (!is_null($retVal) && count($retVal) == 2) {
            $msg = $retVal[0];
            $obj = $retVal[1];
            $good = TRUE;
        } elseif (count($retVal) == 1) {
            $msg = $retVal;
            $obj[$am_url] = "";
        } else {
            $msg = "Call to sliver_status() FAILed";
            $obj = array();
        }
    }
    $retVal2 = array();
    $retVal2[] = $msg;
    $retVal2[] = $obj;
    $retVal2[] = $good;
    return $retVal2;
}