Ejemplo n.º 1
0
    if (!isset($slice_name)) {
        $slice_name = "";
    }
    $_SESSION['lasterror'] = "Slice " . $slice_name . " is expired.";
    relative_redirect('dashboard.php#slices');
}
// redirect if user isn't allowed to look up slice
if (!$user->isAllowed(SA_ACTION::LOOKUP_SLICE, CS_CONTEXT_TYPE::SLICE, $slice_id)) {
    relative_redirect('home.php');
}
// show header and breadcrumbs
show_header('GENI Portal: Add Resources to Slice (Results)');
include "tool-breadcrumbs.php";
include "tool-showmessage.php";
// check that invocation ID actually points to a directory
$dir_to_check = get_invocation_dir_name($invocation_user, $invocation_id);
if (!is_dir($dir_to_check)) {
    echo "<h1>Add Resources to GENI Slice <i>{$slice_name}</i> (Results)</h1>";
    echo "<p class='error'>Files and process data related to omni request <b>{$invocation_user}-{$invocation_id}</b> not found. Note that older files are periodically removed from the Portal, so it is possible that the files and process-related data have been deleted as part of routine maintenance.<br><br>For further help, please contact <a href='mailto:portal-help@geni.net'>Portal Help</a>.</p>";
    echo '<form method="GET" action="back">';
    echo '<input type="button" value="Back" onClick="history.back(-1)"/>';
    echo '</form>';
    include "footer.php";
    error_log("sliceresource.php: Failed to find directory with invocation ID " . "{$invocation_id} and user {$invocation_user}.");
    exit;
}
// set e-mail footer message
$bug_report_msg1 = "Attached is a problem report about reserving resources generated from the GENI Portal (https://portal.geni.net/). This problem report contains process-related information such as log files, resource specifications (RSpecs) and metadata.<br><br>User message:";
$bug_report_msg2 = "Thanks,<br>" . $user->prettyName();
$bug_report_subject = "GENI Portal Reservation Problem Report";
/*
     $download = false;
 }
 // set offset to 0 by default unless it's set in AJAX call
 if (array_key_exists("offset", $_REQUEST) && is_int(intval($_REQUEST['offset'])) && intval($_REQUEST['offset'] >= 0)) {
     $offset = intval($_REQUEST['offset']);
 } else {
     $offset = 0;
 }
 // get AM ID if it exists
 if (array_key_exists("am_id", $_REQUEST) && $_REQUEST['am_id']) {
     $am_id = $_REQUEST['am_id'];
 } else {
     $am_id = NULL;
 }
 // set up invocation directory based on username and invocation ID
 $invocation_dir = get_invocation_dir_name($invocation_user, $invocation_id);
 switch ($request) {
     case "pid":
         $retVal = get_omni_invocation_pid($invocation_dir);
         break;
     case "command":
         do_security_check($slice_id);
         $retVal = get_omni_invocation_command($invocation_dir, $raw);
         break;
     case "console":
         do_security_check($slice_id);
         $retVal = get_omni_invocation_console_log($invocation_dir, $raw, $offset);
         break;
     case "error":
         do_security_check($slice_id);
         $retVal = get_omni_invocation_error_log($invocation_dir, $raw);
Ejemplo n.º 3
0
function send_bug_report($user, $invocation_user, $invocation_id, $to, $cc, $custom_message)
{
    $omni_invocation_dir = get_invocation_dir_name($invocation_user, $invocation_id);
    // make sure directory actually exists
    if (!is_dir($omni_invocation_dir)) {
        send_bug_report_error("Problem report files could not be zipped in an archive. Problem report not sent.");
    }
    // don't include the user's cert, credentials, private key, and (maybe) SF cred
    $excluded_files_list = array("{$omni_invocation_dir}/" . OMNI_INVOCATION_FILE::SLICE_CREDENTIAL_FILE, "{$omni_invocation_dir}/" . OMNI_INVOCATION_FILE::CERTIFICATE_FILE, "{$omni_invocation_dir}/" . OMNI_INVOCATION_FILE::PRIVATE_KEY_FILE, "{$omni_invocation_dir}/" . OMNI_INVOCATION_FILE::SPEAKSFOR_CREDENTIAL_FILE);
    $zip_name = OMNI_INVOCATION_FILE::ZIP_ARCHIVE_PREFIX . "-{$invocation_user}-{$invocation_id}.zip";
    $zip_path = "{$omni_invocation_dir}/{$zip_name}";
    // FIXME: See ticket #1117/1169: Try making this a .tar.gz?
    $retVal = zip_dir_files($zip_path, $omni_invocation_dir, $excluded_files_list);
    // if .zip file exists, grab its contents for attachment and delete file
    $attachment = "";
    if ($retVal) {
        $attachment = chunk_split(base64_encode(file_get_contents($retVal)), 76, "\n");
        if (file_exists($retVal)) {
            unlink($retVal);
        }
    } else {
        send_bug_report_error("Problem report files could not be zipped in an archive. Problem report not sent.");
    }
    // prepare metadata
    $metadata = "";
    $metadata_file = "{$omni_invocation_dir}/" . OMNI_INVOCATION_FILE::METADATA_BUG_REPORT_EMAIL_FILE;
    if (is_file($metadata_file) && filesize($metadata_file)) {
        $metadata_json_string = file_get_contents($metadata_file);
        $metadata_array = json_decode($metadata_json_string, True);
        foreach ($metadata_array as $key => $value) {
            if (is_array($value)) {
                $metadata .= "{$key}: " . implode(', ', $value) . "\n";
            } else {
                $metadata .= "{$key}: {$value}\n";
            }
        }
    }
    // set up e-mail
    $boundary_string = md5(date('r', time()));
    $from = "\"" . $user->prettyName() . " (via the GENI Portal)\" <*****@*****.**>";
    $subject = "GENI Portal Reservation Problem Report";
    $headers = array();
    $headers[] = "MIME-Version: 1.0";
    $headers[] = "Content-type: multipart/mixed; boundary=\"PHP-mixed-" . $boundary_string . "\"";
    $headers[] = "From: {$from}";
    if ($cc) {
        $headers[] = "Cc: {$cc}";
    }
    $headers[] = "Reply-To: " . $user->prettyEmailAddress();
    $headers[] = "Subject: {$subject}";
    $headers[] = "X-Mailer: PHP/" . phpversion();
    // start output buffering
    // do not add any additional tabs here as they will indent
    // the PHP-mixed et al lines
    ob_start();
    ?>

--PHP-mixed-<?php 
    echo "{$boundary_string}\n";
    ?>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit

Attached is a problem report about reserving resources generated from the
GENI Portal (https://portal.geni.net/). This problem report contains
process-related information such as log files, resource specifications
(RSpecs) and metadata.

User message:
<?php 
    echo $custom_message;
    ?>


Process metadata:
<?php 
    echo $metadata;
    ?>

Thanks,
<?php 
    echo $user->prettyName();
    ?>

--PHP-mixed-<?php 
    echo "{$boundary_string}\n";
    ?>
Content-Type: application/zip; name="<?php 
    echo $zip_name;
    ?>
"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

<?php 
    echo $attachment;
    ?>

<?php 
    $message = ob_get_clean();
    $message .= "\r\n";
    $message .= "--PHP-mixed-{$boundary_string}--\r\n";
    $retVal = mail($to, $subject, $message, implode("\r\n", $headers));
    if ($retVal) {
        if ($cc) {
            $msg = "Problem report sent to <b>{$to}</b> (and copied to <b>{$cc}</b>).";
        } else {
            $msg = "Problem report sent to <b>{$to}</b>.";
        }
        send_bug_report_success($msg);
    } else {
        error_log("Error sending problem report {$invocation_user}-{$invocation_id}: {$retVal}");
        send_bug_report_error("Could not send problem report. Try again later or " . "please contact <a href='mailto:portal-help@geni.net'>Portal Help</a>.");
    }
}