374
376
def set_model_constraints(self, constraints):
375
377
constraint_strings = self._dict_as_option_strings(constraints)
376
return self.juju('set-constraints', constraint_strings)
378
retvar, ct = self.juju('set-constraints', constraint_strings)
379
return retvar, CommandComplete(NoopCondition(), ct)
378
381
def set_config(self, service, options):
379
382
option_strings = ['{}={}'.format(*item) for item in options.items()]
394
397
def set_env_option(self, option, value):
395
398
"""Set the value of the option in the environment."""
396
399
option_value = "%s=%s" % (option, value)
397
return self.juju('set-env', (option_value,))
400
retvar, ct = self.juju('set-env', (option_value,))
401
return retvar, CommandComplete(NoopCondition(), ct)
399
403
def unset_env_option(self, option):
400
404
"""Unset the value of the option in the environment."""
401
return self.juju('set-env', ('{}='.format(option),))
405
retvar, ct = self.juju('set-env', ('{}='.format(option),))
406
return retvar, CommandComplete(NoopCondition(), ct)
403
408
def get_model_defaults(self, model_key, cloud=None, region=None):
404
409
log.info('No model-defaults stored for client (attempted get).')
449
454
"""Bootstrap a controller."""
450
455
self._check_bootstrap()
451
456
args = self.get_bootstrap_args(upload_tools, bootstrap_series)
452
self.juju('bootstrap', args)
457
retvar, ct = self.juju('bootstrap', args)
458
ct.actual_completion()
455
461
def bootstrap_async(self, upload_tools=False):
497
503
"""Destroy the environment, with force. Hard kill option.
499
505
:return: Subprocess's exit code."""
506
retvar, ct = self.juju(
501
507
'destroy-environment', (self.env.environment, '--force', '-y'),
502
508
check=check, include_e=False, timeout=get_teardown_timeout(self))
509
return retvar, CommandComplete(NoopCondition(), ct)
504
511
def destroy_controller(self, all_models=False):
505
512
"""Destroy the environment, with force. Soft kill option.
507
514
:param all_models: Ignored.
508
515
:raises: subprocess.CalledProcessError if the operation fails."""
516
retvar, ct = self.juju(
510
517
'destroy-environment', (self.env.environment, '-y'),
511
518
include_e=False, timeout=get_teardown_timeout(self))
519
return retvar, CommandComplete(NoopCondition(), ct)
513
521
def destroy_environment(self, force=True, delete_jenv=False):
515
523
force_arg = ('--force',)
518
exit_status = self.juju(
526
exit_status, _ = self.juju(
519
527
'destroy-environment',
520
528
(self.env.environment,) + force_arg + ('-y',),
521
529
check=False, include_e=False,
572
580
args.extend(['--storage', storage])
573
581
if constraints is not None:
574
582
args.extend(['--constraints', constraints])
575
return self.juju('deploy', tuple(args))
583
retvar, ct = self.juju('deploy', tuple(args))
584
return retvar, CommandComplete(NoopCondition(), ct)
577
586
def upgrade_charm(self, service, charm_path=None):
578
587
args = (service,)
662
671
def disable_command(self, command_set, message=''):
663
672
"""Disable a command-set."""
664
return self.juju('block {}'.format(command_set), (message, ))
673
retvar, ct = self.juju('block {}'.format(command_set), (message, ))
674
return retvar, CommandComplete(NoopCondition(), ct)
666
676
def enable_command(self, args):
667
677
"""Enable a command-set."""
668
return self.juju('unblock', args)
678
retvar, ct = self.juju('unblock', args)
679
return retvar, CommandComplete(NoopCondition(), ct)
671
682
class EnvJujuClient22(EnvJujuClient1X):