blob: 82abbf7fb46675a7c6c4d1341ea3a25837a0c8c8 [file] [log] [blame]
Vladimir Khlyunevf38cee22020-11-06 14:00:55 +04001import datetime
2import re
3import urllib.request
4
5
6def get_url_content(url):
7 with urllib.request.urlopen(url) as f:
8 return f.read().decode('utf-8')
9
10
11def get_snapshot_date(target_content):
12 date_regex = r".*(\d\d\d\d-\d\d-\d\d-\d\d\d\d\d\d)"
13 snapshot_date_str = re.findall(date_regex, target_content)[0]
14 date_format = "%Y-%m-%d-%H%M%S"
15 snapshot_date = datetime.datetime.strptime(snapshot_date_str, date_format)
16 return snapshot_date
17
18
19update_url = "http://mirror.mirantis.com/update/"
20proposed_section = "proposed/"
21releases_regex = r"2019.2.\d+"
22mirror_target_file = "xenial.target.txt"
23
24update_url_content = get_url_content(update_url)
25releases = re.findall(releases_regex, update_url_content)
26latest_release = sorted(set(releases),
27 key=lambda release: int(release.split('.')[2]))[-1]
28latest_release += "/"
29update_released_url = update_url + latest_release
30update_proposed_url = update_url + proposed_section
31
32proposed_subrepos = get_url_content(update_proposed_url)
33
34subrepos = ["cassandra/",
35 "ceph-luminous/",
36 "ceph-nautilus/",
37 "docker/",
38 "elasticsearch-5.x/",
39 "elasticsearch-6.x/",
40 "elasticsearch-curator-5/",
41 "extra/",
42 "glusterfs-5/",
43 "kubernetes-extra/",
44 "maas/",
45 "opencontrail-3.2/",
46 "opencontrail-4.0/",
47 "opencontrail-4.1/",
48 "opencontrail-5.0/",
49 "openstack-mitaka/",
50 "openstack-newton/",
51 "openstack-ocata/",
52 "openstack-pike/",
53 "openstack-queens/",
54 "percona/",
55 "salt-2017.7.8/",
56 "salt-formulas/",
57 "saltstack/",
58 "saltstack-2017.7/",
59 "td-agent/",
60 "ubuntu",
61 "maas-ephemeral-v3"]
62
63good_subrepos = []
64suspicious_subrepos = []
65error_subrepos = []
66
67
68def check_snapshot(subrepo):
69 if subrepo in ['ubuntu', 'maas-ephemeral-v3']:
70 proposed_target_url = "{}{}".format(
71 update_proposed_url, "{}.target.txt".format(subrepo))
72 released_target_url = "{}{}".format(
73 update_released_url, "{}.target.txt".format(subrepo))
74 else:
75 proposed_target_url = "{}{}{}".format(update_proposed_url, subrepo,
76 mirror_target_file)
77 released_target_url = "{}{}{}".format(update_released_url, subrepo,
78 mirror_target_file)
79
80 released_snapshot = get_url_content(released_target_url).splitlines()[0]
81 proposed_snapshot = get_url_content(proposed_target_url).splitlines()[0]
82 released_snapshot_date = get_snapshot_date(released_snapshot)
83 proposed_snapshot_date = get_snapshot_date(proposed_snapshot)
84 if proposed_snapshot_date > released_snapshot_date:
Vladimir Khlyunev0f333942020-11-16 17:14:18 +040085 good_subrepos.append([subrepo, proposed_snapshot])
Vladimir Khlyunevf38cee22020-11-06 14:00:55 +040086 elif proposed_snapshot_date == released_snapshot_date:
87 suspicious_subrepos.append([subrepo, proposed_snapshot])
88 else:
89 error_subrepos.append([subrepo, proposed_snapshot, released_snapshot])
90
91
92for subrepo in subrepos:
93 check_snapshot(subrepo)
94
Vladimir Khlyunev0f333942020-11-16 17:14:18 +040095for i in good_subrepos:
Vladimir Khlyunevf38cee22020-11-06 14:00:55 +040096 print("Repo {} - all fine, proposed is fresher than "
Vladimir Khlyunev0f333942020-11-16 17:14:18 +040097 "latest release\n{}".format(i[0], i[1]))
Vladimir Khlyunevf38cee22020-11-06 14:00:55 +040098print("Good news ended\n" + "=" * 79)
99for i in suspicious_subrepos:
100 print(
101 "Repo {} - same as previous release, ensure than this is fine:\n"
102 "{}".format(i[0], i[1]))
103print("Mediocre news ended\n" + "X" * 79)
104for i in error_subrepos:
105 print(
106 "ERROR: Repo {} IS OLDER THAN RELEASED ONE!!!\n"
107 "Released:{}\n"
108 "Proposed:{}".format(i[0], i[1], i[2]))
109if error_subrepos:
110 exit(1)