~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/replication/new-slave.py

  • Committer: Jeroen Vermeulen
  • Date: 2011-09-19 06:57:55 UTC
  • mto: This revision was merged to the branch mainline in revision 13994.
  • Revision ID: jeroen.vermeulen@canonical.com-20110919065755-lgot1hi4xfqrf492
Lint.  Lots of lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python -S
2
2
#
3
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
3
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
4
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
5
 
6
6
"""Bring a new slave online."""
8
8
__metaclass__ = type
9
9
__all__ = []
10
10
 
11
 
import _pythonpath
12
 
 
13
11
from optparse import OptionParser
14
12
import subprocess
15
13
import sys
 
14
from textwrap import dedent
16
15
import time
17
 
from textwrap import dedent
18
16
 
 
17
import _pythonpath
19
18
import psycopg2
 
19
import replication.helpers
 
20
from replication.helpers import LPMAIN_SET_ID
20
21
 
21
22
from canonical.database.postgresql import ConnectionString
22
23
from canonical.database.sqlbase import (
23
 
    connect_string, ISOLATION_LEVEL_AUTOCOMMIT)
24
 
from canonical.launchpad.scripts import db_options, logger_options, logger
 
24
    connect_string,
 
25
    ISOLATION_LEVEL_AUTOCOMMIT,
 
26
    )
 
27
from canonical.launchpad.scripts import (
 
28
    db_options,
 
29
    logger,
 
30
    logger_options,
 
31
    )
25
32
 
26
 
import replication.helpers
27
 
from replication.helpers import LPMAIN_SET_ID
28
33
 
29
34
def main():
30
35
    parser = OptionParser(
194
199
        """)
195
200
 
196
201
    full_sync = []
197
 
    sync_nicknames = [node.nickname for node in existing_nodes]
198
 
    sync_nicknames.append('new_node');
 
202
    sync_nicknames = [node.nickname for node in existing_nodes] + ['new_node']
199
203
    for nickname in sync_nicknames:
200
204
        full_sync.append(dedent("""\
201
205
            echo 'Waiting for %(nickname)s sync.';
248
252
 
249
253
    # Confirm we can connect from here.
250
254
    try:
251
 
        test_con = psycopg2.connect(str(connection_string))
 
255
        # Test connection only.  We're not going to use it.
 
256
        psycopg2.connect(str(connection_string))
252
257
    except psycopg2.Error, exception:
253
258
        parser.error("Failed to connect to using '%s' (%s)" % (
254
259
            connection_string, str(exception).strip()))