/**
  *  Openstack Connection Object
  */
 function connection_object()
 {
     $api_settings = $this->api_settings;
     $connection = new \OpenCloud\Rackspace($api_settings['url'], array('username' => $api_settings['username'], 'apiKey' => $api_settings['apiKey']));
     $cdn = $connection->ObjectStore('cloudFiles', $api_settings['region'], 'publicURL');
     return $cdn;
 }
 /**
  *  Openstack Connection Object
  */
 function connection_object()
 {
     if ($this->opencloud_version == '1.9.2') {
         // Return service
         return $this->oc_service;
     } else {
         // Get settings and connection object
         $api_settings = $this->api_settings;
         $connection = new \OpenCloud\Rackspace($api_settings->url, array('username' => $api_settings->username, 'apiKey' => $api_settings->apiKey));
         // Return connection object
         $cdn = $connection->ObjectStore('cloudFiles', $api_settings->region, 'publicURL');
         $this->oc_service = $cdn;
         return $cdn;
     }
 }
 /**
  *  Openstack Connection Object
  */
 function connection_object()
 {
     // If connection object is already set, return it
     if (isset($this->oc_connection)) {
         // Return existing connection object
         return $this->oc_connection;
     }
     // Get settings
     $api_settings = $this->api_settings;
     // Create connection object
     $connection = new \OpenCloud\Rackspace($api_settings->url, array('username' => $api_settings->username, 'apiKey' => $api_settings->apiKey));
     // Try to create connection object
     try {
         $cdn = $connection->ObjectStore('cloudFiles', $api_settings->region, 'publicURL');
         $this->oc_connection = $cdn;
         return $this->oc_connection;
     } catch (Exception $exc) {
         $this->oc_connection = null;
         return null;
     }
 }
예제 #4
0
파일: cdn.php 프로젝트: omusico/home365
<?php

// (c)2012 Rackspace Hosting
// See COPYING for licensing information
require_once "php-opencloud.php";
define('AUTHURL', RACKSPACE_US);
define('USERNAME', $_ENV['OS_USERNAME']);
define('TENANT', $_ENV['OS_TENANT_NAME']);
define('APIKEY', $_ENV['NOVA_API_KEY']);
// establish our credentials
$connection = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
// now, connect to the ObjectStore service
$objstore = $connection->ObjectStore('cloudFiles', 'DFW');
// create a new container
print "Creating CdnContainer\n";
$container = $objstore->Container();
$container->Create(array('name' => 'CdnContainer'));
// publish it to the CDN
print "Publishing to CDN...\n";
$cdnversion = $container->PublishToCDN();
printf("Container: %s\n", $container->name);
printf("      URL: %s\n", $container->Url());
printf("  CDN URL: %s\n", $container->CDNUrl());
// load this file into the CDN container
print "Creating a CDN object\n";
$object = $container->DataObject();
$object->Create(array('name' => 'FOOBAR'), __FILE__);
printf("  The CDN URL of the object is %s\n", $object->CDNUrl());
printf("The PublicURL of the object is %s\n", $object->PublicURL());
// get our containers
print "Containers:\n";
예제 #5
0
define('USERNAME', $_ENV['OS_USERNAME']);
define('TENANT', $_ENV['OS_TENANT_NAME']);
define('APIKEY', $_ENV['NOVA_API_KEY']);
define('TEMP_URL_SECRET', 'April is the cruellest month, breeding lilacs...');
define('CONTAINER_NAME', 'SampleContainer');
// progress callback function
function UploadProgress($len)
{
    printf("[uploading %d bytes]", $len);
}
// establish our credentials
$connection = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
// set the callback function
$connection->SetUploadProgressCallback('UploadProgress');
// create a Cloud Files (ObjectStore) connection
$ostore = $connection->ObjectStore();
//setDebug(TRUE);
// set the temp URL secret
$ostore->SetTempUrlSecret(TEMP_URL_SECRET);
// next, make a container named CONTAINER_NAME
printf("Creating container...\n");
$cont = $ostore->Container();
$cont->Create(array('name' => CONTAINER_NAME));
// finally, create an object in that container named hello.txt
printf("Creating object...\n");
$obj = $cont->DataObject();
$obj->Create(array('name' => 'SampleObject', 'content_type' => 'text/plain'), __FILE__);
printf("Reading object...\n");
$obj = $cont->DataObject('SampleObject');
//print_r($obj);
$obj->content_type = 'text/html';
예제 #6
0
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);
        }
        $oyb_test = $ostore->Container('oyb_test');
