launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #16270
[Merge] lp:~stub/launchpad/swift-librarian-config into lp:launchpad
Stuart Bishop has proposed merging lp:~stub/launchpad/swift-librarian-config into lp:launchpad with lp:~stub/launchpad/swift-librarian as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stub/launchpad/swift-librarian-config/+merge/198220
Pull the Swift connection details from the Launchpad config file, rather than the OpenStack environment variables. While the OpenStack environment variables are 'standard', they might be a bit of a foot gun on our production setup.
--
https://code.launchpad.net/~stub/launchpad/swift-librarian-config/+merge/198220
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/swift-librarian-config into lp:launchpad.
=== modified file 'lib/lp/services/config/schema-lazr.conf'
--- lib/lp/services/config/schema-lazr.conf 2013-08-27 01:30:47 +0000
+++ lib/lp/services/config/schema-lazr.conf 2013-12-09 10:58:30 +0000
@@ -1132,6 +1132,20 @@
# datatype: string
root: none
+# Swift connection information and secret.
+#
+# datatype: urlbase
+os_auth_url: none
+
+# datatype: string
+os_username: none
+
+# datatype: string
+os_password: none
+
+# datatype: string
+os_tenant: none
+
# Mailman configuration. This is only a shim to the real Mailman
# configuration system and is primarily used to specify settings that
=== modified file 'lib/lp/services/librarianserver/swift.py'
--- lib/lp/services/librarianserver/swift.py 2013-11-26 06:35:29 +0000
+++ lib/lp/services/librarianserver/swift.py 2013-12-09 10:58:30 +0000
@@ -281,10 +281,10 @@
def _new_connection(self):
return swiftclient.Connection(
- authurl=os.environ.get('OS_AUTH_URL', None),
- user=os.environ.get('OS_USERNAME', None),
- key=os.environ.get('OS_PASSWORD', None),
- tenant_name=os.environ.get('OS_TENANT_NAME', None),
+ authurl=config.librarian_server.os_auth_url,
+ user=config.librarian_server.os_username,
+ key=config.librarian_server.os_password,
+ tenant_name=config.librarian_server.os_tenant,
auth_version='2.0',
)
=== modified file 'lib/lp/testing/swift/fixture.py'
--- lib/lp/testing/swift/fixture.py 2013-12-04 05:55:15 +0000
+++ lib/lp/testing/swift/fixture.py 2013-12-09 10:58:30 +0000
@@ -10,9 +10,10 @@
import shutil
import socket
import tempfile
+from textwrap import dedent
import time
-from fixtures import EnvironmentVariableFixture, FunctionFixture
+from fixtures import FunctionFixture
from s4 import hollow
from swiftclient import client as swiftclient
import testtools.content
@@ -20,6 +21,7 @@
from txfixtures.tachandler import TacTestFixture
from lp.services.config import config
+from lp.testing.layers import BaseLayer
class SwiftFixture(TacTestFixture):
@@ -54,15 +56,18 @@
testtools.content.attach_file(
self, logfile, 'swift-log', testtools.content_type.UTF8_TEXT)
- self.useFixture(EnvironmentVariableFixture(
- 'OS_AUTH_URL',
- 'http://localhost:{0}/keystone/v2.0/'.format(self.daemon_port)))
- self.useFixture(EnvironmentVariableFixture(
- 'OS_USERNAME', hollow.DEFAULT_USERNAME))
- self.useFixture(EnvironmentVariableFixture(
- 'OS_PASSWORD', hollow.DEFAULT_PASSWORD))
- self.useFixture(EnvironmentVariableFixture(
- 'OS_TENANT_NAME', hollow.DEFAULT_TENANT_NAME))
+ service_config = dedent("""\
+ [librarian_server]
+ os_auth_url: http://localhost:{0}/keystone/v2.0/
+ os_username: {1}
+ os_password: {2}
+ os_tenant: {3}
+ """.format(
+ self.daemon_port, hollow.DEFAULT_USERNAME,
+ hollow.DEFAULT_PASSWORD, hollow.DEFAULT_TENANT_NAME))
+ BaseLayer.config_fixture.add_section(service_config)
+ config.reloadConfig
+ assert config.librarian_server.os_tenant == 'test'
def setUpRoot(self):
# Create a root directory.
@@ -80,11 +85,11 @@
def connect(self):
"""Return a valid connection to our mock Swift"""
client = swiftclient.Connection(
- authurl=os.environ.get('OS_AUTH_URL', None),
+ authurl=config.librarian_server.os_auth_url,
auth_version="2.0",
- tenant_name=os.environ.get('OS_TENANT_NAME', None),
- user=os.environ.get('OS_USERNAME', None),
- key=os.environ.get('OS_PASSWORD', None),
+ tenant_name=config.librarian_server.os_tenant,
+ user=config.librarian_server.os_username,
+ key=config.librarian_server.os_password,
retries=0, insecure=True)
return client
=== modified file 'lib/lp/testing/swift/tests/test_fixture.py'
--- lib/lp/testing/swift/tests/test_fixture.py 2013-09-23 12:57:34 +0000
+++ lib/lp/testing/swift/tests/test_fixture.py 2013-12-09 10:58:30 +0000
@@ -7,11 +7,11 @@
__all__ = []
import httplib
-import os
from s4 import hollow
from swiftclient import client as swiftclient
+from lp.services.config import config
from lp.testing import TestCase
from lp.testing.layers import BaseLayer
from lp.testing.swift.fixture import SwiftFixture
@@ -77,10 +77,13 @@
self.assertEquals(body, "0" * size)
def test_env(self):
- self.assertEqual(hollow.DEFAULT_USERNAME, os.environ['OS_USERNAME'])
- self.assertEqual(hollow.DEFAULT_PASSWORD, os.environ['OS_PASSWORD'])
+ self.assertEqual(
+ hollow.DEFAULT_USERNAME, config.librarian_server.os_username)
+ self.assertEqual(
+ hollow.DEFAULT_PASSWORD, config.librarian_server.os_password)
self.assertEqual(
'http://localhost:{0}/keystone/v2.0/'.format(
- self.swift_fixture.daemon_port), os.environ['OS_AUTH_URL'])
+ self.swift_fixture.daemon_port),
+ config.librarian_server.os_auth_url)
self.assertEqual(
- hollow.DEFAULT_TENANT_NAME, os.environ['OS_TENANT_NAME'])
+ hollow.DEFAULT_TENANT_NAME, config.librarian_server.os_tenant)
Follow ups