Merge lp:~andrewjbeach/juju-ci-tools/rm-list-shares into lp:juju-ci-tools

Proposed by Andrew James Beach
Status: Merged
Merged at revision: 1596
Proposed branch: lp:~andrewjbeach/juju-ci-tools/rm-list-shares
Merge into: lp:juju-ci-tools
Diff against target: 70 lines (+19/-6)
2 files modified
assess_user_grant_revoke.py (+2/-1)
fakejuju.py (+17/-5)
To merge this branch: bzr merge lp:~andrewjbeach/juju-ci-tools/rm-list-shares
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Review via email: mp+305995@code.launchpad.net

Description of the change

Removed the use of juju list-shares in the test set-ups.

assess_user_grant_revoke.py was the only script that used it. The usage there
was replaced with show-model. Some minimal additions to fakejuju.FakeBackend
were made to accomidate the changes.

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Please remove any list-shares code. The command is now dead and isn't needed to support previous betas.

Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Needs Fixing
Revision history for this message
Andrew James Beach (andrewjbeach) wrote :

Added explanation for an extra change I had made.

The add_model function would create a new FakeEnviormentState without a controller. So the new FakeEnviormentState would create a new FakeControllerState to be its controller. However add_model overwrites that new FakeControllerState with a reference to self a few lines later, so that self is the controller.

The change saves creating the discarded FakeControllerState and clarifies that the new FakeEnviormentState does indeed use the current FakeKontrollerState as its controller.

1595. By Andrew James Beach

Removed refrence to the list-shares command.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Thank you.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assess_user_grant_revoke.py'
2--- assess_user_grant_revoke.py 2016-09-13 21:33:20 +0000
3+++ assess_user_grant_revoke.py 2016-09-16 19:55:08 +0000
4@@ -82,8 +82,9 @@
5
6 def list_shares(client):
7 """Test listing users' shares"""
8- share_list = json.loads(client.get_juju_output('list-shares', '--format',
9+ model_data = json.loads(client.get_juju_output('show-model', '--format',
10 'json', include_e=False))
11+ share_list = model_data['default']['users']
12 for key, value in share_list.iteritems():
13 value.pop("last-connection", None)
14 return share_list
15
16=== modified file 'fakejuju.py'
17--- fakejuju.py 2016-09-13 18:16:55 +0000
18+++ fakejuju.py 2016-09-16 19:55:08 +0000
19@@ -59,10 +59,9 @@
20 self.shares = ['admin']
21
22 def add_model(self, name):
23- state = FakeEnvironmentState()
24+ state = FakeEnvironmentState(self)
25 state.name = name
26 self.models[name] = state
27- state.controller = self
28 state.controller.state = 'created'
29 return state
30
31@@ -506,7 +505,7 @@
32 user_status = {'user-name': user_name, 'display-name': ''}
33 return user_status
34
35- def list_shares(self):
36+ def get_users(self):
37 share_names = self.controller_state.shares
38 permissions = []
39 for key, value in self.controller_state.users.iteritems():
40@@ -524,6 +523,19 @@
41 share_list[name]['access'] = 'admin'
42 return share_list
43
44+ def show_model(self):
45+ # To get data from the model we would need:
46+ # self.controller_state.current_model
47+ model_name = 'default'
48+ data = {
49+ 'name': model_name,
50+ 'owner': 'admin@local',
51+ 'life': 'alive',
52+ 'status': {'current': 'available', 'since': '15 minutes ago'},
53+ 'users': self.get_users(),
54+ }
55+ return { model_name: data }
56+
57 def _log_command(self, command, args, model, level=logging.INFO):
58 full_args = ['juju', command]
59 if model is not None:
60@@ -674,8 +686,8 @@
61 return yaml.safe_dump(self.list_models())
62 if command == 'list-users':
63 return json.dumps(self.list_users())
64- if command == 'list-shares':
65- return json.dumps(self.list_shares())
66+ if command == 'show-model':
67+ return json.dumps(self.show_model())
68 if command == 'show-user':
69 return json.dumps(self.show_user(user_name))
70 if command == 'add-user':

Subscribers

People subscribed via source and target branches