Esempio n. 1
0
        $agg_urn = $agg[SR_TABLE_FIELDNAME::SERVICE_URN];
        if ($agg_urn == $slice_agg_urn) {
            $agg_url = $agg[SR_TABLE_FIELDNAME::SERVICE_URL];
            $all_slice_aggs[$agg_urn] = $agg_url;
            break;
        }
    }
}
// error_log("SLICE_AGGS = " . print_r($all_slice_aggs, true));
// Get the manifests for this slice at each aggregate in the sliver info
$manifests = array();
foreach ($all_slice_aggs as $agg_urn => $agg_url) {
    //  error_log("URN " . $agg_urn . " URL " . $agg_url);
    $slice_cred = get_slice_credential($sa_url, $user, $slice_id);
    //  error_log("SC = " . $slice_cred);
    $raw_output = list_resources_on_slice($agg_url, $user, $slice_cred, $slice_urn);
    if (is_null($raw_output)) {
        error_log("Null result from listresources at " . $agg_url . " on " . $slice_urn);
    } else {
        if (!is_array($raw_output)) {
            error_log("Error result from listresources at " . $agg_url . " on " . $slice_urn . ": '" . $raw_output . "'.");
        } else {
            $output = $raw_output[1][$agg_url];
            //  error_log("OUTPUT = " . print_r($output, true));
            if (array_key_exists('code', $output) && array_key_exists('value', $output) && array_key_exists('geni_code', $output['code']) && $output['code']['geni_code'] == 0) {
                $manifest = $output['value'];
                $manifests[$agg_urn] = $manifest;
            }
        }
    }
}
Esempio n. 2
0
function query_details($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-details!");
        $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 = list_resources_on_slice($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 list_resources_on_slice() FAILed";
            $obj = array();
        }
    }
    $retVal2 = array();
    $retVal2[] = $msg;
    $retVal2[] = $obj;
    $retVal2[] = $good;
    return $retVal2;
}