1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
4
# Snappy Ecosystem Tests
5
# Copyright (C) 2017 Canonical
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
"""Utility for printing Store versions of: CPI, SCA and SSO.
22
To be called as a standalone script.
27
DEFAULT_HEADER = "X-BZR-REVISION-NUMBER"
30
CPI=('https://search.apps.ubuntu.com/api/v1',
31
'https://search.apps.staging.ubuntu.com/api/v1'),
32
SCA=('https://myapps.developer.ubuntu.com/',
33
'https://myapps.developer.staging.ubuntu.com/'),
34
SSO=('https://login.ubuntu.com/',
35
'https://login.staging.ubuntu.com/'),
39
def get_deployed_revno(service, environment):
40
"""Get revno from service."""
41
prod, stag = SERVICES_INFO[service]
42
if environment == 'staging':
46
with requests.Session() as session:
47
resp = session.get(url)
48
if resp.status_code == 200:
49
revno = resp.headers[DEFAULT_HEADER]
51
print("{} 500'ed: {}".format(service, resp.text))
53
return service, environment, revno
57
"""Print Store components version"""
59
for service in SERVICES_INFO:
60
coro = get_deployed_revno(service, 'staging')
62
coro = get_deployed_revno(service, 'production')
65
data = {(service, kind): value for service, kind, value in coros}
66
print("#########################-STORE VERSIONS-#########################")
67
for service in sorted(SERVICES_INFO):
68
print("{}: Staging: {:>5}".format(service,
69
data[(service, 'staging')]))
70
print("{}: Production: {:>5}".format(service,
71
data[(service, 'production')]))
73
if __name__ == '__main__':