Merge lp:~frankban/juju-quickstart/initial-vivid-support into lp:juju-quickstart

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 114
Proposed branch: lp:~frankban/juju-quickstart/initial-vivid-support
Merge into: lp:juju-quickstart
Diff against target: 202 lines (+36/-28)
6 files modified
quickstart/__init__.py (+1/-1)
quickstart/app.py (+3/-3)
quickstart/netutils.py (+3/-3)
quickstart/settings.py (+9/-7)
quickstart/tests/test_app.py (+9/-9)
quickstart/tests/test_netutils.py (+11/-5)
To merge this branch: bzr merge lp:~frankban/juju-quickstart/initial-vivid-support
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+246199@code.launchpad.net

Description of the change

Use charm store API to retrieve GUI revision.

This branch includes the following small fixes
in preparation for the 1.6 release:

- bump version up to 1.6.0;
- use the charm store API to retrieve the URL
  of the last revision of the juju-gui charm;
- add initial support for vivid: the new series can now
  be selected as default bootstrap node series when
  creating/editing environments.

  Tests: `make check`.

  QA:
  - just run `.venv/bin/python juju-quickstart` as
    usual, locally and on a ec2 environment
    (it would be nice if both precise and trusty
    are used as default series in this QA); check
    that vivid can be added as a default-series
    in the environment edit view; check that
    the last Juju GUI revision is correctly retrieved.

https://codereview.appspot.com/197740043/

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

Reviewers: mp+246199_code.launchpad.net,

Message:
Please take a look.

Description:
Use charm store API to retrieve GUI revision.

This branch includes the following small fixes
in preparation for the 1.6 release:

- bump version up to 1.6.0;
- use the charm store API to retrieve the URL
   of the last revision of the juju-gui charm;
- add initial support for vivid: the new series can now
   be selected as default bootstrap node series when
   creating/editing environments.

   Tests: `make check`.

   QA:
   - just run `.venv/bin/python juju-quickstart` as
     usual, locally and on a ec2 environment
     (it would be nice if both precise and trusty
     are used as default series in this QA); check
     that vivid can be added as a default-series
     in the environment edit view; check that
     the last Juju GUI revision is correctly retrieved.

https://code.launchpad.net/~frankban/juju-quickstart/initial-vivid-support/+merge/246199

(do not edit description out of merge proposal)

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

Affected files (+38, -28 lines):
   A [revision details]
   M quickstart/__init__.py
   M quickstart/app.py
   M quickstart/netutils.py
   M quickstart/settings.py
   M quickstart/tests/test_app.py
   M quickstart/tests/test_netutils.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/__init__.py
