diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-08-14 16:42:09 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-08-14 16:42:09 +0000 |
commit | 33d7bbf6e3eb6855d5ccbcb63fee71f2dc5ddc3b (patch) | |
tree | f4a06fe4b7f8e98a44f8332cd11916d915d3aa7b | |
parent | dcc53b156025525c1d371400d037db4a62b5cde4 (diff) | |
parent | c496750d93ab525a42f05f7c38c717e4cdefaa9f (diff) | |
download | zuul-33d7bbf6e3eb6855d5ccbcb63fee71f2dc5ddc3b.tar.gz |
Merge "Provide swift credentials without requiring a connection"
-rw-r--r-- | doc/source/zuul.rst | 27 | ||||
-rw-r--r-- | zuul/lib/swift.py | 26 |
2 files changed, 36 insertions, 17 deletions
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst index cb49c82b4..7f9382612 100644 --- a/doc/source/zuul.rst +++ b/doc/source/zuul.rst @@ -190,9 +190,27 @@ To send (optional) swift upload instructions this section must be present. Multiple destinations can be defined in the :ref:`jobs` section of the layout. -**authurl** - The (keystone) Auth URL for swift +**X-Account-Meta-Temp-Url-Key** (optional) + This is the key used to sign the HMAC message. If you do not set a + key Zuul will generate one automatically. + +**Send-Temp-Url-Key** (optional) + Zuul can send the X-Account-Meta-Temp-Url-Key to swift for you if + you have set up the appropriate credentials in ``authurl`` below. + This isn't necessary if you know and have set your + X-Account-Meta-Temp-Url-Key. + ``default: true`` + +**X-Storage-Url** (optional) + The storage URL is the destination to upload files into. If you do + not set this the ``authurl`` credentials are used to fetch the url + from swift. + +**authurl** (optional) + The (keystone) Auth URL for swift. ``For example, https://identity.api.rackspacecloud.com/v2.0/`` + This is required if you have Send-Temp-Url-Key set to ``True`` or + if you have not supplied the X-Storage-Url. Any of the `swiftclient connection parameters`_ can also be defined here by the same name. Including the os_options by their key name ( @@ -200,11 +218,6 @@ here by the same name. Including the os_options by their key name ( .. _swiftclient connection parameters: http://docs.openstack.org/developer/python-swiftclient/swiftclient.html#module-swiftclient.client -**X-Account-Meta-Temp-Url-Key** (optional) - This is the key used to sign the HMAC message. zuul will send the - key to swift for you so you only need to define it here. If you do - not set a key zuul will generate one automatically. - **region_name** (optional) The region name holding the swift container ``For example, SYD`` diff --git a/zuul/lib/swift.py b/zuul/lib/swift.py index f95305859..88cd9053a 100644 --- a/zuul/lib/swift.py +++ b/zuul/lib/swift.py @@ -40,16 +40,29 @@ class Swift(object): ) self.storage_url = '' + if self.config.has_option('swift', 'X-Storage-Url'): + self.storage_url = self.config.get('swift', 'X-Storage-Url') try: - self.connect() + if self.config.has_section('swift'): + if (not self.config.has_option('swift', 'Send-Temp-Url-Key') + or self.config.getboolean('swift', 'Send-Temp-Url-Key')): + self.connect() + + # Tell swift of our key + headers = {} + headers['X-Account-Meta-Temp-Url-Key'] = self.secure_key + self.connection.post_account(headers) + + if not self.config.has_option('swift', 'X-Storage-Url'): + self.connect() + self.storage_url = self.connection.get_auth()[0] except Exception as e: self.log.warning("Unable to set up swift. Signed storage URL is " "likely to be wrong. %s" % e) def connect(self): - if self.config.has_section('swift'): - # required + if not self.connection: authurl = self.config.get('swift', 'authurl') user = (self.config.get('swift', 'user') @@ -106,13 +119,6 @@ class Swift(object): auth_version=auth_version, cacert=cacert, insecure=insecure, ssl_compression=ssl_compression) - # Tell swift of our key - headers = {} - headers['X-Account-Meta-Temp-Url-Key'] = self.secure_key - self.connection.post_account(headers) - - self.storage_url, self.auth_token = self.connection.get_auth() - def generate_form_post_middleware_params(self, destination_prefix='', **kwargs): """Generate the FormPost middleware params for the given settings""" |