log("OpenStack authentication URL: ".$authurl); $client = new OpenStack($authurl, array( 'username' => $user, 'password' => $password, 'tenantName' => $tenant )); $this->client = $client; if ($disablesslverify) { $client->setSslVerification(false); } else { if ($useservercerts) { $client->setConfig(array($client::SSL_CERT_AUTHORITY => false)); } else { $client->setSslVerification(UPDRAFTPLUS_DIR.'/includes/cacert.pem', true, 2); } } $client->authenticate(); if (empty($region)) { $catalog = $client->getCatalog(); if (!empty($catalog)) { $items = $catalog->getItems(); if (is_array($items)) { foreach ($items as $item) { $name = $item->getName(); $type = $item->getType(); if ('swift' != $name || 'object-store' != $type) continue; $eps = $item->getEndpoints(); if (!is_array($eps)) continue; foreach ($eps as $ep) { if (is_object($ep) && !empty($ep->region)) { $region = $ep->region; } } } } } } $this->region = $region; return $client->objectStoreService('swift', $region); } /** * This method overrides the parent method and lists the supported features of this remote storage option. * * @return Array - an array of supported features (any features not * mentioned are assumed to not be supported) */ public function get_supported_features() { // This options format is handled via only accessing options via $this->get_options() return array('multi_options', 'config_templates', 'multi_storage'); } /** * Retrieve default options for this remote storage module. * * @return Array - an array of options */ public function get_default_options() { return array( 'user' => '', 'authurl' => '', 'password' => '', 'tenant' => '', 'path' => '', 'region' => '' ); } /** * Get the pre middlesection configuration template * * @return String - the template */ public function get_pre_configuration_middlesection_template() { ?>

">

get_css_classes(); ?> : output_settings_field_name_and_id('authurl');?> value="{{authurl}}" />
: output_settings_field_name_and_id('tenant');?> value="{{tenant}}" /> : output_settings_field_name_and_id('region');?> value="{{region}}" />
: output_settings_field_name_and_id('user');?> value="{{user}}" /> : output_settings_field_name_and_id('password');?> value="{{password}}" /> : output_settings_field_name_and_id('path');?> value="{{path}}" /> $posted_settings['user'], 'password' => $posted_settings['password'], 'authurl' => $posted_settings['authurl'], 'tenant' => $posted_settings['tenant'], 'region' => empty($posted_settings['region']) ? '' : $posted_settings['region'], ); $this->credentials_test_go($opts, $posted_settings['path'], $posted_settings['useservercerts'], $posted_settings['disableverify']); } }