Merge lp:~frankban/juju-quickstart/ppa-flag into lp:juju-quickstart

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 63
Proposed branch: lp:~frankban/juju-quickstart/ppa-flag
Merge into: lp:juju-quickstart
Diff against target: 147 lines (+87/-2)
4 files modified
quickstart/__init__.py (+1/-1)
quickstart/manage.py (+31/-1)
quickstart/packaging.py (+31/-0)
quickstart/tests/test_manage.py (+24/-0)
To merge this branch: bzr merge lp:~frankban/juju-quickstart/ppa-flag
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+214536@code.launchpad.net

Description of the change

Support the --ppa flag for distro packaging.

Add a packaging module suitable for being
easily modified when packaging quickstart for
distro repositories.

The new --ppa flag can be used to switch to ppa
when quickstart is installed from the default
repositories.

Tests: `make check`.

QA: there is no easy way to QA this.
It would require removing juju packages,
running quickstart with and without
the --distro-only and --ppa flags,
switching packaging.py to "distro"
and trying again.
I'll do that anyway as part of the next
release QA, so feel free to avoid QAing now.

https://codereview.appspot.com/84520047/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :
Download full text (6.8 KiB)

Reviewers: mp+214536_code.launchpad.net,

Message:
Please take a look.

Description:
Support the --ppa flag for distro packaging.

Add a packaging module suitable for being
easily modified when packaging quickstart for
distro repositories.

The new --ppa flag can be used to switch to ppa
when quickstart is installed from the default
repositories.

Tests: `make check`.

QA: there is no easy way to QA this.
It would require removing juju packages,
running quickstart with and without
the --distro-only and --ppa flags,
switching packaging.py to "distro"
and trying again.
I'll do that anyway as part of the next
release QA, so feel free to avoid QAing now.

https://code.launchpad.net/~frankban/juju-quickstart/ppa-flag/+merge/214536

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/84520047/

Affected files (+87, -1 lines):
   A [revision details]
   M quickstart/manage.py
   A quickstart/packaging.py
   M quickstart/tests/test_manage.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision:
<email address hidden>

Index: quickstart/manage.py
=== modified file 'quickstart/manage.py'
--- quickstart/manage.py 2014-03-27 10:38:01 +0000
+++ quickstart/manage.py 2014-04-07 10:11:34 +0000
@@ -32,6 +32,7 @@
  import quickstart
  from quickstart import (
      app,
+ packaging,
      settings,
      utils,
  )
@@ -53,6 +54,29 @@
          parser.exit()

+def _get_packaging_info(juju_source):
+ """Return packaging info based on the given juju source.
+
+ The juju_source argument can be either "ppa" or "distro".
+
+ Packaging info is a tuple containing:
+ - distro_only: whether to install juju-core packages from the
distro
+ repositories or the external PPA;
+ - distro_only_help: the help text for the --distro-only flag;
+ - ppa_help: the help text for the --ppa flag.
+ """
+ distro_only_help = ('Do not use external sources when installing and '
+ 'setting up Juju')
+ ppa_help = 'Use external sources when installing and setting up Juju'
+ if juju_source == 'distro':
+ distro_only = True
+ distro_only_help += '\n(enabled by default, use --ppa to disable)'
+ else:
+ distro_only = False
+ ppa_help += '\n(enabled by default, use --distro-only to disable)'
+ return distro_only, distro_only_help, ppa_help
+
+
  def _validate_bundle(options, parser):
      """Validate and process the bundle options.

@@ -317,6 +341,8 @@
      Exit with an error if the provided arguments are not valid.
      """
      default_env_name = envs.get_default_env_name()
+ default_distro_only, distro_only_help, ppa_help = _get_packaging_info(
+ packaging.JUJU_SOURCE)
      # Define the help message for the --environment option.
      env_help = 'The name of the Juju environment to use'
      if default_env_name is not None:
@@ -377,7 +403,10 @@
          help...

