Merge lp:~tvansteenburgh/juju-deployer/1575863 into lp:juju-deployer

Proposed by Tim Van Steenburgh
Status: Merged
Merged at revision: 171
Proposed branch: lp:~tvansteenburgh/juju-deployer/1575863
Merge into: lp:juju-deployer
Diff against target: 138 lines (+15/-43)
3 files modified
deployer/env/base.py (+2/-30)
deployer/utils.py (+12/-12)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~tvansteenburgh/juju-deployer/1575863
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Matt Bruzek (community) Approve
juju-deployers Pending
Review via email: mp+293654@code.launchpad.net
To post a comment you must log in.
172. By Tim Van Steenburgh

Fix typo

Revision history for this message
Matt Bruzek (mbruzek) wrote :

+1 LGTM

review: Approve
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/env/base.py'
2--- deployer/env/base.py 2016-03-31 20:08:08 +0000
3+++ deployer/env/base.py 2016-05-03 17:28:32 +0000
4@@ -1,7 +1,7 @@
5 import logging
6
7 from ..utils import (
8- _get_juju_home, path_join, yaml_load, ErrorExit,
9+ yaml_load, ErrorExit,
10 yaml_dump, temp_file, _check_call, get_juju_major_version)
11
12
13@@ -9,12 +9,6 @@
14
15 log = logging.getLogger("deployer.env")
16
17- @property
18- def env_config_path(self):
19- jhome = _get_juju_home()
20- env_config_path = path_join(jhome, 'environments.yaml')
21- return env_config_path
22-
23 def _check_call(self, *args, **kwargs):
24 if self.options and self.options.retry_count:
25 kwargs['max_retry'] = self.options.retry_count
26@@ -29,32 +23,10 @@
27 params.extend([flag, self.name])
28 return params
29
30- def _get_env_config(self):
31- with open(self.env_config_path) as fh:
32- config = yaml_load(fh.read())
33- if self.name:
34- if self.name not in config['environments']:
35- self.log.error("Environment %r not found", self.name)
36- raise ErrorExit()
37- return config['environments'][self.name]
38- else:
39- env_name = config.get('default')
40- if env_name is None:
41- if len(config['environments'].keys()) == 1:
42- env_name = config['environments'].keys().pop()
43- else:
44- self.log.error("Ambigious operation environment")
45- raise ErrorExit()
46- return config['environments'][env_name]
47-
48 def _write_config(self, svc_name, config, fh):
49 fh.write(yaml_dump({svc_name: config}))
50 fh.flush()
51
52-# def _write_config(self, svc_name, config, fh):
53-# fh.write(yaml_dump(config))
54-# fh.flush()
55-
56 def _get_agent_state(self, entity):
57 try:
58 return entity['agent-state']
59@@ -147,7 +119,7 @@
60 try:
61 self._check_call(
62 params, self.log, "Error terminating machine %r" % mid)
63- except ErrorExit, e:
64+ except ErrorExit as e:
65 if ("machine %s does not exist" % mid) in e.error.output:
66 return
67 raise
68
69=== modified file 'deployer/utils.py'
70--- deployer/utils.py 2016-03-31 15:24:20 +0000
71+++ deployer/utils.py 2016-05-03 17:28:32 +0000
72@@ -121,7 +121,6 @@
73 if verbose:
74 log_options.update({"loggers": {
75 "deployer": {"level": "DEBUG", "propogate": True}}})
76- #log_options.update({"loggers": {""
77 if debug:
78 log_options.update(
79 {"handlers": {"console": {"formatter": "detailed"}}})
80@@ -239,10 +238,16 @@
81
82
83 def _get_juju_home():
84- jhome = os.environ.get("JUJU_HOME")
85- if jhome is None:
86- jhome = path_join(os.environ.get('HOME'), '.juju')
87- return jhome
88+ if get_juju_major_version() == 1:
89+ return (
90+ os.environ.get("JUJU_HOME") or
91+ path_join(os.environ.get('HOME'), '.juju')
92+ )
93+ return (
94+ os.environ.get("JUJU_DATA") or
95+ path_join(os.environ.get('HOME'), '.local', 'share', 'juju')
96+ )
97+
98
99 _juju_major_version = None
100 def get_juju_major_version():
101@@ -274,14 +279,9 @@
102 stderr = kw['stderr']
103 output = subprocess.check_output(
104 params, cwd=cwd, stderr=stderr, env=os.environ, shell=shell)
105- except subprocess.CalledProcessError, e:
106+ except subprocess.CalledProcessError as e:
107 if 'ignoreerr' in kw:
108 return
109- #print "subprocess error"
110- #print " ".join(params), "\ncwd: %s\n" % cwd, "\n ".join(
111- # ["%s=%s" % (k, os.environ[k]) for k in os.environ
112- # if k.startswith("JUJU")])
113- #print e.output
114 log.error(*args)
115 log.error("Command (%s) Output:\n\n %s", " ".join(params), e.output)
116 if not max_retry or cur > max_retry:
117@@ -393,7 +393,7 @@
118
119 with open(os.path.join(juju_home, 'environments.yaml')) as fh:
120 conf = yaml_load(fh.read())
121- if not 'default' in conf:
122+ if 'default' not in conf:
123 raise ValueError("No Environment specified")
124 return conf['default']
125 else:
126
127=== modified file 'setup.py'
128--- setup.py 2016-04-05 20:26:10 +0000
129+++ setup.py 2016-05-03 17:28:32 +0000
130@@ -9,7 +9,7 @@
131 author="Kapil Thangavelu",
132 author_email="kapil.foss@gmail.com",
133 url="http://launchpad.net/juju-deployer",
134- install_requires=["jujuclient>=0.18", "PyYAML>=3.10"],
135+ install_requires=["jujuclient>=0.18", "PyYAML>=3.10", "bzr"],
136 packages=find_packages(),
137 classifiers=[
138 "Development Status :: 4 - Beta",

Subscribers

People subscribed via source and target branches