Merge lp:~frankban/charms/precise/juju-gui/use-env-name into lp:~juju-gui/charms/precise/juju-gui/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 158
Proposed branch: lp:~frankban/charms/precise/juju-gui/use-env-name
Merge into: lp:~juju-gui/charms/precise/juju-gui/trunk
Diff against target: 116 lines (+61/-6)
5 files modified
config.yaml (+2/-4)
hooks/backend.py (+1/-1)
hooks/utils.py (+29/-0)
revision (+1/-1)
tests/test_utils.py (+28/-0)
To merge this branch: bzr merge lp:~frankban/charms/precise/juju-gui/use-env-name
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+204503@code.launchpad.net

Description of the change

Add jenv file path to the GUI login help text.

Change the GUI login message to give exact
jenv file to look in for the admin secret, if
the environment name is available in the hook's
context.

Tests: `make unittest`.

QA:
1) bootstrap a stable juju-core;
2) deploy this branch with `make deploy`;
3) open the GUI: the login message should point
   you generically to the path where to find
   the jenv files;
4) destroy the environment;

5) bootstrap juju-core trunk (at least revno 2289);
6) deploy this branch with `make deploy`;
7) open the GUI: the login message should point you
   to the exact path to the jenv file;

8) now execute "juju set juju-gui login-help=HELP!",
   and wait a couple of seconds;
9) open the GUI again and you should see the new message;
10) destroy the environment.

Done, thank you!

https://codereview.appspot.com/59560044/

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

Reviewers: mp+204503_code.launchpad.net,

Message:
Please take a look.

Description:
Add jenv file path to the GUI login help text.

Change the GUI login message to give exact
jenv file to look in for the admin secret, if
the environment name is available in the hook's
context.

Tests: `make unittest`.

QA:
1) bootstrap a stable juju-core;
2) deploy this branch with `make deploy`;
3) open the GUI: the login message should point
    you generically to the path where to find
    the jenv files;
4) destroy the environment;

5) bootstrap juju-core trunk (at least revno 2289);
6) deploy this branch with `make deploy`;
7) open the GUI: the login message should point you
    to the exact path to the jenv file;

8) now execute "juju set juju-gui login-help=HELP!",
    and wait a couple of seconds;
9) open the GUI again and you should see the new message;
10) destroy the environment.

Done, thank you!

https://code.launchpad.net/~frankban/charms/precise/juju-gui/use-env-name/+merge/204503

(do not edit description out of merge proposal)

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

Affected files (+50, -6 lines):
   A [revision details]
   M config.yaml
   M hooks/backend.py
   M hooks/utils.py
   M revision
   M tests/test_utils.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: config.yaml
=== modified file 'config.yaml'
--- config.yaml 2014-01-16 19:25:52 +0000
+++ config.yaml 2014-02-03 14:02:24 +0000
@@ -74,11 +74,9 @@
      type: string
    login-help:
      description: |
- The help text shown to the user on the login screen.
+ The help text shown to the user on the login screen. If not
provided, a
+ default message is used, suggesting how to find the login
credentials.
      type: string
- default: |
- The password is the admin-secret from the Juju environment. This can
- often be found by looking in ~/.juju/environments.yaml.
    read-only:
      description: |
        Whether or not the GUI is in read-only mode. Note that read-only
mode is

Index: revision
=== modified file 'revision'
--- revision 2014-01-22 09:07:34 +0000
+++ revision 2014-02-03 14:02:24 +0000
@@ -1,1 +1,1 @@
-103
+104

