Merge lp:~frankban/juju-quickstart/distro-only-flag into lp:juju-quickstart

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 61
Proposed branch: lp:~frankban/juju-quickstart/distro-only-flag
Merge into: lp:juju-quickstart
Diff against target: 172 lines (+66/-12)
4 files modified
quickstart/__init__.py (+1/-1)
quickstart/app.py (+13/-7)
quickstart/manage.py (+5/-1)
quickstart/tests/test_app.py (+47/-3)
To merge this branch: bzr merge lp:~frankban/juju-quickstart/distro-only-flag
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+213021@code.launchpad.net

Description of the change

Add the distro-only flag.

This can be used (e.g. in trusty) to
prevent quickstart from installing
the Juju stable PPA.

Tests: `make check`.

No QA required, I already tested this on
a trusty VM.

https://codereview.appspot.com/81400043/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

LGTM thanks for the quick update.

https://codereview.appspot.com/81400043/

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

*** Submitted:

Add the distro-only flag.

This can be used (e.g. in trusty) to
prevent quickstart from installing
the Juju stable PPA.

Tests: `make check`.

No QA required, I already tested this on
a trusty VM.

R=rharding
CC=
https://codereview.appspot.com/81400043

https://codereview.appspot.com/81400043/

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

Hi Rick, thanks for the review!

