Commits

Ian Bicking committed 2f9e1ef

Add --libcloud-debug option

Comments (0)

Files changed (2)

silverlining/config.py

             else:
                 DriverClass = libcloud_get_driver(getattr(Provider, provider.upper()))
             self._driver = DriverClass(self['username'], self['secret'])
+            if getattr(self.args, 'debug_libcloud', False):
+                print 'XXX', self.args.debug_libcloud, self._driver.connection.conn_classes
+                from libcloud.base import LoggingHTTPConnection, LoggingHTTPSConnection
+                fp = open(self.args.debug_libcloud, 'a')
+                LoggingHTTPConnection.log = LoggingHTTPSConnection.log = fp
+                self._driver.connection.conn_classes = (
+                    LoggingHTTPConnection, LoggingHTTPSConnection)
         return self._driver
 
     @property

silverlining/runner.py

     action='store_true',
     help="Answer yes to any questions")
 
+parser.add_argument(
+    '--debug-libcloud', metavar='FILENAME',
+    help="Write any libcloud interactions (HTTP request log)")
+
 add_verbose(parser, add_log=True)
 
 subcommands = parser.add_subparsers(dest="command")