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
=== modified file 'quickstart/__init__.py'
--- quickstart/__init__.py 2014-11-10 11:27:04 +0000
+++ quickstart/__init__.py 2015-01-12 17:54:09 +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, 5, 0)48VERSION = (1, 6, 0)
4949
5050
51def get_version():51def get_version():
5252
=== modified file 'quickstart/app.py'
--- quickstart/app.py 2014-12-16 14:12:44 +0000
+++ quickstart/app.py 2015-01-12 17:54:09 +0000
@@ -386,8 +386,8 @@
386 unit.386 unit.
387387
388 If the charm URL is not provided, and the service is not already deployed,388 If the charm URL is not provided, and the service is not already deployed,
389 the function tries to retrieve it from the charmworld API. In this case a389 the function tries to retrieve it from the charm store API. In this case a
390 default charm URL is used if charmworld is not available.390 default charm URL is used if the charm store service is not available.
391391
392 Return a tuple including the following values:392 Return a tuple including the following values:
393 - charm_url: the charm URL that will be used to deploy the service;393 - charm_url: the charm URL that will be used to deploy the service;
@@ -418,7 +418,7 @@
418 else:418 else:
419 series = settings.JUJU_GUI_SUPPORTED_SERIES[-1]419 series = settings.JUJU_GUI_SUPPORTED_SERIES[-1]
420 try:420 try:
421 # Try to get the charm URL from charmworld.421 # Try to get the charm URL from the charm store API.
422 charm_url = netutils.get_charm_url(series)422 charm_url = netutils.get_charm_url(series)
423 except (IOError, ValueError) as err:423 except (IOError, ValueError) as err:
424 # Fall back to the default URL for the current series.424 # Fall back to the default URL for the current series.
425425
=== modified file 'quickstart/netutils.py'
--- quickstart/netutils.py 2014-11-12 16:40:54 +0000
+++ quickstart/netutils.py 2015-01-12 17:54:09 +0000
@@ -69,10 +69,10 @@
69 Raise an IOError if any problems occur connecting to the API endpoint.69 Raise an IOError if any problems occur connecting to the API endpoint.
70 Raise a ValueError if the API returns invalid data.70 Raise a ValueError if the API returns invalid data.
71 """71 """
72 url = settings.CHARMWORLD_API.format(72 url = settings.CHARMSTORE_API.format(
73 series=series, charm=settings.JUJU_GUI_CHARM_NAME)73 series=series, charm=settings.JUJU_GUI_CHARM_NAME)
74 charm_info = json.loads(urlread(url))74 data = json.loads(urlread(url))
75 charm_url = charm_info.get('charm', {}).get('url')75 charm_url = data.get('Id')
76 if charm_url is None:76 if charm_url is None:
77 raise ValueError(b'unable to find the charm URL')77 raise ValueError(b'unable to find the charm URL')
78 return charm_url78 return charm_url
7979
=== modified file 'quickstart/settings.py'
--- quickstart/settings.py 2014-11-10 11:39:40 +0000
+++ quickstart/settings.py 2015-01-12 17:54:09 +0000
@@ -29,17 +29,19 @@
29UNKNOWN_PLATFORM = object()29UNKNOWN_PLATFORM = object()
30WINDOWS = object()30WINDOWS = object()
3131
32# The base charmworld API URL containing information about charms.32# The base charm store API URL containing information about charms.
33# This URL must be formatted with a series and a charm name.33# This URL must be formatted with a series and a charm name.
34CHARMWORLD_API = 'http://manage.jujucharms.com/api/3/charm/{series}/{charm}'34CHARMSTORE_API = (
35 'https://api.jujucharms.com'
36 '/charmstore/v4/{series}/{charm}/meta/id')
3537
36# The default Juju GUI charm URLs for each supported series. Used when it is38# The default Juju GUI charm URLs for each supported series. Used when it is
37# not possible to retrieve the charm URL from the charmworld API, e.g. due to39# not possible to retrieve the charm URL from the charm store API, e.g. due to
38# temporary connection/charmworld errors.40# temporary connection/charm store errors.
39# Keep this list sorted by release date (older first).41# Keep this list sorted by release date (older first).
40DEFAULT_CHARM_URLS = collections.OrderedDict((42DEFAULT_CHARM_URLS = collections.OrderedDict((
41 ('precise', 'cs:precise/juju-gui-97'),43 ('precise', 'cs:precise/juju-gui-104'),
42 ('trusty', 'cs:trusty/juju-gui-9'),44 ('trusty', 'cs:trusty/juju-gui-16'),
43))45))
4446
45# The quickstart app short description.47# The quickstart app short description.
@@ -62,7 +64,7 @@
6264
63# The possible values for the environments.yaml default-series field.65# The possible values for the environments.yaml default-series field.
64JUJU_DEFAULT_SERIES = (66JUJU_DEFAULT_SERIES = (
65 'precise', 'quantal', 'raring', 'saucy', 'trusty', 'utopic')67 'precise', 'quantal', 'raring', 'saucy', 'trusty', 'utopic', 'vivid')
6668
67# Retrieve the current juju-core home.69# Retrieve the current juju-core home.
68JUJU_HOME = os.getenv('JUJU_HOME', '~/.juju')70JUJU_HOME = os.getenv('JUJU_HOME', '~/.juju')
6971
=== modified file 'quickstart/tests/test_app.py'
--- quickstart/tests/test_app.py 2014-12-16 14:12:44 +0000
+++ quickstart/tests/test_app.py 2015-01-12 17:54:09 +0000
@@ -922,8 +922,8 @@
922 check_preexisting)922 check_preexisting)
923 # There is no need to call status if the environment was just created.923 # There is no need to call status if the environment was just created.
924 self.assertFalse(env.get_status.called)924 self.assertFalse(env.get_status.called)
925 # The charm URL has been retrieved from charmworld based on the current925 # The charm URL has been retrieved from the charm store API based on
926 # bootstrap node series.926 # the current bootstrap node series.
927 self.assertEqual('cs:trusty/juju-gui-42', url)927 self.assertEqual('cs:trusty/juju-gui-42', url)
928 mock_get_charm_url.assert_called_once_with(bootstrap_node_series)928 mock_get_charm_url.assert_called_once_with(bootstrap_node_series)
929 # Since the bootstrap node series is supported by the GUI charm, the929 # Since the bootstrap node series is supported by the GUI charm, the
@@ -957,8 +957,8 @@
957 check_preexisting)957 check_preexisting)
958 # The environment status has been retrieved.958 # The environment status has been retrieved.
959 env.get_status.assert_called_once_with()959 env.get_status.assert_called_once_with()
960 # The charm URL has been retrieved from charmworld based on the current960 # The charm URL has been retrieved from the charm store API based on
961 # bootstrap node series.961 # the current bootstrap node series.
962 self.assertEqual('cs:precise/juju-gui-42', url)962 self.assertEqual('cs:precise/juju-gui-42', url)
963 mock_get_charm_url.assert_called_once_with(bootstrap_node_series)963 mock_get_charm_url.assert_called_once_with(bootstrap_node_series)
964 # Since the bootstrap node series is supported by the GUI charm, the964 # Since the bootstrap node series is supported by the GUI charm, the
@@ -1012,8 +1012,8 @@
1012 url, machine, service_data, unit_data = app.check_environment(1012 url, machine, service_data, unit_data = app.check_environment(
1013 env, 'my-gui', charm_url, env_type, bootstrap_node_series,1013 env, 'my-gui', charm_url, env_type, bootstrap_node_series,
1014 check_preexisting)1014 check_preexisting)
1015 # The charm URL has been retrieved from charmworld using the most1015 # The charm URL has been retrieved from the charm store API using the
1016 # recent supported series.1016 # most recent supported series.
1017 self.assertEqual('cs:trusty/juju-gui-42', url)1017 self.assertEqual('cs:trusty/juju-gui-42', url)
1018 mock_get_charm_url.assert_called_once_with('trusty')1018 mock_get_charm_url.assert_called_once_with('trusty')
1019 # The Juju GUI unit cannot be deployed to saucy machine 0.1019 # The Juju GUI unit cannot be deployed to saucy machine 0.
@@ -1037,7 +1037,7 @@
1037 url, machine, service_data, unit_data = app.check_environment(1037 url, machine, service_data, unit_data = app.check_environment(
1038 env, 'my-gui', charm_url, env_type, bootstrap_node_series,1038 env, 'my-gui', charm_url, env_type, bootstrap_node_series,
1039 check_preexisting)1039 check_preexisting)
1040 # The charm URL has been correctly retrieved from charmworld.1040 # The charm URL has been correctly retrieved from the charm store API.
1041 self.assertEqual('cs:trusty/juju-gui-42', url)1041 self.assertEqual('cs:trusty/juju-gui-42', url)
1042 # The Juju GUI unit cannot be deployed to localhost.1042 # The Juju GUI unit cannot be deployed to localhost.
1043 self.assertIsNone(machine)1043 self.assertIsNone(machine)
@@ -1058,7 +1058,7 @@
10581058
1059 def test_default_charm_url(self, mock_print):1059 def test_default_charm_url(self, mock_print):
1060 # A default charm URL suitable to be deployed in the bootstrap node is1060 # A default charm URL suitable to be deployed in the bootstrap node is
1061 # returned if the charmworld API is not reachable.1061 # returned if the charm store API is not reachable.
1062 env = self.make_env()1062 env = self.make_env()
1063 charm_url = None1063 charm_url = None
1064 env_type = 'ec2'1064 env_type = 'ec2'
@@ -1074,7 +1074,7 @@
10741074
1075 def test_most_recent_default_charm_url(self, mock_print):1075 def test_most_recent_default_charm_url(self, mock_print):
1076 # The default charm URL corresponding to the most recent series1076 # The default charm URL corresponding to the most recent series
1077 # supported by the GUI is returned if the charmworld API is not1077 # supported by the GUI is returned if the charm store API is not
1078 # reachable and the bootstrap node cannot host the Juju GUI unit.1078 # reachable and the bootstrap node cannot host the Juju GUI unit.
1079 env = self.make_env()1079 env = self.make_env()
1080 charm_url = None1080 charm_url = None
10811081
=== modified file 'quickstart/tests/test_netutils.py'
--- quickstart/tests/test_netutils.py 2014-11-12 16:40:54 +0000
+++ quickstart/tests/test_netutils.py 2015-01-12 17:54:09 +0000
@@ -107,12 +107,17 @@
107107
108 def test_charm_url(self):108 def test_charm_url(self):
109 # The Juju GUI charm URL is correctly returned.109 # The Juju GUI charm URL is correctly returned.
110 contents = json.dumps({'charm': {'url': 'cs:trusty/juju-gui-42'}})110 contents = json.dumps({
111 'Id': 'cs:trusty/juju-gui-42',
112 'Series': 'trusty',
113 'Name': 'juju-gui',
114 'Revision': 42,
115 })
111 with self.patch_urlread(contents=contents) as mock_urlread:116 with self.patch_urlread(contents=contents) as mock_urlread:
112 charm_url = netutils.get_charm_url('trusty')117 charm_url = netutils.get_charm_url('trusty')
113 self.assertEqual('cs:trusty/juju-gui-42', charm_url)118 self.assertEqual('cs:trusty/juju-gui-42', charm_url)
114 mock_urlread.assert_called_once_with(119 mock_urlread.assert_called_once_with(
115 'http://manage.jujucharms.com/api/3/charm/trusty/juju-gui')120 'https://api.jujucharms.com/charmstore/v4/trusty/juju-gui/meta/id')
116121
117 def test_io_error(self):122 def test_io_error(self):
118 # IOErrors are properly propagated.123 # IOErrors are properly propagated.
@@ -120,17 +125,18 @@
120 with self.assertRaises(IOError) as context_manager:125 with self.assertRaises(IOError) as context_manager:
121 netutils.get_charm_url('precise')126 netutils.get_charm_url('precise')
122 mock_urlread.assert_called_once_with(127 mock_urlread.assert_called_once_with(
123 'http://manage.jujucharms.com/api/3/charm/precise/juju-gui')128 'https://api.jujucharms.com/charmstore/v4/precise/juju-gui/meta/id'
129 )
124 self.assertEqual('bad wolf', bytes(context_manager.exception))130 self.assertEqual('bad wolf', bytes(context_manager.exception))
125131
126 def test_value_error(self):132 def test_value_error(self):
127 # A ValueError is raised if the API response is not valid.133 # A ValueError is raised if the API response is not valid.
128 contents = json.dumps({'charm': {}})134 contents = json.dumps({'invalid': {}})
129 with self.patch_urlread(contents=contents) as mock_urlread:135 with self.patch_urlread(contents=contents) as mock_urlread:
130 with self.assertRaises(ValueError) as context_manager:136 with self.assertRaises(ValueError) as context_manager:
131 netutils.get_charm_url('trusty')137 netutils.get_charm_url('trusty')
132 mock_urlread.assert_called_once_with(138 mock_urlread.assert_called_once_with(
133 'http://manage.jujucharms.com/api/3/charm/trusty/juju-gui')139 'https://api.jujucharms.com/charmstore/v4/trusty/juju-gui/meta/id')
134 self.assertEqual(140 self.assertEqual(
135 'unable to find the charm URL', bytes(context_manager.exception))141 'unable to find the charm URL', bytes(context_manager.exception))
136142

Subscribers

People subscribed via source and target branches