~gandelman-a/+junk/cloud-archive-utils

« back to all changes in this revision

Viewing changes to bin/cloud-archive-sru-released

  • Committer: Adam Gandelman
  • Date: 2013-07-01 20:47:20 UTC
  • Revision ID: adamg@canonical.com-20130701204720-0peq4s7wr9dc7pyp
Checkin bin/cloud-archive-sru-released.

A script to mark a Openstack SRU meta bug as Fix Released
in the UCA with references to the released UCA packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import logging
 
4
import optparse
 
5
import sys
 
6
 
 
7
from cloudarchive import utils as utils
 
8
 
 
9
from cloudarchive.common import SOURCE_RELEASE, LTS_SERIES
 
10
 
 
11
logging.basicConfig(level=logging.INFO)
 
12
 
 
13
 
 
14
if __name__ == '__main__':
 
15
    usage = 'usage: %prog [options] meta-bug-number'
 
16
    parser = optparse.OptionParser(usage=usage)
 
17
    parser.add_option('-d', '--dryrun', action='store_true',
 
18
                      dest='dryrun', default=False)
 
19
    (opts, args) = parser.parse_args()
 
20
 
 
21
    if len(args) != 1:
 
22
        parser.print_help()
 
23
        sys.exit(1)
 
24
    else:
 
25
        bug_no = args[0]
 
26
 
 
27
    lp_bug = utils.get_bug(bug_no)
 
28
 
 
29
    affected = utils.affected_packages(lp_bug)
 
30
    logging.info('Meta bug (LP: #%s) affects packages: %s.' %
 
31
                 (bug_no, affected))
 
32
 
 
33
    ubuntu_series = utils.meta_bug_distribution(lp_bug)
 
34
    openstack_series = [k for k, v in SOURCE_RELEASE.iteritems()
 
35
                        if v == ubuntu_series].pop()
 
36
 
 
37
    logging.info('Meta bug affects Ubuntu (%s) and OpenStack (%s)' %
 
38
                 (ubuntu_series, openstack_series))
 
39
 
 
40
    pocket = [k for k, v in LTS_SERIES.iteritems()
 
41
              if openstack_series in v].pop()
 
42
    pocket = '%s-%s' % (pocket, openstack_series)
 
43
 
 
44
    msg = 'This bug has been fixed in the Ubuntu Cloud Archive (%s):\n\n' %\
 
45
          pocket
 
46
 
 
47
    for package in affected:
 
48
        u_rel = utils.query_distro(package, ubuntu_series)
 
49
        ca_rel = utils.get_package_version(package, openstack_series)
 
50
        if not ca_rel.startswith(u_rel):
 
51
            logging.warn('UCA Package %s %s does not appear to be derived '
 
52
                         'from correpsonding Ubuntu %s package %s %s' %
 
53
                         (package, ca_rel, ubuntu_series, package, u_rel))
 
54
        msg += '    %s: %s\n' % (package, ca_rel)
 
55
 
 
56
    print 'Will post the following to bug (LP: #%s):' % bug_no
 
57
    print msg
 
58
 
 
59
    if opts.dryrun:
 
60
        logging.info('Dry run, bailing.')
 
61
        sys.exit(0)
 
62
 
 
63
    utils.set_cloud_archive_task_status(lp_bug, status='Fix Released')
 
64
    utils.post_message(bug=lp_bug, message=msg)