Beispiel #1
0
// 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);
/*
    STEP 3: CALL AM CLIENT
    Call create_sliver() in am_client.php and get a return code back.
    $retVal is non-null if successful, null if failed
*/
$retVal = create_sliver($am_urls, $user, $slice_users, $slice_credential, $slice_urn, $omni_invocation_dir, $slice['slice_id'], $bound_rspec, $stitch_rspec);
if ($retVal and $retVal != "Invalid AM URL" and $retVal != "Missing AM URL" and $retVal != "Missing slice credential") {
    // Really we want to come here if we spawned the process OK only
    // Set up link to results page
    $invoke_id = get_invocation_id_from_dir($omni_invocation_dir);
    $link = "sliceresource.php?invocation_user="******"&invocation_id={$invoke_id}&slice_id={$slice_id}";
    // if am_id specified, append it to link
    if (isset($am_id) && $am_id) {
        $link .= "&am_id={$am_id}";
    }
Beispiel #2
0
function create_sliver($am_urls, $user, $slice_users, $slice_credential, $slice_urn, $omni_invocation_dir, $slice_id, $bound_rspec = 0, $stitch_rspec = 0)
{
    //  error_log("CS : " . print_r($am_urls, true));
    // stitchable RSpecs should have empty AM URL, so only check for non-stitchable RSpecs
    if (!$stitch_rspec) {
        if (!isset($am_urls) || is_null($am_urls) || is_array($am_urls) && count($am_urls) == 0 || !is_array($am_urls) && $am_urls == '') {
            error_log("am_client cannot do createsliver without an AM URL");
            return "Missing AM URL";
        }
    }
    if (!isset($slice_credential) || is_null($slice_credential) || $slice_credential == '') {
        error_log("am_client cannot act on a slice without a credential");
        return "Missing slice credential";
    }
    $member_id = $user->account_id;
    $msg = "User {$member_id} calling CreateSliver at {$am_urls} on {$slice_urn}";
    geni_syslog(GENI_SYSLOG_PREFIX::PORTAL, $msg);
    $rspec_filename = "{$omni_invocation_dir}/" . OMNI_INVOCATION_FILE::REQUEST_RSPEC_FILE;
    $rspec = file_get_contents($rspec_filename);
    // Don't log this: We already log from the caller if the allocation is successful
    //  log_action("Called CreateSliver", $user, $am_urls, $slice_urn, $rspec, $slice_id);
    $slice_credential_filename = writeDataToTempDir($omni_invocation_dir, $slice_credential, OMNI_INVOCATION_FILE::SLICE_CREDENTIAL_FILE);
    $args = array("-o", "--slicecredfile", $slice_credential_filename, 'createsliver', $slice_urn, $rspec_filename);
    // FIXME: Note that this AM has resources
    // slice_id, am_urls or ID, duration?
    // we want to fork the process
    $fork = true;
    $output = invoke_omni_function($am_urls, $user, $args, $slice_users, $bound_rspec, $stitch_rspec, $fork, $omni_invocation_dir);
    // FIXME: forking: this file shouldn't be deleted for now
    //unlink($slice_credential_filename);
    return $output;
}