Esempio n. 1
0
define('AUTHURL', $_ENV['NOVA_URL']);
define('USERNAME', $_ENV['OS_USERNAME']);
define('TENANT', $_ENV['OS_TENANT_NAME']);
define('APIKEY', $_ENV['NOVA_API_KEY']);
*/
define('AUTHURL', 'https://identity.api.rackspacecloud.com/v2.0/');
define('USERNAME', 'onyourblog');
define('APIKEY', 'b3fa0f633b6f09d61c8e37b2b414769b');
$cloud = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
$cloud->Authenticate();
$arr = $cloud->ExportCredentials();
printf("%s Token [%s] expires in %5d seconds\n", date('r'), $arr['token'], $arr['expiration'] - time());
echo '<br>';
if ($cloud) {
    echo 'rackspace connection established<br>';
    $cloud->SetDefaults('ObjectStore', 'cloudFiles', 'ORD');
    $ostore = $cloud->ObjectStore();
    // uses default values
    if ($ostore) {
        echo 'ostore opened<br>';
        $containerlist = $ostore->ContainerList();
        while ($container = $containerlist->Next()) {
            // do something with the container
            printf("Container %s has %u bytes<br>", $container->name, $container->bytes);
        }
        $oyb_01 = $ostore->Container('oyb_01');
        echo 'Container ' . $oyb_01->name . ' has the following objects:<br>';
        $objlist = $oyb_01->ObjectList();
        while ($object = $objlist->Next()) {
            printf("Object %s, size=%u\n", $object->name, $object->bytes);
        }
Esempio n. 2
0
<?php

// (c)2012 Rackspace Hosting
// See COPYING for licensing information
require_once "php-opencloud.php";
define('INIFILE', 'auth.ini');
/**
 * Load the .INI file into an associative array. The second parameter causes it
 * to store the various [sections] of the .ini file. In our example, the
 * [Identity] section contains the auth secret info.
 */
$ini = parse_ini_file(INIFILE, TRUE);
if (!$ini) {
    printf("Unable to load .ini file [%s]\n", INIFILE);
    exit;
}
// establish our credentials
$RAX = new \OpenCloud\Rackspace($ini['Identity']['url'], $ini['Identity']);
$RAX->SetDefaults('Compute', $ini['Compute']['serviceName'], $ini['Compute']['region'], $ini['Compute']['urltype']);
$compute = $RAX->Compute();
$serverlist = $compute->ServerList();
while ($server = $serverlist->Next()) {
    print $server->name . "\n";
}