/**
  *  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;
 }
예제 #2
0
파일: RSCloud.php 프로젝트: huynt57/vs
 protected function checkLogin()
 {
     if (!$this->_uploadImported) {
         $setting = Yii::app()->params["accounts"]["rackspace"];
         require_once "OpenCloud/vendor/autoload.php";
         $client = new OpenCloud\Rackspace(OpenCloud\Rackspace::US_IDENTITY_ENDPOINT, array('username' => $setting["username"], 'apiKey' => $setting["apiKey"]));
         $ostore = $client->ObjectStoreService('cloudFiles', $setting["container_region"]);
         // now, connect to the ObjectStore service
         $this->cloudContainer = $ostore->getContainer($setting["container"]);
         $this->_uploadImported = true;
     }
 }
 /**
  *  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;
     }
 }
예제 #5
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";
예제 #6
0
파일: create.php 프로젝트: omusico/home365
<?php

// (c)2012 Rackspace Hosting
// See COPYING for licensing information
require '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
$cloud = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'tenantName' => TENANT, 'apiKey' => APIKEY));
// now, connect to the compute service
$autoscale = $cloud->Autoscale('autoscale', 'DFW');
print_r($autoscale);
예제 #7
0
define('RAXSDK_OBJSTORE_NAME', 'cloudFiles');
define('RAXSDK_OBJSTORE_REGION', 'DFW');
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']);
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__);
예제 #8
0
파일: flavors.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 compute service
$dbservice = $connection->DbService('cloudDatabases', 'DFW');
// list the flavors
print "Flavors:\n";
$flist = $dbservice->FlavorList();
while ($flavor = $flist->Next()) {
    printf("%5s - %-10s ram: %5dMB\n", $flavor->id, $flavor->name, $flavor->ram);
}
예제 #9
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $action = $this->argument('action');
     $publish = $action == 'publish';
     $delete = !$publish;
     $this->info('Starting cdn ' . $action);
     // Get all files from the CDN, store their names.  We'll be deleting those at the end.
     // Get our secret key
     // File kept out of repository.  Contents: <?php return 'whatever_the_key_is';
     $secret_key = (include 'secret_api_key.php');
     $client = new \OpenCloud\Rackspace('https://identity.api.rackspacecloud.com/v2.0/', array('username' => 'nicholas.wright', 'apiKey' => $secret_key));
     $objectStoreService = $client->objectStoreService(null, 'ORD');
     $container = $objectStoreService->getContainer('CAAS');
     $objects = $container->objectList();
     $existing_files = [];
     foreach ($objects as $object) {
         $existing_files[] = $object->getName();
     }
     // Only show this if we're publishing
     if ($publish) {
         $this->info(count($existing_files) . ' files found');
     }
     // Recursively go through JS and CSS.
     // Get the md5 of the contents.
     // If it's already in the deleted block, remove it from that array, no action
     // Otherwise, prepare the new filename
     //   and upload that file as the new filename into the cdn
     $files_to_upload = array();
     foreach (array('css', 'js') as $ext) {
         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('public/' . $ext)) as $filename) {
             // Ignore '..' or '.' directories.
             if (in_array(substr($filename, -2), array('..', '\\.', '/.'))) {
                 // \. for windows, /. for linux
                 continue;
             }
             // Change \'s to /'s, save this for later too
             $original_filename = $filename = preg_replace('/\\\\/', '/', $filename);
             // md5 file contents
             $md5 = md5_file($filename);
             // remove "public/"
             $filename = substr($filename, 7, strlen($filename));
             // Place md5 string inside filename
             $filename = preg_replace('/\\.' . $ext . '/', '.' . $md5 . '.' . $ext, $filename);
             // Does this file already exist?
             if (in_array($filename, $existing_files)) {
                 // remove it
                 $existing_files = array_diff($existing_files, array($filename));
                 // don't do anything else with this file
                 continue;
             }
             // Upload this file
             $files_to_upload[] = array('name' => $filename, 'path' => $original_filename);
             // Only show this if we're publishing
             if ($publish) {
                 $this->info('Uploading ' . $original_filename . ' as ' . $filename);
             }
         }
     }
     // Upload those files
     // Only if we're publishing
     if ($publish) {
         $container->uploadObjects($files_to_upload);
     }
     // Delete the necessary files
     // if they were safe to keep, they would have been removed from this array
     // Only delete if the command actions dictates
     if ($delete) {
         foreach ($existing_files as $ef) {
             $this->info('Deleting ' . $ef . ' from cdn');
             $object = $container->getObject($ef);
             $object->delete();
         }
     }
     $this->info('cdn ' . $action . ' finished');
     $this->comment('You may want to clear cache! (php artisan cache:clear)');
 }
예제 #10
0
 function rs_file_sync()
 {
     echo "\n###### Uploading Files To Rackspace ######\n";
     // Build a hash of all the files currently at rackspace.
     $connection = new \OpenCloud\Rackspace(RACKSPACE_US, array('username' => $this->cdn_user, 'apiKey' => $this->cdn_key));
     $ostore = $connection->objectStoreService();
     $cont = $ostore->getContainer($this->cdn_container);
     $list = $cont->objectList(array('prefix' => 'assets'));
     $mdhash = array();
     while ($o = $list->next()) {
         $file = $cont->getObject($o->getName());
         $mdhash[$o->name] = $o->hash;
     }
     // Loop through the different image directories. And see if we should upload the files to RS.
     foreach ($this->css_file_dirs as $key => $row) {
         echo "\n###### Reviewing - {$row} ######\n";
         $files = glob("{$row}/*.*");
         foreach ($files as $key2 => $row2) {
             $name = basename($row2);
             // See if the file is already uploaded at Rackspace
             if (isset($mdhash["assets/{$key}/" . $name]) && $mdhash["assets/{$key}/" . $name] == md5_file($row2)) {
                 continue;
             }
             $this->rs_upload($row2, "assets/{$key}/{$name}", mime_content_type($row2));
         }
     }
 }
예제 #11
0
 /**
  * @param string $args
  */
 public function edit_ajax($args = '')
 {
     $error = '';
     if (is_array($args)) {
         $ajax = FALSE;
     } else {
         if (!current_user_can('backwpup_jobs_edit')) {
             wp_die(-1);
         }
         check_ajax_referer('backwpup_ajax_nonce');
         $args['rscusername'] = $_POST['rscusername'];
         $args['rscapikey'] = $_POST['rscapikey'];
         $args['rscselected'] = $_POST['rscselected'];
         $args['rscregion'] = $_POST['rscregion'];
         $ajax = TRUE;
     }
     echo '<span id="rsccontainererror" style="color:red;">';
     $container_list = array();
     if (!empty($args['rscusername']) && !empty($args['rscapikey']) && !empty($args['rscregion'])) {
         try {
             $conn = new OpenCloud\Rackspace(self::get_auth_url_by_region($args['rscregion']), array('username' => $args['rscusername'], 'apiKey' => BackWPup_Encryption::decrypt($args['rscapikey'])));
             $ostore = $conn->objectStoreService('cloudFiles', $args['rscregion'], 'publicURL');
             $containerlist = $ostore->listContainers();
             while ($container = $containerlist->next()) {
                 $container_list[] = $container->name;
             }
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     if (empty($args['rscusername'])) {
         _e('Missing username!', 'backwpup');
     } elseif (empty($args['rscapikey'])) {
         _e('Missing API Key!', 'backwpup');
     } elseif (!empty($error)) {
         echo esc_html($error);
     } elseif (empty($container_list)) {
         _e("A container could not be found!", 'backwpup');
     }
     echo '</span>';
     if (!empty($container_list)) {
         echo '<select name="rsccontainer" id="rsccontainer">';
         foreach ($container_list as $container_name) {
             echo "<option " . selected(strtolower($args['rscselected']), strtolower($container_name), FALSE) . ">" . $container_name . "</option>";
         }
         echo '</select>';
     }
     if ($ajax) {
         die;
     } else {
         return;
     }
 }
예제 #12
0
            default:
        }
    }
}
if (!USERNAME || !APIKEY || !AUTHURL) {
    die('No environment values set');
}
/**
 * START THE TESTS!
 */
