Merge lp:~evarlast/juju-quickstart/upload-tools-constraints into lp:juju-quickstart

Proposed by Jay R. Wren
Status: Merged
Merged at revision: 91
Proposed branch: lp:~evarlast/juju-quickstart/upload-tools-constraints
Merge into: lp:juju-quickstart
Diff against target: 202 lines (+91/-10)
4 files modified
quickstart/app.py (+10/-1)
quickstart/manage.py (+24/-3)
quickstart/tests/test_app.py (+36/-0)
quickstart/tests/test_manage.py (+21/-6)
To merge this branch: bzr merge lp:~evarlast/juju-quickstart/upload-tools-constraints
Reviewer Review Type Date Requested Status
Francesco Banconi Approve
Review via email: mp+227229@code.launchpad.net

Description of the change

support upload-tools and upload-series

support pass through of --upload-tools --upload-series and --constraints from quickstart to bootstrap

https://bugs.launchpad.net/juju-quickstart/+bug/1274584

https://codereview.appspot.com/132760043/

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

Nice branch Jay, it looks good with some changes I described below.
Thank you!

91. By Jay R. Wren

addressing review concerns

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

LGTM with minor changes, thank you!

review: Approve
92. By Jay R. Wren

semicolons and periods in comments

Revision history for this message
Jay R. Wren (evarlast) wrote :

Reviewers: mp+227229_code.launchpad.net,

Message:
Please take a look.

Description:
support upload-tools and upload-series

support pass through of --upload-tools --upload-series and --constraints
from quickstart to bootstrap

https://bugs.launchpad.net/juju-quickstart/+bug/1274584

https://code.launchpad.net/~evarlast/juju-quickstart/upload-tools-constraints/+merge/227229

(do not edit description out of merge proposal)

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

Affected files (+93, -10 lines):
   A [revision details]
   M quickstart/app.py
   M quickstart/manage.py
   M quickstart/tests/test_app.py
   M quickstart/tests/test_manage.py

Revision history for this message
Jay R. Wren (evarlast) wrote :

*** Submitted:

support upload-tools and upload-series

support pass through of --upload-tools --upload-series and --constraints
from quickstart to bootstrap

https://bugs.launchpad.net/juju-quickstart/+bug/1274584

R=
CC=
https://codereview.appspot.com/132760043