Index: hooks/backend.py
=== modified file 'hooks/backend.py'
--- hooks/backend.py 2014-01-28 11:01:55 +0000
+++ hooks/backend.py 2014-02-03 14:02:24 +0000
@@ -127,7 +127,7 @@
          build_dir = utils.compute_build_dir(
              config['juju-gui-debug'], config['serve-tests'])
          utils.write_gui_config(
- config['juju-gui-console-enabled'], config['login-help'],
+ config['juju-gui-console-enabled'], config.get('login-help'),
              config['read-only'], config['charmworld-url'],
              build_dir, secure=config['secure'], sandbox=config['sandbox'],
              ga_key=config['ga-key'],

Index: hooks/utils.py
=== modified file 'hooks/utils.py'
--- hooks/utils....

Read more...

Revision history for this message
Gary Poster (gary) wrote :

LGTM and QA OK with consideration of suggested text changes. Thank you!

Gary

https://codereview.appspot.com/59560044/diff/1/hooks/utils.py
File hooks/utils.py (right):

https://codereview.appspot.com/59560044/diff/1/hooks/utils.py#newcode372
hooks/utils.py:372: 'and searching for the admin-secret
field.'.format(env_name))
per discussion, I suggest changing this to "...the password field."

We could add the following at the end:

"Note that using juju-quickstart (https://launchpad.net/juju-quickstart)
can automate logging in, as well as other parts of installing and
starting Juju."

It would be nice if that could be a separate paragraph, but I suspect
that requires changes in the GUI, and so making a separate paragraph
should be another branch.

https://codereview.appspot.com/59560044/diff/1/hooks/utils.py#newcode380
hooks/utils.py:380: 'environment, and searching for the admin-secret
field.')
Per our QA exploration, I suggest something like the following.

The password for newer Juju clients can be found by locating the Juju
environment file placed in ~/.juju/environments/ with the same name as
the current environment. For example, if you have an environment named
"production," then the file is named
~/.juju/environments/production.jenv. Look for the "password" field in
the file, or if that is empty, for the "admin-secret". Remove the
quotes from the value, and use this to log in. The password for older
Juju clients (< 1.16) is in ~/.juju/environments.yaml, and listed as the
admin-secret for the environment you are using. Note that using
juju-quickstart (https://launchpad.net/juju-quickstart) can automate
logging in, as well as other parts of installing and starting Juju.

Again, paragraphs would be nice, but that may be for another time.

https://codereview.appspot.com/59560044/

159. By Francesco Banconi

Changes as per review.

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

*** Submitted:

Add jenv file path to the GUI login help text.

Change the GUI login message to give exact
jenv file to look in for the admin secret, if
the environment name is available in the hook's
context.

Tests: `make unittest`.

QA:
1) bootstrap a stable juju-core;
2) deploy this branch with `make deploy`;
3) open the GUI: the login message should point
    you generically to the path where to find
    the jenv files;
4) destroy the environment;

5) bootstrap juju-core trunk (at least revno 2289);
6) deploy this branch with `make deploy`;
7) open the GUI: the login message should point you
    to the exact path to the jenv file;

8) now execute "juju set juju-gui login-help=HELP!",
    and wait a couple of seconds;
9) open the GUI again and you should see the new message;
10) destroy the environment.

Done, thank you!

R=gary.poster
CC=
https://codereview.appspot.com/59560044

https://codereview.appspot.com/59560044/diff/1/hooks/utils.py
File hooks/utils.py (right):

https://codereview.appspot.com/59560044/diff/1/hooks/utils.py#newcode372
hooks/utils.py:372: 'and searching for the admin-secret
field.'.format(env_name))
On 2014/02/03 15:39:45, gary.poster wrote:
> per discussion, I suggest changing this to "...the password field."

> We could add the following at the end:

