diff --git a/container.inc b/container.inc index 88068c2..d684e4a 100644 --- a/container.inc +++ b/container.inc @@ -107,6 +107,15 @@ abstract class StorageContainer { watchdog('storage', $msg, array('@container' => $this->name()), WATCHDOG_ERROR); throw new StorageException(t($msg, array('@container' => $this->name()))); } + } else { + try { + $this->serviceUrl(); + } + catch (StorageException $e) { + $msg = 'Failed to create storage container @container.'; + watchdog('storage', $msg, array('@container' => $this->name()), WATCHDOG_ERROR); + throw new StorageException(t($msg, array('@container' => $this->name()))); + } } drupal_write_record('storage_container', $this); @@ -643,6 +652,9 @@ abstract class StorageContainer { public function serviceSettingsDefault() { return array(); } + public function serviceUrl() { + return ''; + } public function servicePostCreate() {} public function serviceUpdate() {} public function serviceMaintenance() {} diff --git a/services/rackspace.inc b/services/rackspace.inc index 1effe60..6744e18 100644 --- a/services/rackspace.inc +++ b/services/rackspace.inc @@ -198,6 +198,19 @@ class StorageRackspace extends StorageContainer implements StorageContainerInter } } + public function serviceUrl() { + $this->init(); + + try { + $cf_container = $this->conn->get_container($this->settings['cf_container'])->cfs_http->head_cdn_container($this->settings['cf_container']); + $this->settings['base_url'] = $cf_container[5]; + return $this->settings['base_url']; + } catch (Exception $e) { + $this->log_exception($e); + throw new StorageException(); + } + } + public function serviceInfo() { $localities = $this->localities(); @@ -205,6 +218,7 @@ class StorageRackspace extends StorageContainer implements StorageContainerInter t('Locality') => $localities[$this->settings['locality']], t('Username') => $this->settings['username'], t('Container') => $this->settings['cf_container'], + t('CDN URI') => $this->settings['base_url'] ); return $info;