Merge lp://qastaging/~frankban/juju-quickstart/do-not-show-user-prefix into lp://qastaging/juju-quickstart

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 108
Proposed branch: lp://qastaging/~frankban/juju-quickstart/do-not-show-user-prefix
Merge into: lp://qastaging/juju-quickstart
Diff against target: 203 lines (+47/-22)
6 files modified
quickstart/app.py (+1/-1)
quickstart/juju.py (+11/-0)
quickstart/models/jenv.py (+9/-7)
quickstart/tests/models/test_jenv.py (+4/-3)
quickstart/tests/test_app.py (+11/-11)
quickstart/tests/test_juju.py (+11/-0)
To merge this branch: bzr merge lp://qastaging/~frankban/juju-quickstart/do-not-show-user-prefix
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+244842@code.qastaging.launchpad.net

Description of the change

Do not output the user prefix.

QA:
run quickstart and check that the username
printed to stdout does not include the "srart-"
prefix.

https://codereview.appspot.com/187320043/

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

Reviewers: mp+244842_code.launchpad.net,

Message:
Please take a look.

Description:
Do not output the user prefix.

QA:
run quickstart and check that the username
printed to stdout does not include the "srart-"
prefix.

https://code.launchpad.net/~frankban/juju-quickstart/do-not-show-user-prefix/+merge/244842

(do not edit description out of merge proposal)

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

Affected files (+49, -22 lines):
   A [revision details]
   M quickstart/app.py
   M quickstart/juju.py
   M quickstart/models/jenv.py
   M quickstart/tests/models/test_jenv.py
   M quickstart/tests/test_app.py
   M quickstart/tests/test_juju.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/app.py
=== modified file 'quickstart/app.py'
--- quickstart/app.py 2014-12-15 17:31:23 +0000
+++ quickstart/app.py 2014-12-16 11:10:10 +0000
@@ -346,7 +346,7 @@
          else:
              break
      try:
- env.login(password, user=username)
+ env.authenticate(username, password)
      except jujuclient.EnvError as err:
          msg = 'unable to log in to the Juju API server on {}: {}'
          raise ProgramExit(msg.format(api_url, err.message))

Index: quickstart/juju.py
=== modified file 'quickstart/juju.py'
--- quickstart/juju.py 2014-11-12 08:48:35 +0000
+++ quickstart/juju.py 2014-12-16 11:10:10 +0000
@@ -25,6 +25,8 @@
  import websocket

+# Define the constant tag used by Juju for user entities.
+JUJU_USER_TAG = 'user'
  OPCODE_TEXT = websocket.ABNF.OPCODE_TEXT
  # Define the options used to initiate the secure WebSocket connection.
  SSLOPT = {
@@ -50,6 +52,15 @@
      deployments to specific machines.
      """

+ def authenticate(self, username, password):
+ """Log in into the Juju environment with the given credentials.
+
+ The user name must be provided without the default Juju prefix for
+ users. Use self.login to log in specifying the complete user tag.
+ """
+ return self.login(
+ password, user='{}-{}'.format(JUJU_USER_TAG, username))
+
      def deploy_bundle(self, yaml, name=None, bundle_id=None):
          """Deploy a bundle."""
          params = {'YAML': yaml}

Index: quickstart/models/jenv.py
=== modified file 'quickstart/models/jenv.py'
--- quickstart/models/jenv.py 2014-12-15 17:31:23 +0000
+++ quickstart/models/jenv.py 2014-12-16 11:10:10 +0000
@@ -31,8 +31,6 @@
  )

-# Define the constant tag used by Juju for user entities.
-JUJU_USER_TAG = 'user'
  # Define the default Juju user when an environment is initially
bootstrapped.
  JUJU_DEFAULT_USER = 'admin'

@@ -70,6 +68,8 @@
      """Return the Juju environment credentials stored in the jenv file.

      The credentials are returned as a tuple (username, password).
+ Note that the returned user name is not prefixed with the Juju default
+ prefix for user entities ("user-).

   ...

Read more...

Revision history for this message
Brad Crittenden (bac) wrote :
Revision history for this message
Richard Harding (rharding) wrote :
Revision history for this message
Francesco Banconi (frankban) wrote :
Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Do not output the user prefix.

QA:
run quickstart and check that the username
printed to stdout does not include the "srart-"
prefix.

R=bac, rharding
CC=
https://codereview.appspot.com/187320043

https://codereview.appspot.com/187320043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches