Merge lp:~gz/juju-ci-tools/rename_admin_controller into lp:juju-ci-tools

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: 1494
Merged at revision: 1494
Proposed branch: lp:~gz/juju-ci-tools/rename_admin_controller
Merge into: lp:juju-ci-tools
Diff against target: 1022 lines (+188/-183)
12 files modified
assess_cs_staging.py (+1/-1)
assess_recovery.py (+12/-12)
deploy_stack.py (+8/-8)
industrial_test.py (+14/-13)
jujupy.py (+31/-30)
tests/test_assess_cs_staging.py (+8/-8)
tests/test_assess_recovery.py (+5/-5)
tests/test_chaos.py (+2/-2)
tests/test_deploy_stack.py (+1/-1)
tests/test_industrial_test.py (+20/-19)
tests/test_jujupy.py (+84/-82)
tests/test_quickstart_deploy.py (+2/-2)
To merge this branch: bzr merge lp:~gz/juju-ci-tools/rename_admin_controller
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+298972@code.launchpad.net

Description of the change

Refer to controller model in interfaces rather than admin model

Versions of juju that used the 'admin' name still return that, but the method for assess scripts to use is now get_controller_client() rather than get_admin_client() and so on.

The branch also renames variables used in assess scripts for clarity and mocks in tests.

