Greetings, I got a ceph test cluster setup this week and I thought it would be 
neat if I could write a php script that let me start working with the adminops 
API.

I did some research to figure out how to correctly 'authorize' in the AWS 
fashion and wrote this little script.

<?php
function hex2b64($str) {
        $raw = '';
        for ($i=0; $i < strlen($str); $i+=2) {
                $raw .= chr(hexdec(substr($str, $i, 2)));
        }
        return base64_encode($raw);
}
$url_prefix = "http://host.com/";;
$url_string = "secretadmin/usage?format=json";
$the_url = "$url_prefix$url_string";
$AWSAccessKeyId = "accesskey";
$AWSSecretAccessKey = "secretaccesskey";
$Expires = time();
$HTTPVerb = "GET";
$ContentMD5 = "";
$ContentType = "";
$CanonicalizedAmzHeaders = "";
$CanonicalizedResource = $url_string;
$string_to_sign = $HTTPVerb . "\n" . $ContentMD5 . "\n" . $ContentType . "\n" . 
$Expires . "\n" . $CanonicalizedAmzHeaders . $CanonicalizedResource;
$sig = hash_hmac("sha1", $string_to_sign, $AWSSecretAccessKey);
$bsf = hex2b64($sig);
$ch = curl_init();
$head_array = Array("Authorization: AWS $AWSAccessKeyId:$bsf", "Host: 
host.com");
curl_setopt($ch, CURLOPT_HTTPHEADER, $head_array);
curl_setopt($ch, CURLOPT_URL,$the_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$err = curl_error($ch);
echo "making call to $the_url\n";
if ($err) {
        die("$err");
} else {
        die("$data");
}

Basically all I am trying to do is view the 'usage' in JSON format and no 
matter what I do it Returns AccessDenied

I did create a radosgw user and said user does have read for usage.

Can anyone give me a push in the right direction?
_______________________________________________
ceph-users mailing list
[email protected]
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com

Reply via email to