예제 #7
0
파일: cleanup.php 프로젝트: omusico/home365
    }
}
step('Deleting the test network(s)');
$list = $cloudservers->NetworkList();
while ($network = $list->Next()) {
    info('Deleting: %s %s', $network->id, $network->label);
    try {
        $network->Delete();
    } catch (OpenCloud\Common\Exceptions\DeleteError $e) {
        info('---Cannot delete');
    }
}
step('Connect to CBS');
$cbs = $rackspace->VolumeService('cloudBlockStorage', MYREGION);
step('Connect to Cloud Files');
$files = $rackspace->ObjectStore('cloudFiles', MYREGION);
step('Connect to Cloud Load Balancers');
$lbservice = $rackspace->LoadBalancerService('cloudLoadBalancers', MYREGION);
step('Deleting snapshots');
$list = $cbs->SnapshotList();
while ($snap = $list->Next()) {
    if ($snap->Status() == 'error' || $snap->Status() == 'available') {
        info('Deleting snapshot [%s] %s', $snap->id, $snap->Name());
        $snap->Delete();
    } else {
        info('[%s] %s status is %s', $snap->id, $snap->Name(), $snap->Status());
    }
}
step('Deleting objects');
$list = $files->ContainerList();
while ($container = $list->Next()) {
예제 #8
0
파일: nitro.php 프로젝트: BulatSa/Ctex
 public function rackspace_upload()
 {
     $persistence = $this->getPersistence();
     $data = $persistence['Nitro']['CDNRackspace'];
     $this->rackspace_set_progress('Initializing connection...', 0, 0, true);
     require_once DIR_SYSTEM . 'nitro/lib/rackspace/php-opencloud.php';
     $connection = new \OpenCloud\Rackspace(RACKSPACE_US, array('username' => $data['Username'], 'apiKey' => $data['APIKey']));
     $objstore = $connection->ObjectStore('cloudFiles', $data['ServerRegion'], "publicURL");
     $buckets = $objstore->ContainerList();
     $b = array();
     while ($con = $buckets->Next()) {
         $b[] = $con->Name();
     }
     if (!empty($data['SyncImages']) && !in_array($data['ImagesContainer'], $b)) {
         throw new Exception('The Image container &quot;' . $data['ImagesContainer'] . '&quot; does not exist. Please create it.');
     }
     if (!empty($data['SyncCSS']) && !in_array($data['CSSContainer'], $b)) {
         throw new Exception('The CSS container &quot;' . $data['CSSContainer'] . '&quot; does not exist. Please create it.');
     }
     if (!empty($data['SyncJavaScript']) && !in_array($data['JavaScriptContainer'], $b)) {
         throw new Exception('The JavaScript container &quot;' . $data['JavaScriptContainer'] . '&quot; does not exist. Please create it.');
     }
     $this->loadConfig();
     $this->loadCore();
     // The connection is successful. We can now start to upload :)
     // clearRackspacePersistence();
     $this->rackspace_set_progress('Scanning files...');
     $files = array();
     $site_root = dirname(DIR_SYSTEM) . '/';
     if (!empty($data['SyncCSS'])) {
         $files = array_merge($files, $this->list_files_with_ext($site_root, 'css'));
     }
     if (!empty($data['SyncJavaScript'])) {
         $files = array_merge($files, $this->list_files_with_ext($site_root, 'js'));
     }
     if (!empty($data['SyncImages'])) {
         $files = array_merge($files, $this->list_files_with_ext($site_root, array('png', 'jpg', 'jpeg', 'gif', 'tiff', 'bmp')));
     }
     $all_size = 0;
     $admin_folder_parts = array_filter(explode('/', DIR_APPLICATION));
     $admin_folder = array_pop($admin_folder_parts) . '/';
     $site_root = dirname(DIR_SYSTEM) . '/';
     clearstatcache(true);
     foreach ($files as $i => $file) {
         $destination = substr($file, strlen($site_root));
         // If in admin folder, omit
         if (stripos($destination, $admin_folder) === 0) {
             unset($files[$i]);
             continue;
         }
         if (file_exists($file) && is_file($file)) {
             $all_size += filesize($file);
         } else {
             unset($files[$i]);
         }
     }
     $this->rackspace_set_progress('Starting upload...', 0, $all_size);
     $this->rackspace_upload_files($objstore, $data, $files);
     $this->rackspace_set_progress('Task finished!', 'success');
     if ($this->session_closed) {
         session_start();
         $this->session_closed = false;
     }
 }
예제 #9
0
<?php

$connection = new \OpenCloud\Rackspace(RACKSPACE_US, array('username' => $data['Username'], 'apiKey' => $data['APIKey']));
$objstore = $connection->ObjectStore('cloudFiles', $data['ServerRegion'], "publicURL");
예제 #10
0
 /**
  * Connect to rackspace and get the object store's container
  * @param  string $container_name
  * @param  string $region         LON, DFW ...
  * @param  array  $options        options passed to constructor
  * @return OpenCloud\ObjectStore\Container
  */
 public static function connect($container_name, $region, array $options)
 {
     $conn = new \OpenCloud\Rackspace(Server_Rackspace::IDENTITY, $options);
     $object_store = $conn->ObjectStore('cloudFiles', $region, 'publicURL');
     return $object_store->Container($container_name);
 }
예제 #11
0
<?php

$connection = new \OpenCloud\Rackspace(RACKSPACE_US, array('username' => getNitroPersistence('CDNRackspace.Username'), 'apiKey' => getNitroPersistence('CDNRackspace.APIKey')));
$objstore = $connection->ObjectStore('cloudFiles', getNitroPersistence('CDNRackspace.ServerRegion'), "publicURL");