printf("SmokeTest started at %s\n", date(TIMEFORMAT, $start));
printf("Using endpoint [%s]\n", $_ENV['NOVA_URL']);
printf("Using region [%s]\n", MYREGION);
step('Authenticate');
$secret = array('username' => USERNAME, 'apiKey' => APIKEY);
$rackspace = new \OpenCloud\Rackspace(AUTHURL, $secret);
$rackspace->AppendUserAgent('(PHP SDK SMOKETEST)');
/**
 * load cached credentials
 */
$fp = @fopen(CACHEFILE, 'r');
if (!$fp) {
    // no cached credentials
    info('Saving credentials in %s', CACHEFILE);
    $rackspace->Authenticate();
    $cred = $rackspace->ExportCredentials();
    $fp = @fopen(CACHEFILE, 'w');
    if (!$fp) {
        die(sprintf("Cannot open cache file %s for writing\n", CACHEFILE));
    }
    fwrite($fp, serialize($cred));
예제 #13
0
<?php

$document_root = '/home/home365/public_html';
require_once $document_root . '/CDN/cdnDefine.php';
require_once $document_root . '/opencloud/lib/php-opencloud.php';
$_domainName = 'home365.ca';
require_once $document_root . '/CDN/cdnAdmin.php';
//require_once $_SERVER['DOCUMENT_ROOT'].'/Connections/cdnAdmin.php';
$cloud = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
if ($cloud) {
    $cloud->Authenticate();
    $cloud->SetDefaults('ObjectStore', 'cloudFiles', 'ORD');
}
예제 #14
0
define('APIKEY', $_ENV['NOVA_API_KEY']);
/**
 * numbers each step
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3));
}
define('TIMEFORMAT', 'r');
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'tenantName' => TENANT, 'apiKey' => APIKEY));
// parse command-line arguments
if ($argc > 1) {
    foreach ($argv as $arg) {
        switch ($arg) {
            case '-C':
            case '--catalog':
                print_r($rackspace->ServiceCatalog());
                break;
            case '-H':
            case '--help':
                printf(<<<ENDHELP
Switches:

    -C --catalog    Display service catalog
    -H --help       Display help message
예제 #15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Starting Image CDN Publish');
     $client = new \OpenCloud\Rackspace('https://identity.api.rackspacecloud.com/v2.0/', ['username' => env('RACKSPACE_USERNAME'), 'apiKey' => env('RACKSPACE_API_KEY')]);
     $objectStoreService = $client->objectStoreService(null, 'ORD');
     $container = $objectStoreService->getContainer('CAAS_Assets');
     // There's more than 10,000 items
     // http://docs.php-opencloud.com/en/latest/services/object-store/objects.html?highlight=objectlist#list-over-10-000-objects
     $existing_files = [];
     $marker = '';
     $this->info('Pulling existing images. Each dot represents 100 objects.');
     while ($marker !== null) {
         echo '.';
         $objects = $container->objectList(['marker' => $marker]);
         $total = $objects->count();
         $count = 0;
         if ($total == 0) {
             break;
         }
         foreach ($objects as $object) {
             $existing_files[] = $object->getName();
             if (++$count == $total) {
                 $marker = $object->getName();
                 break;
             } else {
                 $marker = null;
             }
         }
     }
     echo "\n";
     // Only show this if we're publishing
     $this->info(count($existing_files) . ' files found');
     // Recursively go through Images.
     // Get the md5 of the contents.
     // If it's already in the deleted block, remove it from that array, no action
     // Otherwise, prepare the new filename
     //   and upload that file as the new filename into the cdn
     $files_to_upload = array();
     $tally = 0;
     foreach (array('items/nq', 'items/hq') as $ext) {
         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('resources/assets/images/' . $ext)) as $filename) {
             // Ignore '..' or '.' directories.
             if (in_array(substr($filename, -2), array('..', '\\.', '/.'))) {
                 // \. for windows, /. for linux
                 continue;
             }
             $original_file = $filename->getPathname();
             $save_as = $ext . '/' . $filename->getFilename();
             // Upload this file
             if (!in_array($save_as, $existing_files)) {
                 $files_to_upload[] = array('name' => $save_as, 'path' => $original_file);
             }
         }
     }
     $this->info('Uploading ' . count($files_to_upload) . ' files in batches of 100.');
     // Upload in batches
     foreach (array_chunk($files_to_upload, 100) as $files) {
         $this->info('Uploading ' . count($files) . ' files.');
         $container->uploadObjects($files);
     }
     $this->info('cdn images publish finished');
 }
예제 #16
0
<?php

$connection = new \OpenCloud\Rackspace(RACKSPACE_US, array('username' => $data['Username'], 'apiKey' => $data['APIKey']));
$objstore = $connection->ObjectStore('cloudFiles', $data['ServerRegion'], "publicURL");
예제 #17
0
파일: cleanup.php 프로젝트: omusico/home365
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3));
}
define('TIMEFORMAT', 'r');
print "This script deletes things created in other sample code scripts\n";
printf("Region [%s]\n", MYREGION);
printf("Endpoint [%s]\n", AUTHURL);
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
step('Connect to Cloud Servers');
$cloudservers = $rackspace->Compute('cloudServersOpenStack', MYREGION);
step('Deleting servers');
$slist = $cloudservers->ServerList();
while ($server = $slist->Next()) {
    if (in_array($server->Name(), $keep_servers)) {
        info('Keeping %s', $server->Name());
    } else {
        info('Deleting %s', $server->Name());
        $server->Delete();
    }
}
step('Deleting the test network(s)');
$list = $cloudservers->NetworkList();
while ($network = $list->Next()) {
예제 #18
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;
     }
 }
예제 #19
0
파일: resize.php 프로젝트: omusico/home365
<?php

// (c)2012 Rackspace Hosting. See COPYING for license.
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']);
define('MYREGION', $_ENV['OS_REGION_NAME']);
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
$cservers = $rackspace->Compute('cloudServersOpenStack', MYREGION);
$list = $cservers->ServerList();
setDebug(TRUE);
$flavor = $cservers->Flavor(4);
setDebug(FALSE);
while ($server = $list->Next()) {
    if ($server->name == 'MODEL') {
        printf("Resizing %s [%s]\n", $server->Name(), $server->Id());
        $server->Resize($flavor);
    }
}
예제 #20
0
파일: listlb.php 프로젝트: omusico/home365
define('VOLUMESIZE', 100);
/**
 * numbers each step
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL, $p4 = NULL, $p5 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3, $p4, $p5));
}
define('TIMEFORMAT', 'r');
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
step('Connect to the Load Balancer Service');
$lbservice = $rackspace->LoadBalancerService('cloudLoadBalancers', 'DFW');
// allowed domains
$adlist = $lbservice->AllowedDomainList();
while ($ad = $adlist->Next()) {
    info('Allowed domain: [%s]', $ad->Name());
}
// protocols
info('Protocols:');
$prolist = $lbservice->ProtocolList();
while ($prot = $prolist->Next()) {
    info('  %s %4d', substr($prot->Name() . '.....................', 0, 20), $prot->port);
}
// algorithms
info('Algorithms:');
예제 #21
0
파일: volumes.php 프로젝트: omusico/home365
define('SERVERNAME', 'CBS-test-server');
/**
 * numbers each step
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL, $p4 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3, $p4));
}
define('TIMEFORMAT', 'r');
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
step('Connect to the Compute Service');
$compute = $rackspace->Compute('cloudServersOpenStack', 'DFW');
/*
step('List Extensions');
$arr = $compute->Extensions();
foreach($arr as $item)
	print($item->alias."\n");
exit;
*/
step('Connect to the VolumeService');
$cbs = $rackspace->VolumeService('cloudBlockStorage', 'DFW');
step('Volume Types');
$list = $cbs->VolumeTypeList();
while ($vtype = $list->Next()) {
    info('%s - %s', $vtype->id, $vtype->name);
예제 #22
0
파일: clone.php 프로젝트: omusico/home365
<?php

// (c)2012 Rackspace Hosting
// See COPYING for licensing information
require_once "php-opencloud.php";
// set this to the name of the domain to export
define('EXPORT_DOMAIN', 'fipplefippleraxdrg.info');
define('AUTHURL', RACKSPACE_US);
define('USERNAME', $_ENV['OS_USERNAME']);
define('TENANT', $_ENV['OS_TENANT_NAME']);
define('APIKEY', $_ENV['NOVA_API_KEY']);
// establish our credentials
$cloud = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
// uncomment to turn on debugging
//setDebug(TRUE);
$dns = $cloud->DNS();
$dlist = $dns->DomainList(array('name' => EXPORT_DOMAIN));
while ($domain = $dlist->Next()) {
    printf("Cloning %s\n", $domain->Name());
    //setDebug(TRUE);
    $resp = $domain->CloneDomain('NEWDOMAIN.IO');
    //setDebug(FALSE);
    $resp->WaitFor('COMPLETED', 300, 'ShowStatus', 1);
    // check result
    if ($resp->Status() == 'ERROR') {
        printf("Error code [%d] message [%s]\nDetails: [%s]\n", $resp->error->code, $resp->error->message, $resp->error->details);
    } else {
        if ($resp->Status() != 'COMPLETED') {
            printf("Unable to wait longer. Sorry.\n");
        }
    }
예제 #23
0
define('APIKEY', $_ENV['NOVA_API_KEY']);
/**
 * numbers each step
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3));
}
define('TIMEFORMAT', 'r');
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
step('Connect to Cloud Servers');
$cloudservers = $rackspace->Compute('cloudServersOpenStack', 'DFW');
step('Create a network SAMPLENET');
$samplenet = $cloudservers->Network();
$samplenet->Create(array('label' => 'SAMPLENET', 'cidr' => '192.168.0.0/24'));
step('List Networks');
$netlist = $cloudservers->NetworkList();
$netlist->Sort('label');
while ($net = $netlist->Next()) {
    info('%s: %s (%s)', $net->id, $net->label, $net->cidr);
}
step('Create two servers on SAMPLENET');
$list = $cloudservers->ImageList(TRUE, array('name' => 'CentOS 6.3'));
$image = $list->First();
$flavor = $cloudservers->Flavor(2);
예제 #24
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);
 }
예제 #25
0
<?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 compute service
$compute = $connection->Compute('cloudServersOpenStack', 'DFW');
// display our limits
print "Rate limits:\n";
$lim = $compute->Limits();
foreach ($lim->rate as $limit) {
    printf("Limit url=%s regex=%s:\n", isset($limit->url) ? $limit->url : 'N/A', $limit->regex);
    foreach ($limit->limit as $item) {
        printf("\tVerb: %s Unit: %s Remaining: %d Value: %d\n", $item->verb, $item->unit, $item->remaining, $item->value);
        $next = 'next-available';
        printf("\tNext available: %s\n", $item->{$next});
    }
}
/**
 * Now, we're going to try to hit the rate limits
 */
/* uncomment if you really want to do this
print("Trying to hit the rate limits\n");
$serverlist = $compute->ServerList();
$server = $serverlist->Next();        // we just need one server
예제 #26
0
 *
 */
require_once "../lib/php-opencloud.php";
/**
* Relies upon environment variable settings — these are the same environment
* variables that are used by python-novaclient. Just make sure that they're
* set to the right values before running this test.

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('TENANT', '839319');
define('APIKEY', 'b3fa0f633b6f09d61c8e37b2b414769b');
$mysecret = array('username' => 'onyourblog', 'password' => 'YVR2013ca');
// establish our credentials
if ($connection = new \OpenCloud\OpenStack(AUTHURL, $mysecret)) {
    echo 'connection established';
} else {
    echo 'connection failed';
}
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
//while(TRUE) {
$rackspace->Authenticate();
$arr = $rackspace->ExportCredentials();
printf("%s Token [%s] expires in %5d seconds\n", date('r'), $arr['token'], $arr['expiration'] - time());
//	sleep(60);
//}
예제 #27
0
파일: filter.php 프로젝트: omusico/home365
 * This sample illustrates how to create a Swift/CloudFiles object
 * from a file using the file_get_contents() function. It uses its
 * own source code as the data!
 */
define('NUM_OBJECTS', 30);
// the number of objects to create
define('CONTAINERNAME', 'OpenCloud-Sample-Container');
define('RAXSDK_OBJSTORE_NAME', 'cloudFiles');
define('RAXSDK_OBJSTORE_REGION', 'DFW');
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));
// create a Cloud Files (ObjectStore) connection
$ostore = $connection->ObjectStore();
// next, make a container named 'Sample'
printf("Creating container %s.\n", CONTAINERNAME);
$sample = $ostore->Container();
$sample->Create(array('name' => CONTAINERNAME));
// create a bunch of objects
printf("\nCreating %d randomly-named objects:\n", NUM_OBJECTS);
for ($i = 0; $i <= NUM_OBJECTS; $i++) {
    $obj = $sample->DataObject();
    $obj->SetData(rand());
    $obj->name = sprintf('%d-object-%d', rand(0, 9), rand(0, 999));
    $obj->Create(array('content_type' => 'text/plain'));
    printf("  Created %s\n", $obj->name);
}
예제 #28
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $action = $this->argument('action');
     $publish = $action == 'publish';
     $delete = !$publish;
     $this->info('Starting imgcdn ' . $action);
     // Get all files from the CDN, store their names.  We'll be deleting those at the end.
     // Get our secret key
     // File kept out of repository.  Contents: <?php return 'whatever_the_key_is';
     $secret_key = (include 'secret_api_key.php');
     $client = new \OpenCloud\Rackspace('https://identity.api.rackspacecloud.com/v2.0/', array('username' => 'nicholas.wright', 'apiKey' => $secret_key));
     $objectStoreService = $client->objectStoreService(null, 'ORD');
     $container = $objectStoreService->getContainer('CAAS_Assets');
     $objects = $container->objectList();
     $existing_files = [];
     foreach ($objects as $object) {
         $existing_files[] = $object->getName();
     }
     // Only show this if we're publishing
     if ($publish) {
         $this->info(count($existing_files) . ' files found');
     }
     // Recursively go through Images.
     // Get the md5 of the contents.
     // If it's already in the deleted block, remove it from that array, no action
     // Otherwise, prepare the new filename
     //   and upload that file as the new filename into the cdn
     $files_to_upload = array();
     $tally = 0;
     foreach (array('items/nq', 'items/hq') as $ext) {
         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/var/www/ffxivcrafting-assets/assets/' . $ext)) as $filename) {
             // Ignore '..' or '.' directories.
             if (in_array(substr($filename, -2), array('..', '\\.', '/.'))) {
                 // \. for windows, /. for linux
                 continue;
             }
             $original_file = $filename->getPathname();
             $save_as = $ext . '/' . $filename->getFilename();
             // Upload this file
             if (!in_array($save_as, $existing_files)) {
                 $files_to_upload[] = array('name' => $save_as, 'path' => $original_file);
             }
             // Upload in batches
             // Only show this if we're publishing
             // if ($publish)
             // 	$this->info('Uploading ' . $original_filename . ' as ' . $filename);
         }
     }
     if ($publish) {
         $this->info('Uploading ' . count($files_to_upload) . ' files in batches of 100.');
     }
     // Upload those files
     // Only if we're publishing
     if ($publish) {
         foreach (array_chunk($files_to_upload, 100) as $files) {
             $this->info('Uploading ' . count($files) . ' files.');
             $container->uploadObjects($files);
         }
     }
     // Delete the necessary files
     // if they were safe to keep, they would have been removed from this array
     // Only delete if the command actions dictates
     // if ($delete)
     // 	foreach ($existing_files as $ef)
     // 	{
     // 		$this->info('Deleting ' . $ef . ' from cdn');
     // 		$object = $container->getObject($ef);
     // 		$object->delete();
     // 	}
     $this->info('cdn ' . $action . ' finished');
     // $this->comment('You may want to clear cache! (php artisan cache:clear)');
 }