One thing not changed is assess_user_grant_revoke which uses the variable name 'admin_client' but is not actually operating against the controller model. There is some kind of update needed there to make the multi-user behaviour more obvious if nothing else, but can be done as part of a separate change.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assess_cs_staging.py'
2--- assess_cs_staging.py 2016-03-18 03:02:01 +0000
3+++ assess_cs_staging.py 2016-07-02 01:12:02 +0000
4@@ -28,7 +28,7 @@
5
6
7 def _set_charm_store_ip(client, ip):
8- client.get_admin_client().juju('ssh', ('0', _get_ssh_script(ip)))
9+ client.get_controller_client().juju('ssh', ('0', _get_ssh_script(ip)))
10
11
12 def assess_deploy(client, charm):
13
14=== modified file 'assess_recovery.py'
15--- assess_recovery.py 2016-06-27 11:41:04 +0000
16+++ assess_recovery.py 2016-07-02 01:12:02 +0000
17@@ -49,10 +49,10 @@
18 log.info("%s is ready to testing", client.env.environment)
19
20
21-def restore_present_state_server(admin_client, backup_file):
22+def restore_present_state_server(controller_client, backup_file):
23 """juju-restore won't restore when the state-server is still present."""
24 try:
25- output = admin_client.restore_backup(backup_file)
26+ output = controller_client.restore_backup(backup_file)
27 except CalledProcessError as e:
28 log.info(
29 "juju-restore correctly refused to restore "
30@@ -97,11 +97,11 @@
31 return deleted_machines
32
33
34-def restore_missing_state_server(client, admin_client, backup_file):
35+def restore_missing_state_server(client, controller_client, backup_file):
36 """juju-restore creates a replacement state-server for the services."""
37 log.info("Starting restore.")
38 try:
39- output = admin_client.restore_backup(backup_file)
40+ output = controller_client.restore_backup(backup_file)
41 except CalledProcessError as e:
42 log.info('Call of juju restore exited with an error\n')
43 log.info('Call: %r\n', e.cmd)
44@@ -109,7 +109,7 @@
45 log.exception(e)
46 raise LoggedException(e)
47 log.info(output)
48- admin_client.wait_for_started(600).status
49+ controller_client.wait_for_started(600).status
50 log.info("%s restored", client.env.environment)
51 log.info("PASS")
52
53@@ -147,19 +147,19 @@
54 deploy_stack(client, charm_series)
55 log.info("Setup complete.")
56 log.info("Test started.")
57- admin_client = client.get_admin_client()
58+ controller_client = client.get_controller_client()
59 if strategy in ('ha', 'ha-backup'):
60- admin_client.enable_ha()
61- admin_client.wait_for_ha()
62+ controller_client.enable_ha()
63+ controller_client.wait_for_ha()
64 if strategy in ('ha-backup', 'backup'):
65- backup_file = admin_client.backup()
66- restore_present_state_server(admin_client, backup_file)
67+ backup_file = controller_client.backup()
68+ restore_present_state_server(controller_client, backup_file)
69 if strategy == 'ha':
70 leader_only = True
71 else:
72 leader_only = False
73 deleted_machine_ids = delete_controller_members(
74- admin_client, leader_only=leader_only)
75+ controller_client, leader_only=leader_only)
76 log.info("Deleted {}".format(deleted_machine_ids))
77 for m_id in deleted_machine_ids:
78 if bs_manager.known_hosts.get(m_id):
79@@ -169,7 +169,7 @@
80 log.info("HA recovered from leader failure.")
81 log.info("PASS")
82 else:
83- restore_missing_state_server(client, admin_client, backup_file)
84+ restore_missing_state_server(client, controller_client, backup_file)
85 log.info("Test complete.")
86
87
88
89=== modified file 'deploy_stack.py'
90--- deploy_stack.py 2016-06-22 22:24:04 +0000
91+++ deploy_stack.py 2016-07-02 01:12:02 +0000
92@@ -698,8 +698,8 @@
93 try:
94 try:
95 if len(self.known_hosts) == 0:
96- host = get_machine_dns_name(self.client.get_admin_client(),
97- '0')
98+ host = get_machine_dns_name(
99+ self.client.get_controller_client(), '0')
100 if host is None:
101 raise ValueError('Could not get machine 0 host')
102 self.known_hosts['0'] = host
103@@ -740,7 +740,7 @@
104 # be accurate for a model created by create_environment.
105 if not self._should_dump():
106 return
107- admin_client = self.client.get_admin_client()
108+ controller_client = self.client.get_controller_client()
109 if not self.jes_enabled:
110 clients = [self.client]
111 else:
112@@ -748,13 +748,13 @@
113 clients = list(self.client.iter_model_clients())
114 except Exception:
115 # Even if the controller is unreachable, we may still be able
116- # to gather some logs. admin_client and self.client are all
117- # we have knowledge of.
118- clients = [admin_client]
119- if self.client is not admin_client:
120+ # to gather some logs. The controller_client and self.client
121+ # instances are all we have knowledge of.
122+ clients = [controller_client]
123+ if self.client is not controller_client:
124 clients.append(self.client)
125 for client in clients:
126- if client.env.environment == admin_client.env.environment:
127+ if client.env.environment == controller_client.env.environment:
128 known_hosts = self.known_hosts
129 if self.jes_enabled:
130 runtime_config = self.client.get_cache_path()
131
132=== modified file 'industrial_test.py'
133--- industrial_test.py 2016-06-01 13:57:51 +0000
134+++ industrial_test.py 2016-07-02 01:12:02 +0000
135@@ -611,10 +611,10 @@
136 """Iterate the steps of this Stage. See SteppedStageAttempt."""
137 results = {'test_id': 'ensure-availability-n3'}
138 yield results
139- admin_client = client.get_admin_client()
140- admin_client.enable_ha()
141+ controller_client = client.get_controller_client()
142+ controller_client.enable_ha()
143 yield results
144- admin_client.wait_for_ha()
145+ controller_client.wait_for_ha()
146 results['result'] = True
147 yield results
148
149@@ -773,21 +773,22 @@
150 """Iterate the steps of this Stage. See SteppedStageAttempt."""
151 results = {'test_id': 'back-up-restore'}
152 yield results
153- admin_client = client.get_admin_client()
154- backup_file = admin_client.backup()
155+ controller_client = client.get_controller_client()
156+ backup_file = controller_client.backup()
157 try:
158- status = admin_client.get_status()
159+ status = controller_client.get_status()
160 instance_id = status.get_instance_id('0')
161- host = get_machine_dns_name(admin_client, '0')
162- terminate_instances(admin_client.env, [instance_id])
163- yield results
164- wait_for_state_server_to_shutdown(host, admin_client, instance_id)
165- yield results
166- with admin_client.restore_backup(backup_file):
167+ host = get_machine_dns_name(controller_client, '0')
168+ terminate_instances(controller_client.env, [instance_id])
169+ yield results
170+ wait_for_state_server_to_shutdown(
171+ host, controller_client, instance_id)
172+ yield results
173+ with controller_client.restore_backup(backup_file):
174 yield results
175 finally:
176 os.unlink(backup_file)
177- with wait_for_started(admin_client):
178+ with wait_for_started(controller_client):
179 yield results
180 results['result'] = True
181 yield results
182
183=== modified file 'jujupy.py'
184--- jujupy.py 2016-06-20 05:44:22 +0000
185+++ jujupy.py 2016-07-02 01:12:02 +0000
186@@ -704,11 +704,11 @@
187 def get_cache_path(self):
188 return get_cache_path(self.env.juju_home, models=True)
189
190- def _cmd_model(self, include_e, admin):
191- if admin:
192+ def _cmd_model(self, include_e, controller):
193+ if controller:
194 return '{controller}:{model}'.format(
195 controller=self.env.controller.name,
196- model=self.get_admin_model_name())
197+ model=self.get_controller_model_name())
198 elif self.env is None or not include_e:
199 return None
200 else:
201@@ -717,8 +717,8 @@
202 model=self.model_name)
203
204 def _full_args(self, command, sudo, args,
205- timeout=None, include_e=True, admin=False):
206- model = self._cmd_model(include_e, admin)
207+ timeout=None, include_e=True, controller=False):
208+ model = self._cmd_model(include_e, controller)
209 # sudo is not needed for devel releases.
210 return self._backend.full_args(command, args, model, timeout)
211
212@@ -924,7 +924,7 @@
213 <environment> flag will be placed after <command> and before args.
214 """
215 model = self._cmd_model(kwargs.get('include_e', True),
216- kwargs.get('admin', False))
217+ kwargs.get('controller', False))
218 timeout = kwargs.get('timeout')
219 return self._backend.get_juju_output(
220 command, args, self.used_feature_flags, self.env.juju_home,
221@@ -934,7 +934,7 @@
222 """Print the status to output."""
223 self.juju(self._show_status, ('--format', 'yaml'))
224
225- def get_status(self, timeout=60, raw=False, admin=False, *args):
226+ def get_status(self, timeout=60, raw=False, controller=False, *args):
227 """Get the current status as a dict."""
228 # GZ 2015-12-16: Pass remaining timeout into get_juju_output call.
229 for ignored in until_timeout(timeout):
230@@ -943,7 +943,8 @@
231 return self.get_juju_output(self._show_status, *args)
232 return self.status_class.from_text(
233 self.get_juju_output(
234- self._show_status, '--format', 'yaml', admin=admin))
235+ self._show_status, '--format', 'yaml',
236+ controller=controller))
237 except subprocess.CalledProcessError:
238 pass
239 raise Exception(
240@@ -995,7 +996,7 @@
241 def juju(self, command, args, sudo=False, check=True, include_e=True,
242 timeout=None, extra_env=None):
243 """Run a command under juju for the current environment."""
244- model = self._cmd_model(include_e, admin=False)
245+ model = self._cmd_model(include_e, controller=False)
246 return self._backend.juju(
247 command, args, self.used_feature_flags, self.env.juju_home,
248 model, check, timeout, extra_env)
249@@ -1018,7 +1019,7 @@
250 `args`.
251
252 """
253- model = self._cmd_model(include_e, admin=False)
254+ model = self._cmd_model(include_e, controller=False)
255 return self._backend.expect(
256 command, args, self.used_feature_flags, self.env.juju_home,
257 model, timeout, extra_env)
258@@ -1034,7 +1035,7 @@
259 return stringified_timings
260
261 def juju_async(self, command, args, include_e=True, timeout=None):
262- model = self._cmd_model(include_e, admin=False)
263+ model = self._cmd_model(include_e, controller=False)
264 return self._backend.juju_async(command, args, self.used_feature_flags,
265 self.env.juju_home, model, timeout)
266
267@@ -1252,10 +1253,10 @@
268 for model in models:
269 yield self._acquire_model_client(model['name'])
270
271- def get_admin_model_name(self):
272- """Return the name of the 'admin' model.
273+ def get_controller_model_name(self):
274+ """Return the name of the 'controller' model.
275
276- Return the name of the environment when an 'admin' model does
277+ Return the name of the environment when an 'controller' model does
278 not exist.
279 """
280 return 'controller'
281@@ -1271,13 +1272,13 @@
282 env = self.env.clone(model_name=name)
283 return self.clone(env=env)
284
285- def get_admin_client(self):
286- """Return a client for the admin model. May return self.
287+ def get_controller_client(self):
288+ """Return a client for the controller model. May return self.
289
290 This may be inaccurate for models created using add_model
291 rather than bootstrap.
292 """
293- return self._acquire_model_client(self.get_admin_model_name())
294+ return self._acquire_model_client(self.get_controller_model_name())
295
296 def list_controllers(self):
297 """List the controllers."""
298@@ -1329,7 +1330,7 @@
299 reporter = GroupReporter(sys.stdout, desired_state)
300 try:
301 for remaining in until_timeout(timeout):
302- status = self.get_status(admin=True)
303+ status = self.get_status(controller=True)
304 states = {}
305 for machine, info in status.iter_machines():
306 status = self.get_controller_member_status(info)
307@@ -1637,10 +1638,10 @@
308
309 class EnvJujuClient2B7(EnvJujuClient2B8):
310
311- def get_admin_model_name(self):
312- """Return the name of the 'admin' model.
313+ def get_controller_model_name(self):
314+ """Return the name of the 'controller' model.
315
316- Return the name of the environment when an 'admin' model does
317+ Return the name of the environment when an 'controller' model does
318 not exist.
319 """
320 return 'admin'
321@@ -1678,21 +1679,21 @@
322 args.extend(['--bootstrap-series', bootstrap_series])
323 return tuple(args)
324
325- def get_admin_client(self):
326- """Return a client for the admin model. May return self."""
327+ def get_controller_client(self):
328+ """Return a client for the controller model. May return self."""
329 return self
330
331- def get_admin_model_name(self):
332- """Return the name of the 'admin' model.
333+ def get_controller_model_name(self):
334+ """Return the name of the 'controller' model.
335
336- Return the name of the environment when an 'admin' model does
337+ Return the name of the environment when an 'controller' model does
338 not exist.
339 """
340 models = self.get_models()
341 # The dict can be empty because 1.x does not support the models.
342 # This is an ambiguous case for the jes feature flag which supports
343 # multiple models, but none is named 'admin' by default. Since the
344- # jes case also uses '-e' for models, the env is the admin model.
345+ # jes case also uses '-e' for models, the env is the controller model.
346 for model in models.get('models', []):
347 if 'admin' in model['name']:
348 return 'admin'
349@@ -1908,9 +1909,9 @@
350
351 supported_container_types = frozenset([KVM_MACHINE, LXC_MACHINE])
352
353- def _cmd_model(self, include_e, admin):
354- if admin:
355- return self.get_admin_model_name()
356+ def _cmd_model(self, include_e, controller):
357+ if controller:
358+ return self.get_controller_model_name()
359 elif self.env is None or not include_e:
360 return None
361 else:
362
363=== modified file 'tests/test_assess_cs_staging.py'
364--- tests/test_assess_cs_staging.py 2016-05-23 03:02:18 +0000
365+++ tests/test_assess_cs_staging.py 2016-07-02 01:12:02 +0000
366@@ -44,7 +44,7 @@
367
368 class TestSetCharmStoreIP(TestCase):
369
370- def test_default_as_admin(self):
371+ def test_default_as_controller(self):
372 client = fake_juju_client_optional_jes(jes_enabled=False)
373 client.bootstrap()
374 with patch.object(client, 'juju', autospec=True) as juju_mock:
375@@ -52,15 +52,15 @@
376 juju_mock.assert_called_once_with(
377 'ssh', ('0', _get_ssh_script('1.2.3.4')))
378
379- def test_separate_admin(self):
380+ def test_separate_controller(self):
381 client = fake_juju_client()
382 client.bootstrap()
383- admin_client = client.get_admin_client()
384- # Force get_admin_client to return the *same* client, instead of an
385- # equivalent one.
386- with patch.object(client, 'get_admin_client',
387- return_value=admin_client, autospec=True):
388- with patch.object(admin_client, 'juju',
389+ controller_client = client.get_controller_client()
390+ # Force get_controller_client to return the *same* client, instead of
391+ # an equivalent one.
392+ with patch.object(client, 'get_controller_client',
393+ return_value=controller_client, autospec=True):
394+ with patch.object(controller_client, 'juju',
395 autospec=True) as juju_mock:
396 _set_charm_store_ip(client, '1.2.3.4')
397 juju_mock.assert_called_once_with(
398
399=== modified file 'tests/test_assess_recovery.py'
400--- tests/test_assess_recovery.py 2016-06-04 02:49:54 +0000
401+++ tests/test_assess_recovery.py 2016-07-02 01:12:02 +0000
402@@ -64,9 +64,9 @@
403 client.bootstrap()
404
405 def terminate(env, instance_ids):
406+ model = client._backend.controller_state.controller_model
407 for instance_id in instance_ids:
408- admin_model = client._backend.controller_state.admin_model
409- admin_model.remove_state_server(instance_id)
410+ model.remove_state_server(instance_id)
411
412 with patch('assess_recovery.wait_for_state_server_to_shutdown',
413 autospec=True):
414@@ -93,19 +93,19 @@
415 with self.assess_recovery_cxt(client):
416 assess_recovery(bs_manager, 'ha-backup', 'trusty')
417
418- def test_admin_model_backup(self):
419+ def test_controller_model_backup(self):
420 client = fake_juju_client()
421 bs_manager = Mock(client=client, known_hosts={})
422 with self.assess_recovery_cxt(client):
423 assess_recovery(bs_manager, 'backup', 'trusty')
424
425- def test_admin_model_ha(self):
426+ def test_controller_model_ha(self):
427 client = fake_juju_client()
428 bs_manager = Mock(client=client, known_hosts={})
429 with self.assess_recovery_cxt(client):
430 assess_recovery(bs_manager, 'ha', 'trusty')
431
432- def test_admin_model_ha_backup(self):
433+ def test_controller_model_ha_backup(self):
434 client = fake_juju_client()
435 bs_manager = Mock(client=client, known_hosts={})
436 with self.assess_recovery_cxt(client):
437
438=== modified file 'tests/test_chaos.py'
439--- tests/test_chaos.py 2016-06-08 00:30:20 +0000
440+++ tests/test_chaos.py 2016-07-02 01:12:02 +0000
441@@ -332,7 +332,7 @@
442 expected = ['abcd' * 9, '1234' * 9]
443 self.assertEqual(
444 [
445- call('show-status', '--format', 'yaml', admin=False),
446+ call('show-status', '--format', 'yaml', controller=False),
447 call('run-action', 'chaos-monkey/1', 'start', 'mode=single',
448 'enablement-timeout=120'),
449 call('run-action', 'chaos-monkey/0', 'start', 'mode=single',
450@@ -348,7 +348,7 @@
451 monkey_runner.unleash_once()
452 self.assertEqual(
453 [
454- call('show-status', '--format', 'yaml', admin=False),
455+ call('show-status', '--format', 'yaml', controller=False),
456 call('run-action',
457 'chaos-monkey/1', 'start', 'mode=single',
458 'enablement-timeout=120',
459
460=== modified file 'tests/test_deploy_stack.py'
461--- tests/test_deploy_stack.py 2016-06-13 20:14:35 +0000
462+++ tests/test_deploy_stack.py 2016-07-02 01:12:02 +0000
463@@ -736,7 +736,7 @@
464 self.assertEqual(cc_mock.call_count, 4)
465 self.assertEqual(
466 [
467- call('show-status', '--format', 'yaml', admin=False)
468+ call('show-status', '--format', 'yaml', controller=False)
469 ],
470 gjo_mock.call_args_list)
471
472
473=== modified file 'tests/test_industrial_test.py'
474--- tests/test_industrial_test.py 2016-06-08 00:30:20 +0000
475+++ tests/test_industrial_test.py 2016-07-02 01:12:02 +0000
476@@ -1439,21 +1439,21 @@
477
478 def test_iter_steps(self):
479 client = FakeEnvJujuClient()
480- admin_client = client.get_admin_client()
481+ controller_client = client.get_controller_client()
482 ensure_av = EnsureAvailabilityAttempt()
483 ensure_iter = iter_steps_validate_info(self, ensure_av, client)
484 self.assertEqual(ensure_iter.next(), {
485 'test_id': 'ensure-availability-n3'})
486 with patch('subprocess.check_call') as cc_mock:
487- with patch.object(client, 'get_admin_client',
488- return_value=admin_client, autospec=True):
489+ with patch.object(client, 'get_controller_client',
490+ return_value=controller_client, autospec=True):
491 self.assertEqual(ensure_iter.next(), {
492 'test_id': 'ensure-availability-n3'})
493 assert_juju_call(
494 self,
495 cc_mock, client,
496 ('juju', '--show-log', 'enable-ha', '-m',
497- 'steve:{}'.format(admin_client.env.environment), '-n', '3'))
498+ 'steve:{}'.format(controller_client.env.environment), '-n', '3'))
499 status = {
500 'machines': {
501 '0': {'controller-member-status': 'has-vote'},
502@@ -1462,10 +1462,10 @@
503 },
504 'applications': {},
505 }
506- with patch_status(admin_client, status) as gs_mock:
507+ with patch_status(controller_client, status) as gs_mock:
508 self.assertEqual(ensure_iter.next(), {
509 'test_id': 'ensure-availability-n3', 'result': True})
510- gs_mock.assert_called_once_with(admin=True)
511+ gs_mock.assert_called_once_with(controller=True)
512
513 def test_iter_steps_failure(self):
514 client = FakeEnvJujuClient()
515@@ -1473,9 +1473,9 @@
516 ensure_iter = iter_steps_validate_info(self, ensure_av, client)
517 ensure_iter.next()
518 with patch('subprocess.check_call'):
519- admin_client = client.get_admin_client()
520- with patch.object(client, 'get_admin_client',
521- return_value=admin_client, autospec=True):
522+ controller_client = client.get_controller_client()
523+ with patch.object(client, 'get_controller_client',
524+ return_value=controller_client, autospec=True):
525 ensure_iter.next()
526 status = {
527 'machines': {
528@@ -1484,7 +1484,7 @@
529 },
530 'applications': {},
531 }
532- with patch_status(admin_client, status) as gs_mock:
533+ with patch_status(controller_client, status) as gs_mock:
534 with self.assertRaisesRegexp(
535 Exception, 'Timed out waiting for voting to be enabled.'):
536 ensure_iter.next()
537@@ -1766,13 +1766,14 @@
538 client.env.environment = aws_env.environment
539 client.env.config = aws_env.config
540 client.env.juju_home = aws_env.juju_home
541- admin_client = client.get_admin_client()
542+ controller_client = client.get_controller_client()
543 environ = dict(os.environ)
544 environ.update(get_euca_env(client.env.config))
545
546 def check_output(*args, **kwargs):
547- if args == (('juju', '--show-log', 'create-backup', '-m',
548- 'steve:{}'.format(admin_client.env.environment),),):
549+ if args == ((
550+ 'juju', '--show-log', 'create-backup', '-m',
551+ 'steve:{}'.format(controller_client.env.environment),),):
552 return FakePopen('juju-backup-24.tgz', '', 0)
553 self.assertEqual([], args)
554 initial_status = {
555@@ -1783,12 +1784,12 @@
556 }
557 iterator = iter_steps_validate_info(self, br_attempt, client)
558 self.assertEqual(iterator.next(), {'test_id': 'back-up-restore'})
559- with patch_status(admin_client, initial_status) as gs_mock:
560+ with patch_status(controller_client, initial_status) as gs_mock:
561 with patch('subprocess.Popen',
562 side_effect=check_output) as co_mock:
563 with patch('subprocess.check_call') as cc_mock:
564- with patch.object(client, 'get_admin_client',
565- return_value=admin_client,
566+ with patch.object(client, 'get_controller_client',
567+ return_value=controller_client,
568 autospec=True):
569 with patch('sys.stdout'):
570 self.assertEqual(
571@@ -1799,7 +1800,7 @@
572 co_mock,
573 client,
574 ('juju', '--show-log', 'create-backup',
575- '-m', 'steve:{}'.format(admin_client.env.environment)),
576+ '-m', 'steve:{}'.format(controller_client.env.environment)),
577 0)
578 self.assertEqual(
579 cc_mock.mock_calls[0],
580@@ -1809,7 +1810,7 @@
581 self.assertEqual(iterator.next(),
582 {'test_id': 'back-up-restore'})
583 pn_mock.assert_called_with('Closed.')
584- with patch.object(admin_client, 'restore_backup') as rb_mock:
585+ with patch.object(controller_client, 'restore_backup') as rb_mock:
586 self.assertEqual(iterator.next(), {'test_id': 'back-up-restore'})
587 rb_mock.assert_called_once_with(
588 os.path.abspath('juju-backup-24.tgz'))
589@@ -1823,7 +1824,7 @@
590 },
591 'applications': {},
592 }
593- with patch_status(admin_client, final_status) as gs_mock:
594+ with patch_status(controller_client, final_status) as gs_mock:
595 self.assertEqual(iterator.next(),
596 {'test_id': 'back-up-restore', 'result': True})
597 gs_mock.assert_called_once_with()
598
599=== modified file 'tests/test_jujupy.py'
600--- tests/test_jujupy.py 2016-06-20 05:08:22 +0000
601+++ tests/test_jujupy.py 2016-07-02 01:12:02 +0000
602@@ -103,11 +103,11 @@
603 return wrapper
604
605
606-class AdminOperation(Exception):
607+class ControllerOperation(Exception):
608
609 def __init__(self, operation):
610- super(AdminOperation, self).__init__(
611- 'Operation "{}" can only be performed on admin models.'.format(
612+ super(ControllerOperation, self).__init__(
613+ 'Operation "{}" is only valid on controller models.'.format(
614 operation))
615
616
617@@ -134,19 +134,19 @@
618 state.controller.state = 'created'
619 return state
620
621- def require_admin(self, operation, name):
622- if name != self.admin_model.name:
623- raise AdminOperation(operation)
624+ def require_controller(self, operation, name):
625+ if name != self.controller_model.name:
626+ raise ControllerOperation(operation)
627
628- def bootstrap(self, model_name, config, separate_admin):
629+ def bootstrap(self, model_name, config, separate_controller):
630 default_model = self.add_model(model_name)
631 default_model.name = model_name
632- if separate_admin:
633- admin_model = default_model.controller.add_model('controller')
634+ if separate_controller:
635+ controller_model = default_model.controller.add_model('controller')
636 else:
637- admin_model = default_model
638- self.admin_model = admin_model
639- admin_model.state_servers.append(admin_model.add_machine())
640+ controller_model = default_model
641+ self.controller_model = controller_model
642+ controller_model.state_servers.append(controller_model.add_machine())
643 self.state = 'bootstrapped'
644 default_model.model_config = copy.deepcopy(config)
645 self.models[default_model.name] = default_model
646@@ -234,7 +234,7 @@
647 self.controller.state = 'model-destroyed'
648
649 def restore_backup(self):
650- self.controller.require_admin('restore', self.name)
651+ self.controller.require_controller('restore', self.name)
652 if len(self.state_servers) > 0:
653 exc = subprocess.CalledProcessError('Operation not permitted', 1,
654 2)
655@@ -242,7 +242,7 @@
656 raise exc
657
658 def enable_ha(self):
659- self.controller.require_admin('enable-ha', self.name)
660+ self.controller.require_controller('enable-ha', self.name)
661 for n in range(2):
662 self.state_servers.append(self.add_machine())
663
664@@ -420,13 +420,13 @@
665 for x in range(parsed.count):
666 model_state.add_machine()
667
668- def get_admin_model_name(self):
669- return self.controller_state.admin_model.name
670+ def get_controller_model_name(self):
671+ return self.controller_state.controller_model.name
672
673 def make_controller_dict(self, controller_name):
674- admin_model = self.controller_state.admin_model
675- server_id = list(admin_model.state_servers)[0]
676- server_hostname = admin_model.machine_host_names[server_id]
677+ controller_model = self.controller_state.controller_model
678+ server_id = list(controller_model.state_servers)[0]
679+ server_hostname = controller_model.machine_host_names[server_id]
680 api_endpoint = '{}:23'.format(server_hostname)
681 return {controller_name: {'details': {'api-endpoints': [
682 api_endpoint]}}}
683@@ -579,7 +579,7 @@
684 # subset of YAML, so emit JSON.
685 return json.dumps(status_dict)
686 if command == 'create-backup':
687- self.controller_state.require_admin('backup', model)
688+ self.controller_state.require_controller('backup', model)
689 return 'juju-backup-0.tar.gz'
690 return ''
691
692@@ -658,8 +658,8 @@
693
694 class FakeJujuClientOptionalJES(EnvJujuClient):
695
696- def get_admin_model_name(self):
697- return self._backend.controller_state.admin_model.name
698+ def get_controller_model_name(self):
699+ return self._backend.controller_state.controller_model.name
700
701
702 class TestErroredUnit(TestCase):
703@@ -1228,7 +1228,7 @@
704 full = client._full_args('bar', True, ('baz', 'qux'))
705 self.assertEqual((
706 'bin', '--show-log', 'bar', '-m', 'foo:foo', 'baz', 'qux'), full)
707- full = client._full_args('bar', True, ('baz', 'qux'), admin=True)
708+ full = client._full_args('bar', True, ('baz', 'qux'), controller=True)
709 self.assertEqual(
710 ('bin', '--show-log', 'bar', '-m', 'foo:controller', 'baz', 'qux'),
711 full)
712@@ -1252,12 +1252,13 @@
713 'baz', 'qux'),
714 full)
715
716- def test_full_args_admin(self):
717+ def test_full_args_controller(self):
718 env = JujuData('foo')
719 client = EnvJujuClient(env, None, 'my/juju/bin')
720- with patch.object(client, 'get_admin_model_name',
721+ with patch.object(client, 'get_controller_model_name',
722 return_value='controller') as gamn_mock:
723- full = client._full_args('bar', False, ('baz', 'qux'), admin=True)
724+ full = client._full_args('bar', False, ('baz', 'qux'),
725+ controller=True)
726 self.assertEqual((
727 'bin', '--show-log', 'bar', '-m', 'foo:controller', 'baz', 'qux'),
728 full)
729@@ -1593,7 +1594,7 @@
730 return_value=output_text) as gjo_mock:
731 result = client.get_status()
732 gjo_mock.assert_called_once_with(
733- 'show-status', '--format', 'yaml', admin=False)
734+ 'show-status', '--format', 'yaml', controller=False)
735 self.assertEqual(Status, type(result))
736 self.assertEqual(['a', 'b', 'c'], result.status)
737
738@@ -2227,7 +2228,7 @@
739 self.assertIs(client, model_clients[0])
740 self.assertEqual('bar', model_clients[1].env.environment)
741
742- def test_get_admin_model_name(self):
743+ def test_get_controller_model_name(self):
744 models = {
745 'models': [
746 {'name': 'controller', 'model-uuid': 'aaaa'},
747@@ -2237,11 +2238,11 @@
748 client = EnvJujuClient(JujuData('foo'), None, None)
749 with patch.object(client, 'get_models',
750 return_value=models) as gm_mock:
751- admin_name = client.get_admin_model_name()
752+ controller_name = client.get_controller_model_name()
753 self.assertEqual(0, gm_mock.call_count)
754- self.assertEqual('controller', admin_name)
755+ self.assertEqual('controller', controller_name)
756
757- def test_get_admin_model_name_without_admin(self):
758+ def test_get_controller_model_name_without_controller(self):
759 models = {
760 'models': [
761 {'name': 'bar', 'model-uuid': 'aaaa'},
762@@ -2250,23 +2251,23 @@
763 }
764 client = EnvJujuClient(JujuData('foo'), None, None)
765 with patch.object(client, 'get_models', return_value=models):
766- admin_name = client.get_admin_model_name()
767- self.assertEqual('controller', admin_name)
768+ controller_name = client.get_controller_model_name()
769+ self.assertEqual('controller', controller_name)
770
771- def test_get_admin_model_name_no_models(self):
772+ def test_get_controller_model_name_no_models(self):
773 client = EnvJujuClient(JujuData('foo'), None, None)
774 with patch.object(client, 'get_models', return_value={}):
775- admin_name = client.get_admin_model_name()
776- self.assertEqual('controller', admin_name)
777+ controller_name = client.get_controller_model_name()
778+ self.assertEqual('controller', controller_name)
779
780- def test_get_admin_client(self):
781+ def test_get_controller_client(self):
782 client = EnvJujuClient(
783 JujuData('foo', {'bar': 'baz'}, 'myhome'), None, None)
784- admin_client = client.get_admin_client()
785- admin_env = admin_client.env
786- self.assertEqual('controller', admin_env.environment)
787+ controller_client = client.get_controller_client()
788+ controller_env = controller_client.env
789+ self.assertEqual('controller', controller_env.environment)
790 self.assertEqual(
791- {'bar': 'baz', 'name': 'controller'}, admin_env.config)
792+ {'bar': 'baz', 'name': 'controller'}, controller_env.config)
793
794 def test_list_controllers(self):
795 client = EnvJujuClient(JujuData('foo'), None, None)
796@@ -2309,18 +2310,18 @@
797 api-endpoints: ['[::1]:17070', '[fe80::216:3eff:0:9dc7]:17070']
798 """
799 client = EnvJujuClient(JujuData('foo', {}), None, None)
800- admin_client = client.get_admin_client()
801+ controller_client = client.get_controller_client()
802 client.env.controller.name = 'bar'
803- with patch.object(admin_client, 'get_juju_output',
804+ with patch.object(controller_client, 'get_juju_output',
805 return_value=data) as gjo:
806- endpoint = admin_client.get_controller_endpoint()
807+ endpoint = controller_client.get_controller_endpoint()
808 gjo.assert_called_once_with('show-controller', 'bar',
809 include_e=False)
810 self.assertEqual('::1', endpoint)
811
812 def test_get_controller_members(self):
813 status = Status.from_text("""\
814- model: admin
815+ model: controller
816 machines:
817 "0":
818 dns-name: 10.0.0.0
819@@ -2370,7 +2371,7 @@
820
821 def test_get_controller_members_one(self):
822 status = Status.from_text("""\
823- model: admin
824+ model: controller
825 machines:
826 "0":
827 dns-name: 10.0.0.0
828@@ -2418,7 +2419,7 @@
829 return_value=value) as gjo_mock:
830 client.wait_for_ha()
831 gjo_mock.assert_called_once_with(
832- 'show-status', '--format', 'yaml', admin=True)
833+ 'show-status', '--format', 'yaml', controller=True)
834
835 def test_wait_for_ha_no_has_vote(self):
836 value = yaml.safe_dump({
837@@ -3266,7 +3267,7 @@
838
839 class TestEnvJujuClient2B7(ClientTest):
840
841- def test_get_admin_model_name(self):
842+ def test_get_controller_model_name(self):
843 models = {
844 'models': [
845 {'name': 'admin', 'model-uuid': 'aaaa'},
846@@ -3276,11 +3277,11 @@
847 client = EnvJujuClient2B7(JujuData('foo'), None, None)
848 with patch.object(client, 'get_models',
849 return_value=models) as gm_mock:
850- admin_name = client.get_admin_model_name()
851+ controller_name = client.get_controller_model_name()
852 self.assertEqual(0, gm_mock.call_count)
853- self.assertEqual('admin', admin_name)
854+ self.assertEqual('admin', controller_name)
855
856- def test_get_admin_model_name_without_admin(self):
857+ def test_get_controller_model_name_without_controller(self):
858 models = {
859 'models': [
860 {'name': 'bar', 'model-uuid': 'aaaa'},
861@@ -3289,22 +3290,23 @@
862 }
863 client = EnvJujuClient2B7(JujuData('foo'), None, None)
864 with patch.object(client, 'get_models', return_value=models):
865- admin_name = client.get_admin_model_name()
866- self.assertEqual('admin', admin_name)
867+ controller_name = client.get_controller_model_name()
868+ self.assertEqual('admin', controller_name)
869
870- def test_get_admin_model_name_no_models(self):
871+ def test_get_controller_model_name_no_models(self):
872 client = EnvJujuClient2B7(JujuData('foo'), None, None)
873 with patch.object(client, 'get_models', return_value={}):
874- admin_name = client.get_admin_model_name()
875- self.assertEqual('admin', admin_name)
876+ controller_name = client.get_controller_model_name()
877+ self.assertEqual('admin', controller_name)
878
879- def test_get_admin_client(self):
880+ def test_get_controller_client(self):
881 client = EnvJujuClient2B7(
882 JujuData('foo', {'bar': 'baz'}, 'myhome'), None, None)
883- admin_client = client.get_admin_client()
884- admin_env = admin_client.env
885- self.assertEqual('admin', admin_env.environment)
886- self.assertEqual({'bar': 'baz', 'name': 'admin'}, admin_env.config)
887+ controller_client = client.get_controller_client()
888+ controller_env = controller_client.env
889+ self.assertEqual('admin', controller_env.environment)
890+ self.assertEqual({'bar': 'baz', 'name': 'admin'},
891+ controller_env.config)
892
893
894 class TestEnvJujuClient2B3(ClientTest):
895@@ -3431,7 +3433,7 @@
896 config = yaml.safe_load(config_file)
897 self.assertEqual({'test-mode': True}, config)
898
899- def test_get_admin_model_name(self):
900+ def test_get_controller_model_name(self):
901 models = {
902 'models': [
903 {'name': 'admin', 'model-uuid': 'aaaa'},
904@@ -3441,11 +3443,11 @@
905 client = EnvJujuClient2B2(JujuData('foo'), None, None)
906 with patch.object(client, 'get_models',
907 return_value=models) as gm_mock:
908- admin_name = client.get_admin_model_name()
909+ controller_name = client.get_controller_model_name()
910 gm_mock.assert_called_once_with()
911- self.assertEqual('admin', admin_name)
912+ self.assertEqual('admin', controller_name)
913
914- def test_get_admin_model_name_without_admin(self):
915+ def test_get_controller_model_name_without_controller(self):
916 models = {
917 'models': [
918 {'name': 'bar', 'model-uuid': 'aaaa'},
919@@ -3454,14 +3456,14 @@
920 }
921 client = EnvJujuClient2B2(JujuData('foo'), None, None)
922 with patch.object(client, 'get_models', return_value=models):
923- admin_name = client.get_admin_model_name()
924- self.assertEqual('foo', admin_name)
925+ controller_name = client.get_controller_model_name()
926+ self.assertEqual('foo', controller_name)
927
928- def test_get_admin_model_name_no_models(self):
929+ def test_get_controller_model_name_no_models(self):
930 client = EnvJujuClient2B2(JujuData('foo'), None, None)
931 with patch.object(client, 'get_models', return_value={}):
932- admin_name = client.get_admin_model_name()
933- self.assertEqual('foo', admin_name)
934+ controller_name = client.get_controller_model_name()
935+ self.assertEqual('foo', controller_name)
936
937
938 class TestEnvJujuClient2A2(TestCase):
939@@ -3690,10 +3692,10 @@
940 self.assertEqual((
941 'bin', '--debug', 'bar', '-e', 'foo', 'baz', 'qux'), full)
942
943- def test_full_args_admin(self):
944+ def test_full_args_controller(self):
945 env = SimpleEnvironment('foo')
946 client = EnvJujuClient1X(env, None, 'my/juju/bin')
947- full = client._full_args('bar', False, ('baz', 'qux'), admin=True)
948+ full = client._full_args('bar', False, ('baz', 'qux'), controller=True)
949 self.assertEqual((
950 'bin', '--show-log', 'bar', '-e', 'foo', 'baz', 'qux'), full)
951
952@@ -3987,7 +3989,7 @@
953 return_value=output_text) as gjo_mock:
954 result = client.get_status()
955 gjo_mock.assert_called_once_with(
956- 'status', '--format', 'yaml', admin=False)
957+ 'status', '--format', 'yaml', controller=False)
958 self.assertEqual(ServiceStatus, type(result))
959 self.assertEqual(['a', 'b', 'c'], result.status)
960
961@@ -4029,7 +4031,7 @@
962 client.get_status(500)
963 mock_ut.assert_called_with(500)
964
965- def test_get_status_admin(self):
966+ def test_get_status_controller(self):
967 output_text = """\
968 - a
969 - b
970@@ -4039,9 +4041,9 @@
971 client = EnvJujuClient1X(env, None, None)
972 with patch.object(client, 'get_juju_output',
973 return_value=output_text) as gjo_mock:
974- client.get_status(admin=True)
975+ client.get_status(controller=True)
976 gjo_mock.assert_called_once_with(
977- 'status', '--format', 'yaml', admin=True)
978+ 'status', '--format', 'yaml', controller=True)
979
980 @staticmethod
981 def make_status_yaml(key, machine_value, unit_value):
982@@ -5051,18 +5053,18 @@
983 self.assertIs(client, model_clients[0])
984 self.assertEqual('bar', model_clients[1].env.environment)
985
986- def test_get_admin_model_name_no_models(self):
987+ def test_get_controller_model_name_no_models(self):
988 env = SimpleEnvironment('foo', {'type': 'local'})
989 client = EnvJujuClient1X(env, '1.23-series-arch', None)
990 with patch.object(client, 'get_models', return_value={}):
991- admin_name = client.get_admin_model_name()
992- self.assertEqual('foo', admin_name)
993+ controller_name = client.get_controller_model_name()
994+ self.assertEqual('foo', controller_name)
995
996- def test_get_admin_client(self):
997+ def test_get_controller_client(self):
998 client = EnvJujuClient1X(SimpleEnvironment('foo'), {'bar': 'baz'},
999 'myhome')
1000- admin_client = client.get_admin_client()
1001- self.assertIs(client, admin_client)
1002+ controller_client = client.get_controller_client()
1003+ self.assertIs(client, controller_client)
1004
1005 def test_list_controllers(self):
1006 env = SimpleEnvironment('foo', {'type': 'local'})
1007
1008=== modified file 'tests/test_quickstart_deploy.py'
1009--- tests/test_quickstart_deploy.py 2016-06-02 17:25:41 +0000
1010+++ tests/test_quickstart_deploy.py 2016-07-02 01:12:02 +0000
1011@@ -85,9 +85,9 @@
1012 with patch('deploy_stack.get_machine_dns_name',
1013 return_value='mocked_name') as dns_mock:
1014 # Test second yield
1015- with patch.object(client, 'get_admin_client') as gac_mock:
1016+ with patch.object(client, 'get_controller_client') as gcc_mock:
1017 step = steps.next()
1018- dns_mock.assert_called_once_with(gac_mock.return_value, '0')
1019+ dns_mock.assert_called_once_with(gcc_mock.return_value, '0')
1020 self.assertEqual('mocked_name', step['bootstrap_host'])
1021 with patch.object(client, 'wait_for_deploy_started') as wds_mock:
1022 # Test third yield

Subscribers

People subscribed via source and target branches