-
Notifications
You must be signed in to change notification settings - Fork 29
/
juju-set-all-the-things
executable file
·49 lines (39 loc) · 1.38 KB
/
juju-set-all-the-things
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
import sys
import argparse
import subprocess
from deployer.config import ConfigStack
from jujuclient import Environment
parser = argparse.ArgumentParser("Set all values from deployer configs")
# juju plugin api
class Description(argparse.Action):
def __call__(self, *args, **kwargs):
print("Parse/merge the provided deployer configs and "
"set every value on all services")
sys.exit(0)
parser.add_argument(
'--description',
action=Description,
nargs=0,
help="Output a short description of the command",
)
# same args as deployer
parser.add_argument(
'-c', '--config',
help=('File containing deployment(s) json config. This '
'option can be repeated, with later files overriding '
'values in earlier ones.'),
dest='configs', action='append')
parser.add_argument(
'--series', type=str,
help=('Override distro series in config files'),
dest='series', default=None)
parser.add_argument("deployment", nargs="?")
options = parser.parse_args()
config = ConfigStack(options.configs, options.series)
env_name = subprocess.check_output(['juju', 'switch']).strip()
env = Environment.connect(env_name)
for name, svc in config.data[options.deployment]['services'].items():
if 'options' in svc:
print('Setting config for service {}'.format(name))
env.set_config(name, svc['options'])