https://codereview.appspot.com/81400043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'quickstart/__init__.py'
--- quickstart/__init__.py 2014-03-14 16:50:22 +0000
+++ quickstart/__init__.py 2014-03-27 11:09:37 +0000
@@ -45,7 +45,7 @@
45Once Juju has been installed, the command can also be run as a juju plugin,45Once Juju has been installed, the command can also be run as a juju plugin,
46without the hyphen ("juju quickstart").46without the hyphen ("juju quickstart").
47"""47"""
48VERSION = (1, 2, 0)48VERSION = (1, 3, 0)
4949
5050
51def get_version():51def get_version():
5252
=== modified file 'quickstart/app.py'
--- quickstart/app.py 2014-03-11 12:47:44 +0000
+++ quickstart/app.py 2014-03-27 11:09:37 +0000
@@ -57,11 +57,16 @@
57 return b'juju-quickstart: error: {}'.format(self.message)57 return b'juju-quickstart: error: {}'.format(self.message)
5858
5959
60def ensure_dependencies():60def ensure_dependencies(distro_only):
61 """Ensure that Juju and LXC are installed.61 """Ensure that Juju and LXC are installed.
6262
63 If juju is not found in the PATH, then add the juju stable PPA and install63 If the "juju" command is not found in the PATH, then install and setup
64 both juju and lxc.64 Juju, including the packages required to bootstrap local environments.
65 This is usually done by adding the Juju stable PPA and installing the
66 juju-core and juju-local packages.
67
68 If distro_only is True, the above PPA is not added to the apt sources, and
69 we assume Juju packages are already available in the distro repository.
6570
66 Return the Juju version tuple when Juju is available.71 Return the Juju version tuple when Juju is available.
6772
@@ -87,10 +92,11 @@
87 # All those packages are installed as juju-local dependencies.92 # All those packages are installed as juju-local dependencies.
88 required_packages.append('juju-local')93 required_packages.append('juju-local')
89 if required_packages:94 if required_packages:
90 try:95 if not distro_only:
91 utils.add_apt_repository('ppa:juju/stable')96 try:
92 except OSError as err:97 utils.add_apt_repository('ppa:juju/stable')
93 raise ProgramExit(bytes(err))98 except OSError as err:
99 raise ProgramExit(bytes(err))
94 print('sudo privileges will be used for the installation of \n'100 print('sudo privileges will be used for the installation of \n'
95 'the following packages: {}\n'101 'the following packages: {}\n'
96 'this can take a while...'.format(', '.join(required_packages)))102 'this can take a while...'.format(', '.join(required_packages)))
97103
=== modified file 'quickstart/manage.py'
--- quickstart/manage.py 2014-03-14 16:50:22 +0000
+++ quickstart/manage.py 2014-03-27 11:09:37 +0000
@@ -299,6 +299,7 @@
299 - bundle: the optional bundle (path or URL) to be deployed;299 - bundle: the optional bundle (path or URL) to be deployed;
300 - charm_url: the Juju GUI charm URL or None if not specified;300 - charm_url: the Juju GUI charm URL or None if not specified;
301 - debug: whether debug mode is activated;301 - debug: whether debug mode is activated;
302 - distro_only: install Juju only using the distribution packages;
302 - env_file: the absolute path of the Juju environments.yaml file;303 - env_file: the absolute path of the Juju environments.yaml file;
303 - env_name: the name of the Juju environment to use;304 - env_name: the name of the Juju environment to use;
304 - env_type: the provider type of the selected Juju environment;305 - env_type: the provider type of the selected Juju environment;
@@ -375,6 +376,9 @@
375 '--no-browser', action='store_false', dest='open_browser',376 '--no-browser', action='store_false', dest='open_browser',
376 help='Avoid opening the browser to the GUI at the end of the\nprocess')377 help='Avoid opening the browser to the GUI at the end of the\nprocess')
377 parser.add_argument(378 parser.add_argument(
379 '--distro-only', action='store_true', dest='distro_only',
380 help='Do not use external sources when installing and setting up Juju')
381 parser.add_argument(
378 '--version', action='version', version='%(prog)s {}'.format(version))382 '--version', action='version', version='%(prog)s {}'.format(version))
379 parser.add_argument(383 parser.add_argument(
380 '--debug', action='store_true',384 '--debug', action='store_true',
@@ -408,7 +412,7 @@
408 options.bundle_name, len(options.bundle_services)))412 options.bundle_name, len(options.bundle_services)))
409413
410 logging.debug('ensuring juju and lxc are installed')414 logging.debug('ensuring juju and lxc are installed')
411 juju_version = app.ensure_dependencies()415 juju_version = app.ensure_dependencies(options.distro_only)
412416
413 logging.debug('ensuring SSH keys are available')417 logging.debug('ensuring SSH keys are available')
414 app.ensure_ssh_keys()418 app.ensure_ssh_keys()
415419
=== modified file 'quickstart/tests/test_app.py'
--- quickstart/tests/test_app.py 2014-03-11 12:47:44 +0000
+++ quickstart/tests/test_app.py 2014-03-27 11:09:37 +0000
@@ -67,7 +67,7 @@
67 add_repository = '/usr/bin/add-apt-repository'67 add_repository = '/usr/bin/add-apt-repository'
68 apt_get = '/usr/bin/apt-get'68 apt_get = '/usr/bin/apt-get'
6969
70 def call_ensure_dependencies(self, call_effects):70 def call_ensure_dependencies(self, call_effects, distro_only=False):
71 """Execute the quickstart.app.ensure_dependencies call.71 """Execute the quickstart.app.ensure_dependencies call.
7272
73 The call_effects argument is used to customize the values returned by73 The call_effects argument is used to customize the values returned by
@@ -76,7 +76,7 @@
76 Return the mock call object and the ensure_dependencies return value.76 Return the mock call object and the ensure_dependencies return value.
77 """77 """
78 with self.patch_multiple_calls(call_effects) as mock_call:78 with self.patch_multiple_calls(call_effects) as mock_call:
79 juju_version = app.ensure_dependencies()79 juju_version = app.ensure_dependencies(distro_only)
80 return mock_call, juju_version80 return mock_call, juju_version
8181
82 def test_success_install(self, mock_print):82 def test_success_install(self, mock_print):
@@ -112,6 +112,28 @@
112 ])112 ])
113 self.assertEqual((1, 18, 0), juju_version)113 self.assertEqual((1, 18, 0), juju_version)
114114
115 def test_distro_only_install(self, mock_print):
116 # All the missing packages are installed from the distro repository.
117 side_effects = (
118 (127, '', 'no juju'), # Retrieve the Juju version.
119 (0, 'install', ''), # Install missing packages.
120 (0, '1.17.42', ''), # Retrieve the version again.
121 )
122 mock_call, juju_version = self.call_ensure_dependencies(
123 side_effects, distro_only=True)
124 self.assertEqual(len(side_effects), mock_call.call_count)
125 mock_call.assert_has_calls([
126 mock.call(settings.JUJU_CMD, 'version'),
127 mock.call('sudo', self.apt_get, 'install', '-y',
128 'juju-core', 'juju-local'),
129 mock.call(settings.JUJU_CMD, 'version'),
130 ])
131 mock_print.assert_called_once_with(
132 'sudo privileges will be used for the installation of \n'
133 'the following packages: juju-core, juju-local\n'
134 'this can take a while...')
135 self.assertEqual((1, 17, 42), juju_version)
136
115 def test_success_no_install(self, mock_print):137 def test_success_no_install(self, mock_print):
116 # There is no need to install packages/PPAs if everything is already138 # There is no need to install packages/PPAs if everything is already
117 # set up.139 # set up.
@@ -158,6 +180,28 @@
158 ])180 ])
159 self.assertEqual((1, 16, 42), juju_version)181 self.assertEqual((1, 16, 42), juju_version)
160182
183 def test_distro_only_partial_install(self, mock_print):
184 # One missing installation is correctly handled when using distro only
185 # packages.
186 side_effects = (
187 (0, '1.16.42', ''), # Check the juju command.
188 (127, '', 'no lxc'), # Check the lxc-ls command.
189 (0, 'install', ''), # Install missing packages.
190 )
191 mock_call, juju_version = self.call_ensure_dependencies(
192 side_effects, distro_only=True)
193 self.assertEqual(len(side_effects), mock_call.call_count)
194 mock_call.assert_has_calls([
195 mock.call(settings.JUJU_CMD, 'version'),
196 mock.call('/usr/bin/lxc-ls'),
197 mock.call('sudo', self.apt_get, 'install', '-y', 'juju-local'),
198 ])
199 mock_print.assert_called_once_with(
200 'sudo privileges will be used for the installation of \n'
201 'the following packages: juju-local\n'
202 'this can take a while...')
203 self.assertEqual((1, 16, 42), juju_version)
204
161 def test_add_repository_failure(self, mock_print):205 def test_add_repository_failure(self, mock_print):
162 # A ProgramExit is raised if the PPA is not successfully installed.206 # A ProgramExit is raised if the PPA is not successfully installed.
163 side_effects = (207 side_effects = (
@@ -696,7 +740,7 @@
696 # Set up the add_unit return value.740 # Set up the add_unit return value.
697 if unit_name is not None:741 if unit_name is not None:
698 env.add_unit.return_value = {'Units': [unit_name]}742 env.add_unit.return_value = {'Units': [unit_name]}
699 #Set up the get_status return value.743 # Set up the get_status return value.
700 status = []744 status = []
701 if service_data is not None:745 if service_data is not None:
702 status.append(self.make_service_change(data=service_data))746 status.append(self.make_service_change(data=service_data))

Subscribers

People subscribed via source and target branches