Read more...

Revision history for this message
Brad Crittenden (bac) wrote :

LGTM

https://codereview.appspot.com/84520047/diff/1/quickstart/manage.py
File quickstart/manage.py (right):

https://codereview.appspot.com/84520047/diff/1/quickstart/manage.py#newcode76
quickstart/manage.py:76: ppa_help += '\n(enabled by default, use
--distro-only to disable)'
DRY: pull out this message into a template that gets populated
appropriately? +0

https://codereview.appspot.com/84520047/

74. By Francesco Banconi

Changes as per review.

Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Support the --ppa flag for distro packaging.

Add a packaging module suitable for being
easily modified when packaging quickstart for
distro repositories.

The new --ppa flag can be used to switch to ppa
when quickstart is installed from the default
repositories.

Tests: `make check`.

QA: there is no easy way to QA this.
It would require removing juju packages,
running quickstart with and without
the --distro-only and --ppa flags,
switching packaging.py to "distro"
and trying again.
I'll do that anyway as part of the next
release QA, so feel free to avoid QAing now.

R=bac
CC=
https://codereview.appspot.com/84520047

https://codereview.appspot.com/84520047/diff/1/quickstart/manage.py
File quickstart/manage.py (right):

https://codereview.appspot.com/84520047/diff/1/quickstart/manage.py#newcode76
quickstart/manage.py:76: ppa_help += '\n(enabled by default, use
--distro-only to disable)'
On 2014/04/07 14:46:33, bac wrote:
> DRY: pull out this message into a template that gets populated
appropriately?
> +0

Done.

https://codereview.appspot.com/84520047/