=== modified file 'quickstart/__init__.py'
--- quickstart/__init__.py 2014-11-10 11:27:04 +0000
+++ quickstart/__init__.py 2015-01-12 14:30:44 +0000
@@ -45,7 +45,7 @@
  Once Juju has been installed, the command can also be run as a juju plugin,
  without the hyphen ("juju quickstart").
  """
-VERSION = (1, 5, 0)
+VERSION = (1, 6, 0)

  def get_version():

Index: quickstart/app.py
=== modified file 'quickstart/app.py'
--- quickstart/app.py 2014-12-16 14:12:44 +0000
+++ quickstart/app.py 2015-01-12 15:00:52 +0000
@@ -386,8 +386,8 @@
            unit.

      If the charm URL is not provided, and the service is not already
deployed,
- the function tries to retrieve it from the charmworld API. In this
case a
- default charm URL is used if charmworld is not available.
+ the function tries to retrieve it from the charm store API. In this
case a
+ default charm URL is used if the charm store service is not available.

      Return a tuple including the following values:
          - charm_url: the charm URL that will be used to deploy the service;
@@ -418,7 +418,7 @@
              else:
                  series = settings.JUJU_GUI_SUPPORTED_SERIES[-1]
              try:
- # Try to get the charm URL from charmworld.
+ # Try to get the charm URL from the charm store API.
                  charm_url = netutils.get_charm_url(series)
              except (IOError, ValueError) as err:
                  # Fall back to the default URL for the current series.

Index:...

Revision history for this message
Martin Hilton (martin-hilton) wrote :
Revision history for this message
Martin Hilton (martin-hilton) wrote :

On 2015/01/12 18:02:13, martin.hilton wrote:
> LGTM, No QA (yet)

QA OK

https://codereview.appspot.com/197740043/

Revision history for this message
Roger Peppe (rogpeppe) wrote :

On 2015/01/12 19:46:50, martin.hilton wrote:
> On 2015/01/12 18:02:13, martin.hilton wrote:
> > LGTM, No QA (yet)

> QA OK

LGTM

https://codereview.appspot.com/197740043/

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

*** Submitted:

Use charm store API to retrieve GUI revision.

This branch includes the following small fixes
in preparation for the 1.6 release:

- bump version up to 1.6.0;
- use the charm store API to retrieve the URL
   of the last revision of the juju-gui charm;
- add initial support for vivid: the new series can now
   be selected as default bootstrap node series when
   creating/editing environments.

   Tests: `make check`.

   QA:
   - just run `.venv/bin/python juju-quickstart` as
     usual, locally and on a ec2 environment
     (it would be nice if both precise and trusty
     are used as default series in this QA); check
     that vivid can be added as a default-series
     in the environment edit view; check that
     the last Juju GUI revision is correctly retrieved.

R=martin.hilton, rog
CC=
https://codereview.appspot.com/197740043

https://codereview.appspot.com/197740043/

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-11-10 11:27:04 +0000
3+++ quickstart/__init__.py 2015-01-12 17:54:09 +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, 5, 0)
9+VERSION = (1, 6, 0)
10
11
12 def get_version():
13
14=== modified file 'quickstart/app.py'
15--- quickstart/app.py 2014-12-16 14:12:44 +0000
16+++ quickstart/app.py 2015-01-12 17:54:09 +0000
17@@ -386,8 +386,8 @@
18 unit.
19
20 If the charm URL is not provided, and the service is not already deployed,
21- the function tries to retrieve it from the charmworld API. In this case a
22- default charm URL is used if charmworld is not available.
23+ the function tries to retrieve it from the charm store API. In this case a
24+ default charm URL is used if the charm store service is not available.
25
26 Return a tuple including the following values:
27 - charm_url: the charm URL that will be used to deploy the service;
28@@ -418,7 +418,7 @@
29 else:
30 series = settings.JUJU_GUI_SUPPORTED_SERIES[-1]
31 try:
32- # Try to get the charm URL from charmworld.
33+ # Try to get the charm URL from the charm store API.
34 charm_url = netutils.get_charm_url(series)
35 except (IOError, ValueError) as err:
36 # Fall back to the default URL for the current series.
37
38=== modified file 'quickstart/netutils.py'
39--- quickstart/netutils.py 2014-11-12 16:40:54 +0000
40+++ quickstart/netutils.py 2015-01-12 17:54:09 +0000
41@@ -69,10 +69,10 @@
42 Raise an IOError if any problems occur connecting to the API endpoint.
43 Raise a ValueError if the API returns invalid data.
44 """
45- url = settings.CHARMWORLD_API.format(
46+ url = settings.CHARMSTORE_API.format(
47 series=series, charm=settings.JUJU_GUI_CHARM_NAME)
48- charm_info = json.loads(urlread(url))
49- charm_url = charm_info.get('charm', {}).get('url')
50+ data = json.loads(urlread(url))
51+ charm_url = data.get('Id')
52 if charm_url is None:
53 raise ValueError(b'unable to find the charm URL')
54 return charm_url
55
56=== modified file 'quickstart/settings.py'
57--- quickstart/settings.py 2014-11-10 11:39:40 +0000
58+++ quickstart/settings.py 2015-01-12 17:54:09 +0000
59@@ -29,17 +29,19 @@
60 UNKNOWN_PLATFORM = object()
61 WINDOWS = object()
62
63-# The base charmworld API URL containing information about charms.
64+# The base charm store API URL containing information about charms.
65 # This URL must be formatted with a series and a charm name.
66-CHARMWORLD_API = 'http://manage.jujucharms.com/api/3/charm/{series}/{charm}'
67+CHARMSTORE_API = (
68+ 'https://api.jujucharms.com'
69+ '/charmstore/v4/{series}/{charm}/meta/id')
70
71 # The default Juju GUI charm URLs for each supported series. Used when it is
72-# not possible to retrieve the charm URL from the charmworld API, e.g. due to
73-# temporary connection/charmworld errors.
74+# not possible to retrieve the charm URL from the charm store API, e.g. due to
75+# temporary connection/charm store errors.
76 # Keep this list sorted by release date (older first).
77 DEFAULT_CHARM_URLS = collections.OrderedDict((
78- ('precise', 'cs:precise/juju-gui-97'),
79- ('trusty', 'cs:trusty/juju-gui-9'),
80+ ('precise', 'cs:precise/juju-gui-104'),
81+ ('trusty', 'cs:trusty/juju-gui-16'),
82 ))
83
84 # The quickstart app short description.
85@@ -62,7 +64,7 @@
86
87 # The possible values for the environments.yaml default-series field.
88 JUJU_DEFAULT_SERIES = (
89- 'precise', 'quantal', 'raring', 'saucy', 'trusty', 'utopic')
90+ 'precise', 'quantal', 'raring', 'saucy', 'trusty', 'utopic', 'vivid')
91
92 # Retrieve the current juju-core home.
93 JUJU_HOME = os.getenv('JUJU_HOME', '~/.juju')
94
95=== modified file 'quickstart/tests/test_app.py'
96--- quickstart/tests/test_app.py 2014-12-16 14:12:44 +0000
97+++ quickstart/tests/test_app.py 2015-01-12 17:54:09 +0000
98@@ -922,8 +922,8 @@
99 check_preexisting)
100 # There is no need to call status if the environment was just created.
101 self.assertFalse(env.get_status.called)
102- # The charm URL has been retrieved from charmworld based on the current
103- # bootstrap node series.
104+ # The charm URL has been retrieved from the charm store API based on
105+ # the current bootstrap node series.
106 self.assertEqual('cs:trusty/juju-gui-42', url)
107 mock_get_charm_url.assert_called_once_with(bootstrap_node_series)
108 # Since the bootstrap node series is supported by the GUI charm, the
109@@ -957,8 +957,8 @@
110 check_preexisting)
111 # The environment status has been retrieved.
112 env.get_status.assert_called_once_with()
113- # The charm URL has been retrieved from charmworld based on the current
114- # bootstrap node series.
115+ # The charm URL has been retrieved from the charm store API based on
116+ # the current bootstrap node series.
117 self.assertEqual('cs:precise/juju-gui-42', url)
118 mock_get_charm_url.assert_called_once_with(bootstrap_node_series)
119 # Since the bootstrap node series is supported by the GUI charm, the
120@@ -1012,8 +1012,8 @@
121 url, machine, service_data, unit_data = app.check_environment(
122 env, 'my-gui', charm_url, env_type, bootstrap_node_series,
123 check_preexisting)
124- # The charm URL has been retrieved from charmworld using the most
125- # recent supported series.
126+ # The charm URL has been retrieved from the charm store API using the
127+ # most recent supported series.
128 self.assertEqual('cs:trusty/juju-gui-42', url)
129 mock_get_charm_url.assert_called_once_with('trusty')
130 # The Juju GUI unit cannot be deployed to saucy machine 0.
131@@ -1037,7 +1037,7 @@
132 url, machine, service_data, unit_data = app.check_environment(
133 env, 'my-gui', charm_url, env_type, bootstrap_node_series,
134 check_preexisting)
135- # The charm URL has been correctly retrieved from charmworld.
136+ # The charm URL has been correctly retrieved from the charm store API.
137 self.assertEqual('cs:trusty/juju-gui-42', url)
138 # The Juju GUI unit cannot be deployed to localhost.
139 self.assertIsNone(machine)
140@@ -1058,7 +1058,7 @@
141
142 def test_default_charm_url(self, mock_print):
143 # A default charm URL suitable to be deployed in the bootstrap node is
144- # returned if the charmworld API is not reachable.
145+ # returned if the charm store API is not reachable.
146 env = self.make_env()
147 charm_url = None
148 env_type = 'ec2'
149@@ -1074,7 +1074,7 @@
150
151 def test_most_recent_default_charm_url(self, mock_print):
152 # The default charm URL corresponding to the most recent series
153- # supported by the GUI is returned if the charmworld API is not
154+ # supported by the GUI is returned if the charm store API is not
155 # reachable and the bootstrap node cannot host the Juju GUI unit.
156 env = self.make_env()
157 charm_url = None
158
159=== modified file 'quickstart/tests/test_netutils.py'
160--- quickstart/tests/test_netutils.py 2014-11-12 16:40:54 +0000
161+++ quickstart/tests/test_netutils.py 2015-01-12 17:54:09 +0000
162@@ -107,12 +107,17 @@
163
164 def test_charm_url(self):
165 # The Juju GUI charm URL is correctly returned.
166- contents = json.dumps({'charm': {'url': 'cs:trusty/juju-gui-42'}})
167+ contents = json.dumps({
168+ 'Id': 'cs:trusty/juju-gui-42',
169+ 'Series': 'trusty',
170+ 'Name': 'juju-gui',
171+ 'Revision': 42,
172+ })
173 with self.patch_urlread(contents=contents) as mock_urlread:
174 charm_url = netutils.get_charm_url('trusty')
175 self.assertEqual('cs:trusty/juju-gui-42', charm_url)
176 mock_urlread.assert_called_once_with(
177- 'http://manage.jujucharms.com/api/3/charm/trusty/juju-gui')
178+ 'https://api.jujucharms.com/charmstore/v4/trusty/juju-gui/meta/id')
179
180 def test_io_error(self):
181 # IOErrors are properly propagated.
182@@ -120,17 +125,18 @@
183 with self.assertRaises(IOError) as context_manager:
184 netutils.get_charm_url('precise')
185 mock_urlread.assert_called_once_with(
186- 'http://manage.jujucharms.com/api/3/charm/precise/juju-gui')
187+ 'https://api.jujucharms.com/charmstore/v4/precise/juju-gui/meta/id'
188+ )
189 self.assertEqual('bad wolf', bytes(context_manager.exception))
190
191 def test_value_error(self):
192 # A ValueError is raised if the API response is not valid.
193- contents = json.dumps({'charm': {}})
194+ contents = json.dumps({'invalid': {}})
195 with self.patch_urlread(contents=contents) as mock_urlread:
196 with self.assertRaises(ValueError) as context_manager:
197 netutils.get_charm_url('trusty')
198 mock_urlread.assert_called_once_with(
199- 'http://manage.jujucharms.com/api/3/charm/trusty/juju-gui')
200+ 'https://api.jujucharms.com/charmstore/v4/trusty/juju-gui/meta/id')
201 self.assertEqual(
202 'unable to find the charm URL', bytes(context_manager.exception))
203

Subscribers

People subscribed via source and target branches