コード例 #1
0
 protected static function setConfiguration()
 {
     if (file_exists('tests/settings.ini')) {
         self::$settings = parse_ini_file('tests/settings.ini');
     } else {
         throw new \Exception('Could not access test/settings.ini');
     }
     Bootstrap::setConfiguration(self::$settings);
 }
コード例 #2
0
 public function __construct($details)
 {
     parent::__construct($details);
     $this->file_path = 'swift://' . $details['file_path'];
     if (!self::$init) {
         $config = PerchConfig::get('openstack_object_storage');
         Bootstrap::useStreamWrappers();
         Bootstrap::setConfiguration(['account' => isset($config['account']) ? $config['account'] : null, 'key' => isset($config['key']) ? $config['key'] : null, 'username' => isset($config['username']) ? $config['username'] : null, 'password' => isset($config['password']) ? $config['password'] : null, 'tenantname' => isset($config['tenantname']) ? $config['tenantname'] : null, 'tenantid' => isset($config['tenantid']) ? $config['tenantid'] : null, 'endpoint' => $config['endpoint'], 'openstack.swift.region' => $config['region']]);
         self::$init = true;
     }
 }
コード例 #3
0
 public static function setUpBeforeClass()
 {
     self::setConfiguration();
     $service = self::createObjectStoreService();
     $containerName = self::$settings['openstack.swift.container'];
     $service->createContainer($containerName);
     try {
         self::$container = $service->container($containerName);
     } catch (\Exception $e) {
         $service->deleteContainer($containerName);
         throw $e;
     }
     self::$settings += ['username' => self::$settings['openstack.identity.username'], 'password' => self::$settings['openstack.identity.password'], 'endpoint' => self::$settings['openstack.identity.url'], 'tenantid' => self::$settings['openstack.identity.tenantId'], 'token' => $service->token(), 'swift_endpoint' => $service->url()];
     Bootstrap::setConfiguration(self::$settings);
 }
コード例 #4
0
 public function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     require_once $this->getBaseDir() . "/openstack-sdk-php/vendor/autoload.php";
     Bootstrap::useStreamWrappers();
     Bootstrap::setConfiguration(array('username' => $this->repository->getOption("USERNAME"), 'password' => $this->repository->getOption("PASSWORD"), 'tenantid' => $this->repository->getOption("TENANT_ID"), 'endpoint' => $this->repository->getOption("ENDPOINT"), 'openstack.swift.region' => $this->repository->getOption("REGION"), 'transport.ssl.verify' => false));
     $path = $this->repository->getOption("PATH");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $this->detectStreamWrapper(true);
     $this->urlBase = "pydio://" . $this->repository->getId();
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
コード例 #5
0
<?php

require_once $this->getBaseDir() . "/openstack-sdk-php/vendor/autoload.php";
use OpenStack\Bootstrap;
Bootstrap::useStreamWrappers();
Bootstrap::setConfiguration(array('username' => $this->repository->getOption("USERNAME"), 'password' => $this->repository->getOption("PASSWORD"), 'tenantid' => $this->repository->getOption("TENANT_ID"), 'endpoint' => $this->repository->getOption("ENDPOINT"), 'openstack.swift.region' => $this->repository->getOption("REGION"), 'transport.ssl.verify' => false));
コード例 #6
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use OpenStack\Bootstrap;
Bootstrap::useStreamWrappers();
$ini = parse_ini_file(getenv('HOME') . '/.OpenStack.ini');
$settings = ['account' => $ini['account'], 'key' => $ini['secret'], 'tenantid' => $ini['tenantId'], 'endpoint' => $ini['url']];
Bootstrap::setConfiguration($settings);
// Create a new file and write it to the object store.
$newfile = fopen('swift://Example/my_file.txt', 'w');
fwrite($newfile, "Good Morning!");
fclose($newfile);
// Check for an object:
if (file_exists('swift://Example/my_file.txt')) {
    print "Found my_file.txt." . PHP_EOL;
}
// Get an entire object at once:
$file = file_get_contents('swift://Example/my_file.txt');
print 'File: ' . $file . PHP_EOL;
$cxt = stream_context_create(['swift' => ['account' => $ini['account'], 'key' => $ini['secret'], 'tenantid' => $ini['tenantId'], 'endpoint' => $ini['url']]]);
print file_get_contents('swift://Example/my_file.txt', FALSE, $cxt);
コード例 #7
0
 /**
  * Test the bootstrap identity factory.
  * @depends testAuthenticateAsUser
  */
 public function testBootstrap()
 {
     // We need to save the config settings and reset the bootstrap to this.
     // It does not remove the old settings. The means the identity fall through
     // for different settings may not happen because of ordering. So, we cache
     // and reset back to the default for each test.
     $reset = Bootstrap::$config;
     // Test authenticating as a user.
     $settings = ['username' => self::conf('openstack.identity.username'), 'password' => self::conf('openstack.identity.password'), 'endpoint' => self::conf('openstack.identity.url'), 'tenantid' => self::conf('openstack.identity.tenantId'), 'transport' => self::conf('transport'), 'transport.debug' => self::conf('transport.debug', false), 'transport.ssl_verify' => self::conf('transport.ssl', true)];
     if (self::conf('transport.timeout')) {
         $setting['transport.timeout'] = self::conf('transport.timeout');
     }
     if (self::conf('transport.proxy')) {
         $setting['transport.proxy'] = self::conf('transport.proxy');
     }
     Bootstrap::setConfiguration($settings);
     $is = Bootstrap::identity(true);
     $this->assertInstanceOf('\\OpenStack\\Identity\\v2\\IdentityService', $is);
     // Test getting a second instance from the cache.
     $is2 = Bootstrap::identity();
     $this->assertEquals($is, $is2);
     // Test that forcing a refresh does so.
     $is2 = Bootstrap::identity(true);
     $this->assertNotEquals($is, $is2);
     Bootstrap::$config = $reset;
     // Test with tenant name
     $settings = ['username' => self::conf('openstack.identity.username'), 'password' => self::conf('openstack.identity.password'), 'endpoint' => self::conf('openstack.identity.url'), 'tenantname' => self::conf('openstack.identity.tenantName'), 'transport' => self::conf('transport'), 'transport.debug' => self::conf('transport.debug', false), 'transport.ssl_verify' => self::conf('transport.ssl', true)];
     if (self::conf('transport.timeout')) {
         $setting['transport.timeout'] = self::conf('transport.timeout');
     }
     if (self::conf('transport.proxy')) {
         $setting['transport.proxy'] = self::conf('transport.proxy');
     }
     Bootstrap::setConfiguration($settings);
     $is = Bootstrap::identity(true);
     $this->assertInstanceOf('\\OpenStack\\Identity\\v2\\IdentityService', $is);
 }