Revision history for this message
Francesco Banconi (frankban) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quickstart/__init__.py'
2--- quickstart/__init__.py 2014-03-27 10:44:34 +0000
3+++ quickstart/__init__.py 2014-04-07 15:53:06 +0000
4@@ -45,7 +45,7 @@
5 Once Juju has been installed, the command can also be run as a juju plugin,
6 without the hyphen ("juju quickstart").
7 """
8-VERSION = (1, 3, 0)
9+VERSION = (1, 3, 1)
10
11
12 def get_version():
13
14=== modified file 'quickstart/manage.py'
15--- quickstart/manage.py 2014-03-27 10:38:01 +0000
16+++ quickstart/manage.py 2014-04-07 15:53:06 +0000
17@@ -32,6 +32,7 @@
18 import quickstart
19 from quickstart import (
20 app,
21+ packaging,
22 settings,
23 utils,
24 )
25@@ -53,6 +54,30 @@
26 parser.exit()
27
28
29+def _get_packaging_info(juju_source):
30+ """Return packaging info based on the given juju source.
31+
32+ The juju_source argument can be either "ppa" or "distro".
33+
34+ Packaging info is a tuple containing:
35+ - distro_only: whether to install juju-core packages from the distro
36+ repositories or the external PPA;
37+ - distro_only_help: the help text for the --distro-only flag;
38+ - ppa_help: the help text for the --ppa flag.
39+ """
40+ distro_only_help = ('Do not use external sources when installing and '
41+ 'setting up Juju')
42+ ppa_help = 'Use external sources when installing and setting up Juju'
43+ disable_help = '\n(enabled by default, use {} to disable)'
44+ if juju_source == 'distro':
45+ distro_only = True
46+ distro_only_help += disable_help.format('--ppa')
47+ else:
48+ distro_only = False
49+ ppa_help += disable_help.format('--distro-only')
50+ return distro_only, distro_only_help, ppa_help
51+
52+
53 def _validate_bundle(options, parser):
54 """Validate and process the bundle options.
55
56@@ -317,6 +342,8 @@
57 Exit with an error if the provided arguments are not valid.
58 """
59 default_env_name = envs.get_default_env_name()
60+ default_distro_only, distro_only_help, ppa_help = _get_packaging_info(
61+ packaging.JUJU_SOURCE)
62 # Define the help message for the --environment option.
63 env_help = 'The name of the Juju environment to use'
64 if default_env_name is not None:
65@@ -377,7 +404,10 @@
66 help='Avoid opening the browser to the GUI at the end of the\nprocess')
67 parser.add_argument(
68 '--distro-only', action='store_true', dest='distro_only',
69- help='Do not use external sources when installing and setting up Juju')
70+ default=default_distro_only, help=distro_only_help)
71+ parser.add_argument(
72+ '--ppa', action='store_false', dest='distro_only',
73+ default=not default_distro_only, help=ppa_help)
74 parser.add_argument(
75 '--version', action='version', version='%(prog)s {}'.format(version))
76 parser.add_argument(
77
78=== added file 'quickstart/packaging.py'
79--- quickstart/packaging.py 1970-01-01 00:00:00 +0000
80+++ quickstart/packaging.py 2014-04-07 15:53:06 +0000
81@@ -0,0 +1,31 @@
82+# This file is part of the Juju Quickstart Plugin, which lets users set up a
83+# Juju environment in very few steps (https://launchpad.net/juju-quickstart).
84+# Copyright (C) 2014 Canonical Ltd.
85+#
86+# This program is free software: you can redistribute it and/or modify it under
87+# the terms of the GNU Affero General Public License version 3, as published by
88+# the Free Software Foundation.
89+#
90+# This program is distributed in the hope that it will be useful, but WITHOUT
91+# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
92+# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93+# Affero General Public License for more details.
94+#
95+# You should have received a copy of the GNU Affero General Public License
96+# along with this program. If not, see <http://www.gnu.org/licenses/>.
97+
98+"""Juju Quickstart packaging configuration.
99+
100+This module is parsed and modified in the process of packaging quickstart
101+for Ubuntu distributions.
102+
103+DO NOT MODIFY this file without informing server/distro developers.
104+"""
105+
106+# The source from where to install juju-core packages.
107+# Possible values are:
108+# - ppa: the Juju stable packages PPA. This value is usually set in the code
109+# base and PyPI releases;
110+# - distro: the distribution repository. This value is usually set in the deb
111+# releases included in the Ubuntu repositories.
112+JUJU_SOURCE = 'ppa'
113
114=== modified file 'quickstart/tests/test_manage.py'
115--- quickstart/tests/test_manage.py 2014-03-14 16:50:22 +0000
116+++ quickstart/tests/test_manage.py 2014-04-07 15:53:06 +0000
117@@ -58,6 +58,30 @@
118 mock_exit.assert_called_once_with(0)
119
120
121+class TestGetPackagingInfo(unittest.TestCase):
122+
123+ distro_only_disable = '(enabled by default, use --ppa to disable)'
124+ ppa_disable = '(enabled by default, use --distro-only to disable)'
125+
126+ def test_ppa_source(self):
127+ # The returned distro_only flag is set to False and the help texts are
128+ # formatted accordingly when the passed Juju source is "ppa".
129+ distro_only, distro_only_help, ppa_help = manage._get_packaging_info(
130+ 'ppa')
131+ self.assertFalse(distro_only)
132+ self.assertNotIn(self.distro_only_disable, distro_only_help)
133+ self.assertIn(self.ppa_disable, ppa_help)
134+
135+ def test_distro_source(self):
136+ # The returned distro_only flag is set to True and the help texts are
137+ # formatted accordingly when the passed Juju source is "distro".
138+ distro_only, distro_only_help, ppa_help = manage._get_packaging_info(
139+ 'distro')
140+ self.assertTrue(distro_only)
141+ self.assertIn(self.distro_only_disable, distro_only_help)
142+ self.assertNotIn(self.ppa_disable, ppa_help)
143+
144+
145 class TestValidateBundle(
146 helpers.BundleFileTestsMixin, helpers.UrlReadTestsMixin,
147 unittest.TestCase):

Subscribers

People subscribed via source and target branches