function create_am_map() { global $am_mapping; global $am_mapping_id; global $am_mapping_urn; global $am_mapping_name_by_urn; $am_mapping = array(); $am_mapping_id = array(); $all_aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); foreach ($all_aggs as $agg) { $aggid = $agg['id']; $aggurl = $agg[SR_TABLE_FIELDNAME::SERVICE_URL]; $aggurn = $agg[SR_TABLE_FIELDNAME::SERVICE_URN]; $aggname = $agg[SR_TABLE_FIELDNAME::SERVICE_NAME]; $aggdesc = $agg[SR_TABLE_FIELDNAME::SERVICE_DESCRIPTION]; $am_mapping[$aggurl] = $aggname; $am_mapping_id[$aggurl] = $aggid; $am_mapping_urn[$aggurl] = $aggurn; $am_mapping_name_by_urn[$aggurn] = $aggname; } }
error_log("Bound RSpec but 0 AMs"); no_am_error(); } else { if ($partially_bound_rspec) { error_log("Partially bound RSpec with AMs: " . print_r($am_urns, true)); create_sliver_error("Partially bound RSpecs are not supported. All nodes must be assigned to an aggregate."); } else { if (!$bound_rspec && (!isset($am) || is_null($am))) { error_log("Unbound RSpec and no AM specified"); no_am_error(); } } } // Get an AM for non-bound RSpecs if ($bound_rspec) { $all_aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); $am_urls = array(); $am_names = array(); foreach ($am_urns as $am_urn) { $knownAM = False; // error_log("AM_URN = " . print_r($am_urn, true)); foreach ($all_aggs as $agg) { if ($agg[SR_ARGUMENT::SERVICE_URN] == $am_urn) { // error_log("MATCH " . print_r($agg, true)); $am_name = $agg[SR_ARGUMENT::SERVICE_NAME]; $am_url = $agg[SR_ARGUMENT::SERVICE_URL]; array_push($am_urls, $am_url); array_push($am_names, $am_name); $knownAM = True; break; }
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; }
function cmp($a, $b) { return strcmp(strtolower($a['name']), strtolower($b['name'])); } $user = geni_loadUser(); if (!isset($user) || is_null($user) || !$user->isActive()) { relative_redirect('home.php'); } unset($slice); include "tool-lookupids.php"; $disable_buttons_str = ""; if (isset($slice_expired) && convert_boolean($slice_expired)) { $disable_buttons_str = " disabled"; } if (!isset($all_ams)) { $am_list = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); $all_ams = array(); foreach ($am_list as $am) { $single_am = array(); $service_id = $am[SR_TABLE_FIELDNAME::SERVICE_ID]; $single_am['name'] = $am[SR_TABLE_FIELDNAME::SERVICE_NAME]; $single_am['url'] = $am[SR_TABLE_FIELDNAME::SERVICE_URL]; $single_am['urn'] = $am[SR_TABLE_FIELDNAME::SERVICE_URN]; $single_am['attributes'] = $am[SR_ARGUMENT::SERVICE_ATTRIBUTES]; $all_ams[$service_id] = $single_am; } } // print_r( $all_ams); // For comparing member records by role (low roles come before high roles) function compare_members_by_role($mem1, $mem2) {
function get_first_service_of_type($service_type) { global $SR_SERVICE_TYPE_NAMES; $sot = get_services_of_type($service_type); if (isset($sot) && is_array($sot) && count($sot) > 0) { $ans = $sot[0][SR_TABLE_FIELDNAME::SERVICE_URL]; return $ans; } else { error_log("Got back 0 services of type " . $SR_SERVICE_TYPE_NAMES[$service_type]); return null; } }
/** * Determine the aggregates in a given slice from the sliver info data. * * Return an array of the aggregates. */ function aggregates_in_slice($sa_url, $user, $slice_urn) { $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn); $all_aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); /* Construct a map from aggregate URN to aggregate for faster lookup inside the sliver loop. */ $urn2agg = array(); foreach ($all_aggs as $agg) { $agg_urn = $agg[SR_TABLE_FIELDNAME::SERVICE_URN]; $urn2agg[$agg_urn] = $agg; } $aggs_with_resources = array(); // map the sliver aggregate URNs to aggregate IDs foreach ($slivers as $sliver) { $urn = $sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_AGGREGATE_URN]; if (!array_key_exists($urn, $aggs_with_resources) && array_key_exists($urn, $urn2agg)) { $aggs_with_resources[$urn] = $urn2agg[$urn]; } } return array_values($aggs_with_resources); }
$PGCH_URL = $pgch[SR_TABLE_FIELDNAME::SERVICE_URL]; } $SA_URL = $PGCH_URL; $CH_URL = $PGCH_URL; /* Get the SA URN */ $sa_list = get_services_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY); if (count($sa_list) != 1) { error_log("flack must have exactly one SA service defined"); return "Should be exactly one SA."; } else { $sa = $sa_list[0]; $SA_URN = $sa[SR_TABLE_FIELDNAME::SERVICE_URN]; } /* Get the root certs, which are the signers of the SSL certs that the * aggregates use to speak SSL. */ $ca_services = get_services_of_type(SR_SERVICE_TYPE::CERTIFICATE_AUTHORITY); $am_root_cert_bundle = ""; foreach ($ca_services as $ca_service) { $ca_cert = $ca_service[SR_TABLE_FIELDNAME::SERVICE_CERT_CONTENTS]; $am_root_cert_bundle = $am_root_cert_bundle . $ca_cert; } $sa_url_parameter = $SA_URL; $sa_urn_parameter = $SA_URN; $ch_url_parameter = $CH_URL; $slice_urn_parameter = $slice_urn; $server_cert_parameter = $am_root_cert_bundle; /* * NOTE: Flack must use the inside cert & key. Flack does not know how * to do speaks-for, so cannot use the portal cert/key to talk to PGCH * or aggregates with a speaks-for credential. *
function show_am_chooser() { $all_aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); print '<select name="am_id" id="agg_chooser" onchange="am_onchange()">\\n'; echo '<option value="" title = "Choose an Aggregate">Choose an Aggregate...</option>'; foreach ($all_aggs as $agg) { $aggid = $agg['id']; $aggname = $agg['service_name']; $aggdesc = $agg['service_description']; print "<option value=\"{$aggid}\" title=\"{$aggdesc}\">{$aggname}</option>\n"; } // FIXME: Bound RSpecs not implemented yet // echo '<option disabled value="stitch" title="Stitchable RSpec">Stitchable RSpec</option>'; // echo '<option disabled value="bound" title="Bound RSpec">Bound RSpec</option>'; print "</select>\n"; // Display message to user about stitching/bound RSpecs print "<div id='aggregate_message' style='display:block;'></div>"; }
//$irods_url = 'http://iren-web.renci.org:8080/irods-rest-0.0.1-SNAPSHOT/rest'; //$irods_url = 'https://iren-web.renci.org:8443/irods-rest-0.0.1-SNAPSHOT/rest'; // Production server // $irods_url = 'https://geni-gimi.renci.org:8443/irods-rest-0.0.1-SNAPSHOT/rest'; /* TODO put these in the service registry or similar */ $irods_host = "emmy9.casa.umass.edu"; // FIXME $irods_port = 1247; // FIXME: Always right? $irods_resource = "demoResc"; // FIXME: Always right? $default_zone = "tempZone"; // This is only for the test server. The production server uses geniRenci // Get the irods server cert for smime purposes $irods_cert = null; $irods_svrs = get_services_of_type(SR_SERVICE_TYPE::IRODS); if (isset($irods_svrs) && !is_null($irods_svrs) && is_array($irods_svrs) && count($irods_svrs) > 0) { $irod = $irods_svrs[0]; if (is_null($irod[SR_TABLE_FIELDNAME::SERVICE_URL]) or trim($irod[SR_TABLE_FIELDNAME::SERVICE_URL]) == '') { error_log("null or empty irods_url from DB"); } else { $irods_url = $irod[SR_TABLE_FIELDNAME::SERVICE_URL]; $irods_cert = $irod[SR_TABLE_FIELDNAME::SERVICE_CERT]; } } // FIXME FIXME FIXME - see ticket #847 // HACK // The production iRODS server uses a different zone. But we don't know it. // The right thing may be to put this in the SR or the settings file, but for now: if (strpos($irods_url, "geni-gimi") !== FALSE and strpos($irods_url, "irods-rest-0.0.1-SNAP") !== FALSE) { // production server has a different zone
function setup_jacks_slice_context() { global $user; global $slice; global $slice_id; global $slice_name; global $ma_url; global $sa_url; global $all_ams; global $slice_ams; global $slice_urn; global $slice_expiration; // Set globals for variables used in slice jacks page later global $owner_email; global $slice_date_expiration; global $member_names; global $slice_creation; global $slice_desc; global $slice_owner_name; global $members; unset($slice); include "tool-lookupids.php"; if (!isset($sa_url)) { $sa_url = get_first_service_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY); } if (!isset($ma_url)) { $ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY); } if (isset($slice)) { $slice_name = $slice[SA_ARGUMENT::SLICE_NAME]; // error_log("SLICE = " . print_r($slice, true)); $slice_desc = $slice[SA_ARGUMENT::SLICE_DESCRIPTION]; $slice_creation_db = $slice[SA_ARGUMENT::CREATION]; $slice_creation = dateUIFormat($slice_creation_db); $slice_expiration_db = $slice[SA_ARGUMENT::EXPIRATION]; $slice_expiration = dateUIFormat($slice_expiration_db); $slice_date_expiration = dateOnlyUIFormat($slice_expiration_db); $slice_urn = $slice[SA_ARGUMENT::SLICE_URN]; $slice_owner_id = $slice[SA_ARGUMENT::OWNER_ID]; $owner = $user->fetchMember($slice_owner_id); $slice_owner_name = $owner->prettyName(); $owner_email = $owner->email(); $project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME]; //error_log("slice project_name result: $project_name\n"); // Fill in members of slice member table $members = get_slice_members($sa_url, $user, $slice_id); $member_names = lookup_member_names_for_rows($ma_url, $user, $members, SA_SLICE_MEMBER_TABLE_FIELDNAME::MEMBER_ID); //find only ams that slice has resources on $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn); //find aggregates to be able to return just am_id $all_aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); $aggs_with_resources = array(); //do the comparison and find ams foreach ($slivers as $sliver) { foreach ($all_aggs as $agg) { if ($sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_AGGREGATE_URN] == $agg[SR_TABLE_FIELDNAME::SERVICE_URN]) { $aggs_with_resources[] = $agg[SR_TABLE_FIELDNAME::SERVICE_ID]; break; } } } //return unique ids $slice_ams = array_unique($aggs_with_resources, SORT_REGULAR); // Now restore the array to a numerically ordered array because // array_unique preserves keys, so it could turn into, in effect, a // dictionary. $slice_ams = array_values($slice_ams); } else { print "Unable to load slice<br/>\n"; $_SESSION['lasterror'] = "Unable to load slice"; relative_redirect("home.php"); exit; } if (!isset($all_ams)) { $am_list = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); $all_ams = array(); foreach ($am_list as $am) { $single_am = array(); $service_id = $am[SR_TABLE_FIELDNAME::SERVICE_ID]; $single_am['name'] = $am[SR_TABLE_FIELDNAME::SERVICE_NAME]; $single_am['url'] = $am[SR_TABLE_FIELDNAME::SERVICE_URL]; $single_am['urn'] = $am[SR_TABLE_FIELDNAME::SERVICE_URN]; $all_ams[$service_id] = $single_am; } } }
/** * Write an aggregate nickname cache based on the service registry * entries. * * Returns TRUE on success, FALSE on failure * * It stinks that the SCS URL and latest_omni_version are hardcoded here. * The SCS URL could eventually be in the service registry. Not sure how * we figure out what the current version of omni is. */ function write_agg_nick_cache($dest) { $anc = '[omni_default]' . PHP_EOL; $anc .= 'scs_url=https://geni-scs.net.internet2.edu:8443/geni/xmlrpc' . PHP_EOL; $anc .= 'latest_omni_version=2.9,No newer omni version available' . PHP_EOL; $anc .= PHP_EOL; $anc .= '[aggregate_nicknames]' . PHP_EOL; $aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); foreach ($aggs as $agg) { $sn = $agg[SR_ARGUMENT::SERVICE_SHORT_NAME]; $urn = $agg[SR_ARGUMENT::SERVICE_URN]; $url = $agg[SR_ARGUMENT::SERVICE_URL]; if ($sn && $urn && $url) { // Only write this aggregate if we have all the necessary info $anc .= "{$sn}={$urn},{$url}" . PHP_EOL; } } // file_put_contents returns FALSE on failure // or the number of bytes written on success $result = file_put_contents($dest, $anc); return $result !== FALSE; }