https://codereview.appspot.com/132760043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quickstart/app.py'
2--- quickstart/app.py 2014-07-04 07:49:03 +0000
3+++ quickstart/app.py 2014-08-21 13:36:56 +0000
4@@ -163,7 +163,8 @@
5 raise ProgramExit(bytes(err))
6
7
8-def bootstrap(env_name, juju_command, requires_sudo=False, debug=False):
9+def bootstrap(env_name, juju_command, requires_sudo=False, debug=False,
10+ upload_tools=False, upload_series=None, constraints=None):
11 """Bootstrap the Juju environment with the given name.
12
13 Do not bootstrap the environment if already bootstrapped.
14@@ -188,6 +189,14 @@
15 cmd.insert(0, 'sudo')
16 if debug:
17 cmd.append('--debug')
18+ if upload_tools:
19+ cmd.append('--upload-tools')
20+ if upload_series is not None:
21+ cmd.append('--upload-series')
22+ cmd.append(upload_series)
23+ if constraints is not None:
24+ cmd.append('--constraints')
25+ cmd.append(constraints)
26 retcode, _, error = utils.call(*cmd)
27 if retcode:
28 # XXX frankban 2013-11-13 bug 1252322: the check below is weak. We are
29
30=== modified file 'quickstart/manage.py'
31--- quickstart/manage.py 2014-06-13 15:19:46 +0000
32+++ quickstart/manage.py 2014-08-21 13:36:56 +0000
33@@ -353,8 +353,12 @@
34 - env_name: the name of the Juju environment to use;
35 - env_type: the provider type of the selected Juju environment;
36 - interactive: whether to start the interactive session;
37- - open_browser: whether the GUI browser must be opened.
38- - platform: The host platform.
39+ - open_browser: whether the GUI browser must be opened;
40+ - platform: The host platform;
41+ - upload_tools: whether to upload local version of tools;
42+ - upload_series: the comma-separated series list for which tools will
43+ be uploaded, or None if not set;
44+ - constraints: the environment constrains or None if not set.
45
46 The following attributes will also be included in the namespace if a bundle
47 deployment is requested:
48@@ -450,6 +454,20 @@
49 parser.add_argument(
50 '--description', action=_DescriptionAction, default=argparse.SUPPRESS,
51 nargs=0, help="Show program's description and exit")
52+ # These options are passed to juju bootstrap.
53+ parser.add_argument(
54+ '--upload-tools', action='store_true',
55+ help='upload local version of tools before bootstrapping')
56+ parser.add_argument(
57+ '--upload-series',
58+ help='upload tools for supplied comma-separated series list')
59+ parser.add_argument(
60+ '--constraints',
61+ help='If constraints are specified in the bootstrap command,\n'
62+ 'they will apply to the machine provisioned for the juju state\n'
63+ 'server. They will also be set as default constraints on the\n'
64+ 'environment for all future machines, exactly as if the\n'
65+ 'constraints were set with juju set-constraints.\n')
66 # Parse the provided arguments.
67 options = parser.parse_args()
68
69@@ -500,7 +518,10 @@
70
71 already_bootstrapped, bootstrap_node_series = app.bootstrap(
72 options.env_name, juju_command,
73- requires_sudo=requires_sudo, debug=options.debug)
74+ requires_sudo=requires_sudo, debug=options.debug,
75+ upload_tools=options.upload_tools,
76+ upload_series=options.upload_series,
77+ constraints=options.constraints)
78
79 # Retrieve the admin-secret for the current environment.
80 try:
81
82=== modified file 'quickstart/tests/test_app.py'
83--- quickstart/tests/test_app.py 2014-07-04 13:09:11 +0000
84+++ quickstart/tests/test_app.py 2014-08-21 13:36:56 +0000
85@@ -510,6 +510,42 @@
86 '--debug'),
87 ] + self.make_status_calls(1))
88
89+ def test_success_upload_tools(self, mock_print):
90+ # The environment is bootstrapped with local tools.
91+ with self.patch_multiple_calls(self.make_side_effects()) as mock_call:
92+ already_bootstrapped, series = app.bootstrap(
93+ self.env_name, self.juju_command, upload_tools=True)
94+ self.assertFalse(already_bootstrapped)
95+ mock_call.assert_has_calls([
96+ mock.call(
97+ self.juju_command, 'bootstrap', '-e', self.env_name,
98+ '--upload-tools'),
99+ ] + self.make_status_calls(1))
100+
101+ def test_success_upload_series(self, mock_print):
102+ # The environment is bootstrapped with tools for specific series.
103+ with self.patch_multiple_calls(self.make_side_effects()) as mock_call:
104+ already_bootstrapped, series = app.bootstrap(
105+ self.env_name, self.juju_command, upload_series='hoary')
106+ self.assertFalse(already_bootstrapped)
107+ mock_call.assert_has_calls([
108+ mock.call(
109+ self.juju_command, 'bootstrap', '-e', self.env_name,
110+ '--upload-series', 'hoary'),
111+ ] + self.make_status_calls(1))
112+
113+ def test_success_constraints(self, mock_print):
114+ # The environment is bootstrapped with given constraints.
115+ with self.patch_multiple_calls(self.make_side_effects()) as mock_call:
116+ already_bootstrapped, series = app.bootstrap(
117+ self.env_name, self.juju_command, constraints='mem=7G')
118+ self.assertFalse(already_bootstrapped)
119+ mock_call.assert_has_calls([
120+ mock.call(
121+ self.juju_command, 'bootstrap', '-e', self.env_name,
122+ '--constraints', 'mem=7G'),
123+ ] + self.make_status_calls(1))
124+
125 def test_already_bootstrapped(self, mock_print):
126 # The function succeeds and returns True if the environment is already
127 # bootstrapped.
128
129=== modified file 'quickstart/tests/test_manage.py'
130--- quickstart/tests/test_manage.py 2014-06-13 15:19:46 +0000
131+++ quickstart/tests/test_manage.py 2014-08-21 13:36:56 +0000
132@@ -660,9 +660,10 @@
133 with mock.patch('sys.argv', ['juju-quickstart'] + args):
134 with mock.patch('sys.exit') as mock_exit:
135 with self.patch_get_default_env_name(env_name):
136- manage.setup()
137+ options = manage.setup()
138 if exit_called:
139 mock_exit.assert_called_once_with(0)
140+ return options
141
142 def test_help(self):
143 # The program help message is properly formatted.
144@@ -735,7 +736,12 @@
145 # Logging is properly set up at the debug level.
146 logger = logging.getLogger()
147 self.call_setup(['--debug'], 'ec2', exit_called=False)
148- self.assertEqual(logging.DEBUG, logger.level)
149+ self.assertTrue(logging.DEBUG, logger.level)
150+
151+ def test_upload_tools(self):
152+ # Upload tools is properly set up.
153+ options = self.call_setup(['--upload-tools'], exit_called=False)
154+ self.assertTrue(options.upload_tools)
155
156
157 @mock.patch('webbrowser.open')
158@@ -797,7 +803,9 @@
159 mock_app.ensure_ssh_keys.assert_called()
160 mock_app.bootstrap.assert_called_once_with(
161 options.env_name, self.juju_command, requires_sudo=False,
162- debug=options.debug)
163+ debug=options.debug, upload_tools=options.upload_tools,
164+ upload_series=options.upload_series,
165+ constraints=options.constraints)
166 mock_app.get_api_url.assert_called_once_with(
167 options.env_name, self.juju_command)
168 mock_app.connect.assert_has_calls([
169@@ -878,7 +886,9 @@
170 manage.run(options)
171 mock_app.bootstrap.assert_called_once_with(
172 options.env_name, self.juju_command, requires_sudo=False,
173- debug=options.debug)
174+ debug=options.debug, upload_tools=options.upload_tools,
175+ upload_series=options.upload_series,
176+ constraints=options.constraints)
177 mock_app.bootstrap.reset_mock()
178
179 def test_local_provider_requiring_sudo(self, mock_app, mock_open):
180@@ -902,7 +912,9 @@
181 manage.run(options)
182 mock_app.bootstrap.assert_called_once_with(
183 options.env_name, self.juju_command, requires_sudo=True,
184- debug=options.debug)
185+ debug=options.debug, upload_tools=options.upload_tools,
186+ upload_series=options.upload_series,
187+ constraints=options.constraints)
188 mock_app.bootstrap.reset_mock()
189
190 def test_no_local_no_sudo(self, mock_app, mock_open):
191@@ -921,7 +933,10 @@
192 manage.run(options)
193 mock_app.bootstrap.assert_called_once_with(
194 options.env_name, self.juju_command,
195- requires_sudo=False, debug=options.debug)
196+ requires_sudo=False,
197+ debug=options.debug, upload_tools=options.upload_tools,
198+ upload_series=options.upload_series,
199+ constraints=options.constraints)
200
201 def test_no_browser(self, mock_app, mock_open):
202 # It is possible to avoid opening the GUI in the browser.

Subscribers

People subscribed via source and target branches

to all changes: