Fix logging in swift

This commit is contained in:
Eldar Nugaev 2011-04-13 12:57:52 +00:00 committed by Tarmac
commit 9ad6223fd1
2 changed files with 39 additions and 3 deletions

View File

@ -111,9 +111,9 @@ class SwiftBackend(glance.store.Backend):
# should be a stateful object with options parsed once in # should be a stateful object with options parsed once in
# a constructor. # a constructor.
if not auth_address: if not auth_address:
logger.error(msg)
msg = ("Could not find swift_store_auth_address in configuration " msg = ("Could not find swift_store_auth_address in configuration "
"options.") "options.")
logger.error(msg)
raise glance.store.BackendException(msg) raise glance.store.BackendException(msg)
else: else:
full_auth_address = auth_address full_auth_address = auth_address
@ -121,15 +121,15 @@ class SwiftBackend(glance.store.Backend):
full_auth_address = 'https://' + full_auth_address full_auth_address = 'https://' + full_auth_address
if not user: if not user:
logger.error(msg)
msg = ("Could not find swift_store_user in configuration " msg = ("Could not find swift_store_user in configuration "
"options.") "options.")
logger.error(msg)
raise glance.store.BackendException(msg) raise glance.store.BackendException(msg)
if not key: if not key:
logger.error(msg)
msg = ("Could not find swift_store_key in configuration " msg = ("Could not find swift_store_key in configuration "
"options.") "options.")
logger.error(msg)
raise glance.store.BackendException(msg) raise glance.store.BackendException(msg)
swift_conn = swift_client.Connection( swift_conn = swift_client.Connection(

View File

@ -324,6 +324,42 @@ class TestSwiftBackend(unittest.TestCase):
SwiftBackend.add, SwiftBackend.add,
2, image_swift, SWIFT_OPTIONS) 2, image_swift, SWIFT_OPTIONS)
def test_add_no_user(self):
"""
Tests that adding options without user raises
an appropriate exception
"""
image_swift = StringIO.StringIO("nevergonnamakeit")
options = SWIFT_OPTIONS.copy()
del options['swift_store_user']
self.assertRaises(BackendException,
SwiftBackend.add,
2, image_swift, options)
def test_no_key(self):
"""
Tests that adding options without key raises
an appropriate exception
"""
image_swift = StringIO.StringIO("nevergonnamakeit")
options = SWIFT_OPTIONS.copy()
del options['swift_store_key']
self.assertRaises(BackendException,
SwiftBackend.add,
2, image_swift, options)
def test_add_no_auth_address(self):
"""
Tests that adding options without auth address raises
an appropriate exception
"""
image_swift = StringIO.StringIO("nevergonnamakeit")
options = SWIFT_OPTIONS.copy()
del options['swift_store_auth_address']
self.assertRaises(BackendException,
SwiftBackend.add,
2, image_swift, options)
def test_delete(self): def test_delete(self):
""" """
Test we can delete an existing image in the swift store Test we can delete an existing image in the swift store