예제 #29
0
define('SERVERNAME', 'CBS-test-server');
/**
 * numbers each step
 */
function step($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    global $STEPCOUNTER;
    printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg, $p1, $p2, $p3));
}
function info($msg, $p1 = NULL, $p2 = NULL, $p3 = NULL)
{
    printf("  %s\n", sprintf($msg, $p1, $p2, $p3));
}
define('TIMEFORMAT', 'r');
step('Authenticate');
$rackspace = new \OpenCloud\Rackspace(AUTHURL, array('username' => USERNAME, 'apiKey' => APIKEY));
step('Connect to the VolumeService');
$cbs = $rackspace->VolumeService('cloudBlockStorage', 'DFW');
step('Snapshotting volumes');
$list = $cbs->VolumeList();
while ($vol = $list->Next()) {
    info('Volume: %s [%s] size=%d', $vol->display_name, $vol->display_description, $vol->size);
    $snap = $cbs->Snapshot();
    // empty snapshot object
    info('  Creating snapshot');
    //setDebug(TRUE);
    $snap->Create(array('display_name' => $vol->Name() . 'Snapshot-' . time(), 'volume_id' => $vol->id, 'force' => TRUE));
    setDebug(FALSE);
}
step('DONE');
exit;
예제 #30
0
 */
require_once "../lib/php-opencloud.php";
/**
* Relies upon environment variable settings — these are the same environment
* variables that are used by python-novaclient. Just make sure that they're
* set to the right values before running this test.

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);