. # # }}} # chdir(".."); include("defs.php3"); chdir("apt"); include("quickvm_sup.php"); include("profile_defs.php"); $page_title = "My Profiles"; # # Verify page arguments. # $reqargs = RequiredPageArguments("uuid", PAGEARG_STRING); # # Get current user. # RedirectSecure(); $this_user = CheckLoginOrRedirect(); SPITHEADER(1); $profile = Profile::Lookup($uuid); if (!$profile) { SPITUSERERROR("No such profile!"); } else if ($this_user->uid_idx() != $profile->creator_idx() && !ISADMIN()) { SPITUSERERROR("Not enough permission!"); } $profileid = $profile->profileid(); $instances = array(); # # First existing instances and then the history table. # $query1_result = DBQueryFatal("select 1 as active, ". " i.uuid,i.profile_version,i.created,'' as destroyed, ". " i.creator,p.uuid as profile_uuid,u.email,". " GROUP_CONCAT(ia.public_url) as public_urls, ". " GROUP_CONCAT(aa.abbreviation) as clusters, ". " i.slice_uuid,f.exitmessage,f.exitcode ". " from apt_instances as i ". "left join apt_instance_failures as f ". " on f.uuid=i.uuid ". "left join apt_instance_aggregates as ia ". " on ia.uuid=i.uuid ". "left join apt_profile_versions as p on ". " p.profileid=i.profile_id and ". " p.version=i.profile_version ". "left join geni.geni_users as u on u.uuid=i.creator_uuid ". "left join apt_aggregates as aa on aa.urn=ia.aggregate_urn ". "where i.profile_id='$profileid' ". "group by i.uuid order by i.created desc"); $query2_result = DBQueryFatal("select 0 as active, ". " h.uuid,h.profile_version,h.created,h.destroyed, ". " h.creator,p.uuid as profile_uuid,u.email, ". " GROUP_CONCAT(ia.public_url) as public_urls, ". " GROUP_CONCAT(aa.abbreviation) as clusters, ". " h.slice_uuid,f.exitmessage,f.exitcode ". " from apt_instance_history as h ". "left join apt_instance_failures as f ". " on f.uuid=h.uuid ". "left join apt_instance_aggregate_history as ia ". " on ia.uuid=h.uuid ". "left join apt_profile_versions as p on ". " p.profileid=h.profile_id and ". " p.version=h.profile_version ". "left join geni.geni_users as u on u.uuid=h.creator_uuid ". "left join apt_aggregates as aa on aa.urn=ia.aggregate_urn ". "where h.profile_id='$profileid' ". "group by h.uuid order by h.created desc"); if (mysql_num_rows($query1_result) == 0 && mysql_num_rows($query2_result) == 0) { $message = "Oops, there is no activity to show you.
"; SPITUSERERROR($message); exit(); } foreach (array($query1_result, $query2_result) as $query_result) { while ($row = mysql_fetch_array($query_result)) { $active = $row["active"]; $uuid = $row["uuid"]; $puuid = $row["profile_uuid"]; $pversion = $row["profile_version"]; $created = $row["created"]; $destroyed = $row["destroyed"]; $creator = $row["creator"]; $email = $row["email"]; $exitmessage= $row["exitmessage"]; $exitcode = $row["exitcode"]; $public_urls= $row["public_urls"]; $slice_uuid= $row["slice_uuid"]; $clusters = $row["clusters"]; # If a guest user, use email instead. if (isset($email)) { $creator = $email; } $instance = array(); $instance["active"] = intval($active); $instance["uuid"] = $uuid; $instance["p_uuid"] = $puuid; $instance["p_version"] = $pversion; $instance["creator"] = $creator; $instance["created"] = $created; $instance["destroyed"] = $destroyed; $instance["clusters"] = ($clusters ? $clusters : "n/a"); if (isset($exitcode)) { $instance["iserror"] = 1; if ($exitcode >= 0 && $exitcode <= count($geni_response_codes)) { $instance["error_reason"] = $geni_response_codes[$exitcode]; } elseif ($exitcode == GENIRESPONSE_STITCHER_ERROR) { $instance["error_reason"] = "Stitcher Failed"; } else { $instance["error_reason"] = $exitcode; } $instance["error_message"] = $exitmessage; } $instances[] = $instance; } } # Place to hang the toplevel template. echo "
\n"; echo "\n"; echo "\n"; echo "\n"; REQUIRE_UNDERSCORE(); REQUIRE_SUP(); SPITREQUIRE("js/profile-activity.js"); AddTemplate("profile-activity"); SPITFOOTER(); ?>