1
# Copyright (C) 2015 Canonical
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""CI Automation: mojo helpers."""
33
def project_exists(project):
34
'''Check the provided mojo project exists.'''
40
out = subprocess.check_output(args)
42
if project in out.decode('utf8').split('\n'):
48
def new_workspace(project, stage, branch, name):
49
'''Create a fresh mojo workspace for the given project'''
54
'--stage={}'.format(stage),
59
utils.check_call(args)
62
def deploy(project, stage, branch, manifest, juju_home):
63
'''Deploy the given mojo project.'''
64
workspace_name = os.path.basename(juju_home)
65
env = os.environ.copy()
66
env['JUJU_HOME'] = juju_home
68
# Run juju status before trying to deploy as a safe workaround
69
# (https://bugs.launchpad.net/juju-deployer/+bug/1368403)
70
args = ['juju', 'status']
71
utils.check_call(args, env=env)
79
# Mojo 0.1.6 (ppa) does not like it, so -golive manifests
80
# are currently blocked.
81
# '--manifest-file', manifest,
86
utils.check_call(args, env=env)