> "Note that using juju-quickstart
(https://launchpad.net/juju-quickstart) can
> automate logging in, as well as other parts of installing and starting
Juju."

> It would be nice if that could be a separate paragraph, but I suspect
that
> requires changes in the GUI, and so making a separate paragraph should
be
> another branch.

Done.

https://codereview.appspot.com/59560044/diff/1/hooks/utils.py#newcode380
hooks/utils.py:380: 'environment, and searching for the admin-secret
field.')
On 2014/02/03 15:39:45, gary.poster wrote:
> Per our QA exploration, I suggest something like the following.

> The password for newer Juju clients can be found by locating the Juju
> environment file placed in ~/.juju/environments/ with the same name as
the
> current environment. For example, if you have an environment named
> "production," then the file is named
~/.juju/environments/production.jenv. Look
> for the "password" field in the file, or if that is empty, for the
> "admin-secret". Remove the quotes from the value, and use this to log
in. The
> password for older Juju clients (< 1.16) is in
~/.juju/environments.yaml, and
> listed as the admin-secret for the environment you are using. Note
that using
> juju-quickstart (https://launchpad.net/juju-quickstart) can automate
logging in,
> as well as other parts of installing and starting Juju.

> Again, paragraphs would be nice, but that may be for another time.

Done.

https://codereview.appspot.com/59560044/

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 'config.yaml'
2--- config.yaml 2014-01-16 19:25:52 +0000
3+++ config.yaml 2014-02-03 16:30:44 +0000
4@@ -74,11 +74,9 @@
5 type: string
6 login-help:
7 description: |
8- The help text shown to the user on the login screen.
9+ The help text shown to the user on the login screen. If not provided, a
10+ default message is used, suggesting how to find the login credentials.
11 type: string
12- default: |
13- The password is the admin-secret from the Juju environment. This can
14- often be found by looking in ~/.juju/environments.yaml.
15 read-only:
16 description: |
17 Whether or not the GUI is in read-only mode. Note that read-only mode is
18
19=== modified file 'hooks/backend.py'
20--- hooks/backend.py 2014-01-28 11:01:55 +0000
21+++ hooks/backend.py 2014-02-03 16:30:44 +0000
22@@ -127,7 +127,7 @@
23 build_dir = utils.compute_build_dir(
24 config['juju-gui-debug'], config['serve-tests'])
25 utils.write_gui_config(
26- config['juju-gui-console-enabled'], config['login-help'],
27+ config['juju-gui-console-enabled'], config.get('login-help'),
28 config['read-only'], config['charmworld-url'],
29 build_dir, secure=config['secure'], sandbox=config['sandbox'],
30 ga_key=config['ga-key'],
31
32=== modified file 'hooks/utils.py'
33--- hooks/utils.py 2014-01-16 19:25:52 +0000
34+++ hooks/utils.py 2014-02-03 16:30:44 +0000
35@@ -362,6 +362,35 @@
36 else:
37 log('Running in insecure mode! Port 80 will serve unencrypted.')
38 protocol = 'ws'
39+ # Set up the help message displayed by the GUI login view.
40+ if login_help is None:
41+ env_name = os.getenv('JUJU_ENV_NAME')
42+ if env_name:
43+ login_help = (
44+ 'The password is the admin-secret from the Juju environment. '
45+ 'This can be found by looking in ~/.juju/environments/{}.jenv '
46+ 'and searching for the password field. Note that using '
47+ 'juju-quickstart (https://launchpad.net/juju-quickstart) can '
48+ 'automate logging in, as well as other parts of installing '
49+ 'and starting Juju.'.format(env_name))
50+ else:
51+ # The Juju environment name is included in the hooks context
52+ # starting from juju-core v1.18.
53+ login_help = (
54+ 'The password for newer Juju clients can be found by locating '
55+ 'the Juju environment file placed in ~/.juju/environments/ '
56+ 'with the same name as the current environment. For example, '
57+ 'if you have an environment named "production", then the file '
58+ 'is named ~/.juju/environments/production.jenv. Look for the '
59+ '"password" field in the file, or if that is empty, for the '
60+ '"admin-secret". Remove the quotes from the value, and use '
61+ 'this to log in. The password for older Juju clients (< 1.16) '
62+ 'is in ~/.juju/environments.yaml, and listed as the '
63+ 'admin-secret for the environment you are using. Note that '
64+ 'using juju-quickstart '
65+ '(https://launchpad.net/juju-quickstart) can automate logging '
66+ 'in, as well as other parts of installing and starting Juju.')
67+
68 context = {
69 'raw_protocol': protocol,
70 'address': unit_get('public-address'),
71
72=== modified file 'revision'
73--- revision 2014-01-22 09:07:34 +0000
74+++ revision 2014-02-03 16:30:44 +0000
75@@ -1,1 +1,1 @@
76-103
77+104
78
79=== modified file 'tests/test_utils.py'
80--- tests/test_utils.py 2014-01-16 19:25:52 +0000
81+++ tests/test_utils.py 2014-02-03 16:30:44 +0000
82@@ -961,6 +961,34 @@
83 self.assertIn('user: "user-admin"', js_conf)
84 self.assertIn('password: "kumquat"', js_conf)
85
86+ def test_write_gui_config_help_with_env_name(self):
87+ # The login help message refers to the specific jenv file is the Juju
88+ # environment name is available.
89+ with mock.patch('os.environ', {'JUJU_ENV_NAME': 'my-env'}):
90+ write_gui_config(
91+ False, None, True, True, self.charmworld_url, self.build_dir,
92+ config_js_path='config',)
93+ js_conf = self.files['config']
94+ expected_help = (
95+ 'login_help: "The password is the admin-secret from the Juju '
96+ 'environment. This can be found by looking in '
97+ '~/.juju/environments/my-env.jenv and searching for the '
98+ 'password field.')
99+ self.assertIn(expected_help, js_conf)
100+
101+ def test_write_gui_config_help_without_env_name(self):
102+ # The login help points to the path where to find the jenv files.
103+ write_gui_config(
104+ False, None, True, True, self.charmworld_url, self.build_dir,
105+ config_js_path='config',)
106+ js_conf = self.files['config']
107+ expected_help = (
108+ 'login_help: "The password for newer Juju clients can be found by '
109+ 'locating the Juju environment file placed in '
110+ '~/.juju/environments/ with the same name as the current '
111+ 'environment.')
112+ self.assertIn(expected_help, js_conf)
113+
114 def test_setup_haproxy_config_insecure(self):
115 setup_haproxy_config(self.ssl_cert_path, secure=False)
116 # The insecure approach eliminates the https redirect.

Subscribers

People subscribed via source and target branches