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.
+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='Avoid opening the browser to the GUI at the end of
the\nprocess')
parser.add_argument( '--distro-only', action='store_true', dest='distro_only',
- help='Do not use external sources when installing and setting up
Juju')
+ default=default_distro_only, help=distro_only_help)
+ parser.add_argument(
+ '--ppa', action='store_false', dest='distro_only',
+ default=not default_distro_only, help=ppa_help)
parser.add_argument( '--version', action='version', version='%(prog)s
{}'.format(version))
parser.add_argument(
Index: quickstart/packaging.py
=== added file 'quickstart/packaging.py'
--- quickstart/packaging.py 1970-01-01 00:00:00 +0000
+++ quickstart/packaging.py 2014-04-07 10:10:13 +0000
@@ -0,0 +1,31 @@
+# This file is part of the Juju Quickstart Plugin, which lets users set up
a
+# Juju environment in very few steps
(https://launchpad.net/juju-quickstart).
+# Copyright (C) 2014 Canonical Ltd.
+#
+# This program is free software: you can redistribute it and/or modify it
under
+# the terms of the GNU Affero General Public License version 3, as
published by
+# the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
WITHOUT
+# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""Juju Quickstart packaging configuration.
+
+This module is parsed and modified in the process of packaging quickstart
+for Ubuntu distributions.
+
+DO NOT MODIFY this file without informing server/distro developers.
+"""
+
+# The source from where to install juju-core packages.
+# Possible values are:
+# - ppa: the Juju stable packages PPA. This value is usually set in the
code
+# base and PyPI releases;
+# - distro: the distribution repository. This value is usually set in
the deb
+# releases included in the Ubuntu repositories.
+JUJU_SOURCE = 'ppa'
+class TestGetPackagingInfo(unittest.TestCase):
+
+ distro_only_disable = '(enabled by default, use --ppa to disable)'
+ ppa_disable = '(enabled by default, use --distro-only to disable)'
+
+ def test_ppa_source(self):
+ # The returned distro_only flag is set to False and the help texts
are
+ # formatted accordingly when the passed Juju source is "ppa".
+ distro_only, distro_only_help, ppa_help =
manage._get_packaging_info(
+ 'ppa')
+ self.assertFalse(distro_only)
+ self.assertNotIn(self.distro_only_disable, distro_only_help)
+ self.assertIn(self.ppa_disable, ppa_help)
+
+ def test_distro_source(self):
+ # The returned distro_only flag is set to True and the help texts
are
+ # formatted accordingly when the passed Juju source is "distro".
+ distro_only, distro_only_help, ppa_help =
manage._get_packaging_info(
+ 'distro')
+ self.assertTrue(distro_only)
+ self.assertIn(self.distro_only_disable, distro_only_help)
+ self.assertNotIn(self.ppa_disable, ppa_help)
+
+
class TestValidateBundle( helpers.BundleFileTestsMixin, helpers.UrlReadTestsMixin, unittest.TestCase):
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): manage. py packaging. py tests/test_ manage. py
A [revision details]
M quickstart/
A quickstart/
M quickstart/
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 manage. py' manage. py 2014-03-27 10:38:01 +0000 manage. py 2014-04-07 10:11:34 +0000
parser. exit()
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -32,6 +32,7 @@
import quickstart
from quickstart import (
app,
+ packaging,
settings,
utils,
)
@@ -53,6 +54,29 @@
+def _get_packaging_ info(juju_ source) : bundle( options, parser):
+ """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_
"""Validate and process the bundle options.
@@ -317,6 +341,8 @@ env_name = envs.get_ default_ env_name( ) distro_ only, distro_only_help, ppa_help = _get_packaging_ info( JUJU_SOURCE)
help= 'Avoid opening the browser to the GUI at the end of add_argument(
'--distro- only', action= 'store_ true', dest='distro_only', default_ distro_ only, help=distro_ only_help) add_argument( 'store_ false', dest='distro_only', distro_ only, help=ppa_help) add_argument(
'--version' , action='version', version='%(prog)s version) ) add_argument(
Exit with an error if the provided arguments are not valid.
"""
default_
+ default_
+ packaging.
# 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 @@
the\nprocess')
parser.
- help='Do not use external sources when installing and setting up
Juju')
+ default=
+ parser.
+ '--ppa', action=
+ default=not default_
parser.
{}'.format(
parser.
Index: quickstart/ packaging. py packaging. py' packaging. py 1970-01-01 00:00:00 +0000 packaging. py 2014-04-07 10:10:13 +0000 /launchpad. net/juju- quickstart). www.gnu. org/licenses/>.
=== added file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -0,0 +1,31 @@
+# This file is part of the Juju Quickstart Plugin, which lets users set up
a
+# Juju environment in very few steps
(https:/
+# Copyright (C) 2014 Canonical Ltd.
+#
+# This program is free software: you can redistribute it and/or modify it
under
+# the terms of the GNU Affero General Public License version 3, as
published by
+# the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
WITHOUT
+# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://
+
+"""Juju Quickstart packaging configuration.
+
+This module is parsed and modified in the process of packaging quickstart
+for Ubuntu distributions.
+
+DO NOT MODIFY this file without informing server/distro developers.
+"""
+
+# The source from where to install juju-core packages.
+# Possible values are:
+# - ppa: the Juju stable packages PPA. This value is usually set in the
code
+# base and PyPI releases;
+# - distro: the distribution repository. This value is usually set in
the deb
+# releases included in the Ubuntu repositories.
+JUJU_SOURCE = 'ppa'
Index: quickstart/ tests/test_ manage. py tests/test_ manage. py' tests/test_ manage. py 2014-03-14 16:50:22 +0000 tests/test_ manage. py 2014-04-07 10:29:29 +0000
mock_ exit.assert_ called_ once_with( 0)
=== modified file 'quickstart/
--- quickstart/
+++ quickstart/
@@ -58,6 +58,30 @@
+class TestGetPackagin gInfo(unittest. TestCase) : source( self): _get_packaging_ info( e(distro_ only) n(self. distro_ only_disable, distro_only_help) self.ppa_ disable, ppa_help) source( self): _get_packaging_ info( (distro_ only) self.distro_ only_disable, distro_only_help) n(self. ppa_disable, ppa_help)
helpers. BundleFileTests Mixin, helpers. UrlReadTestsMix in,
unittest. TestCase) :
+
+ distro_only_disable = '(enabled by default, use --ppa to disable)'
+ ppa_disable = '(enabled by default, use --distro-only to disable)'
+
+ def test_ppa_
+ # The returned distro_only flag is set to False and the help texts
are
+ # formatted accordingly when the passed Juju source is "ppa".
+ distro_only, distro_only_help, ppa_help =
manage.
+ 'ppa')
+ self.assertFals
+ self.assertNotI
+ self.assertIn(
+
+ def test_distro_
+ # The returned distro_only flag is set to True and the help texts
are
+ # formatted accordingly when the passed Juju source is "distro".
+ distro_only, distro_only_help, ppa_help =
manage.
+ 'distro')
+ self.assertTrue
+ self.assertIn(
+ self.assertNotI
+
+
class TestValidateBundle(