~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to schedule_hetero_control.py

  • Committer: Aaron Bentley
  • Date: 2015-09-02 17:46:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1082.
  • Revision ID: aaron.bentley@canonical.com-20150902174647-06vmnsooo6yzd46t
Stop supplying env to subprocess calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
            yield entry
41
41
 
42
42
 
43
 
def get_candidate_info(candidate_path):
44
 
    """ Return candidate version and revision build number. """
 
43
def get_candidate_version(candidate_path):
45
44
    with open(os.path.join(candidate_path, 'buildvars.json')) as fp:
46
 
        build_vars = json.load(fp)
47
 
    return build_vars['version'], build_vars['revision_build']
 
45
        return json.load(fp)['version']
48
46
 
49
47
 
50
48
def calculate_jobs(root, schedule_all=False):
52
50
    candidates_path = get_candidates_path(root)
53
51
    for candidate_path in find_candidates(root, schedule_all):
54
52
        parent, candidate = os.path.split(candidate_path)
55
 
        if candidate.startswith('1.26'):
56
 
            # 1.26 was renamed to 2.0 because it is not compatible with 1.x
57
 
            continue
58
53
        if parent != candidates_path:
59
54
            raise ValueError('Wrong path')
60
 
        candidate_version, revision_build = get_candidate_info(candidate_path)
 
55
        candidate_version = get_candidate_version(candidate_path)
61
56
        for release in releases:
62
 
            # Releases with the same major number must be compatible.
63
 
            if release[:2] != candidate[:2]:
 
57
            if is_osx_client(candidate) is not is_osx_client(release):
64
58
                continue
65
 
            for client_os in ('ubuntu', 'osx', 'windows'):
66
 
                yield {
67
 
                    'old_version': release,  # Client
68
 
                    'candidate': candidate_version,  # Server
69
 
                    'new_to_old': 'true',
70
 
                    'candidate_path': candidate,
71
 
                    'client_os': client_os,
72
 
                    'revision_build': revision_build,
73
 
                }
74
 
                yield {
75
 
                    'old_version': release,  # Server
76
 
                    'candidate': candidate_version,  # Client
77
 
                    'new_to_old': 'false',
78
 
                    'candidate_path': candidate,
79
 
                    'client_os': client_os,
80
 
                    'revision_build': revision_build,
81
 
                }
 
59
            client_os = 'ubuntu'
 
60
            if is_osx_client(release):
 
61
                client_os = 'osx'
 
62
            yield {
 
63
                'old_version': release,  # Client
 
64
                'candidate': candidate_version,  # Server
 
65
                'new_to_old': 'true',
 
66
                'candidate_path': candidate,
 
67
                'client_os': client_os,
 
68
            }
 
69
            yield {
 
70
                'old_version': release,  # Server
 
71
                'candidate': candidate_version,  # Client
 
72
                'new_to_old': 'false',
 
73
                'candidate_path': candidate,
 
74
                'client_os': client_os,
 
75
            }
 
76
 
 
77
 
 
78
def is_osx_client(path):
 
79
    return path.endswith('-osx')
82
80
 
83
81
 
84
82
def build_jobs(credentials, root, jobs):
85
83
    jenkins = Jenkins('http://localhost:8080', *credentials)
86
84
    token = get_auth_token(root, 'compatibility-control')
87
 
    os_str = {"ubuntu": "", "osx": "-osx", "windows": "-windows"}
88
85
    for job in jobs:
89
 
        jenkins.build_job(
90
 
            'compatibility-control{}'.format(os_str[job['client_os']]), job,
91
 
            token=token)
 
86
        jenkins.build_job('compatibility-control', job, token=token)
92
87
 
93
88
 
94
89
def main():