Make swiftclient an optional dependency

I can not use the switclient on my installation and need a way to
prevent the swiftclient import entirely.

The only usage of the swiftclient module is to establish a connection
which only happen if there is a [swift] section in the configuration.

Moving the import from the top of the file next to its only usage would
make sure my installs never has to get swiftclient installed.

Change-Id: Ie2ef84f86f9f57796a85758147ba87d8b22c3e55
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index fec7198..122a605 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -182,8 +182,11 @@
 """""
 
 To send (optional) swift upload instructions this section must be
-present. Multiple destinations can be defined in the :ref:`jobs`
-section of the layout.
+present. Multiple destinations can be defined in the :ref:`jobs` section
+of the layout.
+
+If you are sending the temp-url-key or fetching the x-storage-url, you
+will need the python-swiftclient module installed.
 
 **X-Account-Meta-Temp-Url-Key** (optional)
   This is the key used to sign the HMAC message. If you do not set a
@@ -194,12 +197,13 @@
   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.
+  If set, Zuul requires the python-swiftclient module.
   ``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.
+  from swift and Zuul will requires the python-swiftclient module.
 
 **authurl** (optional)
   The (keystone) Auth URL for swift.
diff --git a/zuul/lib/swift.py b/zuul/lib/swift.py
index c5d540c..15e2fe6 100644
--- a/zuul/lib/swift.py
+++ b/zuul/lib/swift.py
@@ -19,7 +19,6 @@
 import os
 import random
 import string
-import swiftclient
 import urlparse
 
 
@@ -110,6 +109,7 @@
                 if self.config.has_option('swift', os_option):
                     os_options[os_option] = self.config.get('swift', os_option)
 
+            import swiftclient
             self.connection = swiftclient.client.Connection(
                 authurl=authurl, user=user, key=key, retries=retries,
                 preauthurl=preauthurl, preauthtoken=preauthtoken, snet=snet,