~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/preflight.py

  • Committer: Stuart Bishop
  • Date: 2011-11-08 11:45:46 UTC
  • mto: This revision was merged to the branch mainline in revision 14272.
  • Revision ID: stuart.bishop@canonical.com-20111108114546-jqyv52uw76ulfi6j
Report what patches are pending in preflight check

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
from datetime import timedelta
17
17
from optparse import OptionParser
 
18
import os.path
18
19
import time
19
20
 
20
21
import psycopg2
30
31
    logger_options,
31
32
    )
32
33
import replication.helpers
 
34
import upgrade
33
35
 
34
36
 
35
37
# Ignore connections by these users.
94
96
            self.lpmain_nodes = set(
95
97
                node for node in self.nodes
96
98
                if node.node_id in lpmain_node_ids)
 
99
 
 
100
            # Store a reference to the lpmain origin.
 
101
            lpmain_master_node_id = replication.helpers.get_master_node(
 
102
                master_con, 1).node_id
 
103
            self.lpmain_master_node = [
 
104
                node for node in self.lpmain_nodes
 
105
                    if node.node_id == lpmain_master_node_id][0]
97
106
        else:
98
107
            node = replication.helpers.Node(None, None, None, True)
99
108
            node.con = master_con
100
109
            self.nodes = set([node])
101
110
            self.lpmain_nodes = self.nodes
 
111
            self.lpmain_master_node = node
102
112
 
103
113
    def check_is_superuser(self):
104
114
        """Return True if all the node connections are as superusers."""
268
278
        else:
269
279
            return True
270
280
 
 
281
    def report_patches(self):
 
282
        """Report what patches are due to be applied from this tree."""
 
283
        con = self.lpmain_master_node.con
 
284
        upgrade.log = self.log
 
285
        for patch_num, patch_file in upgrade.get_patchlist(con):
 
286
            self.log.info("%s is pending", os.path.basename(patch_file))
 
287
 
271
288
    def check_all(self):
272
289
        """Run all checks.
273
290
 
278
295
            # to pg_stat_activity
279
296
            return False
280
297
 
 
298
        self.report_patches()
 
299
 
281
300
        success = True
282
301
        if not self.check_replication_lag():
283
302
            success = False