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
=== modified file 'deployer/env/base.py'
--- deployer/env/base.py 2016-03-31 20:08:08 +0000
+++ deployer/env/base.py 2016-05-03 17:28:32 +0000
@@ -1,7 +1,7 @@
1import logging1import logging
22
3from ..utils import (3from ..utils import (
4 _get_juju_home, path_join, yaml_load, ErrorExit,4 yaml_load, ErrorExit,
5 yaml_dump, temp_file, _check_call, get_juju_major_version)5 yaml_dump, temp_file, _check_call, get_juju_major_version)
66
77
@@ -9,12 +9,6 @@
99
10 log = logging.getLogger("deployer.env")10 log = logging.getLogger("deployer.env")
1111
12 @property
13 def env_config_path(self):
14 jhome = _get_juju_home()
15 env_config_path = path_join(jhome, 'environments.yaml')
16 return env_config_path
17
18 def _check_call(self, *args, **kwargs):12 def _check_call(self, *args, **kwargs):
19 if self.options and self.options.retry_count:13 if self.options and self.options.retry_count:
20 kwargs['max_retry'] = self.options.retry_count14 kwargs['max_retry'] = self.options.retry_count
@@ -29,32 +23,10 @@
29 params.extend([flag, self.name])23 params.extend([flag, self.name])
30 return params24 return params
3125
32 def _get_env_config(self):
33 with open(self.env_config_path) as fh:
34 config = yaml_load(fh.read())
35 if self.name:
36 if self.name not in config['environments']:
37 self.log.error("Environment %r not found", self.name)
38 raise ErrorExit()
39 return config['environments'][self.name]
40 else:
41 env_name = config.get('default')
42 if env_name is None:
43 if len(config['environments'].keys()) == 1:
44 env_name = config['environments'].keys().pop()
45 else:
46 self.log.error("Ambigious operation environment")
47 raise ErrorExit()
48 return config['environments'][env_name]
49
50 def _write_config(self, svc_name, config, fh):26 def _write_config(self, svc_name, config, fh):
51 fh.write(yaml_dump({svc_name: config}))27 fh.write(yaml_dump({svc_name: config}))
52 fh.flush()28 fh.flush()
5329
54# def _write_config(self, svc_name, config, fh):
55# fh.write(yaml_dump(config))
56# fh.flush()
57
58 def _get_agent_state(self, entity):30 def _get_agent_state(self, entity):
59 try:31 try:
60 return entity['agent-state']32 return entity['agent-state']
@@ -147,7 +119,7 @@
147 try:119 try:
148 self._check_call(120 self._check_call(
149 params, self.log, "Error terminating machine %r" % mid)121 params, self.log, "Error terminating machine %r" % mid)
150 except ErrorExit, e:122 except ErrorExit as e:
151 if ("machine %s does not exist" % mid) in e.error.output:123 if ("machine %s does not exist" % mid) in e.error.output:
152 return124 return
153 raise125 raise
154126
=== modified file 'deployer/utils.py'
--- deployer/utils.py 2016-03-31 15:24:20 +0000
+++ deployer/utils.py 2016-05-03 17:28:32 +0000
@@ -121,7 +121,6 @@
121 if verbose:121 if verbose:
122 log_options.update({"loggers": {122 log_options.update({"loggers": {
123 "deployer": {"level": "DEBUG", "propogate": True}}})123 "deployer": {"level": "DEBUG", "propogate": True}}})
124 #log_options.update({"loggers": {""
125 if debug:124 if debug:
126 log_options.update(125 log_options.update(
127 {"handlers": {"console": {"formatter": "detailed"}}})126 {"handlers": {"console": {"formatter": "detailed"}}})
@@ -239,10 +238,16 @@
239238
240239
241def _get_juju_home():240def _get_juju_home():
242 jhome = os.environ.get("JUJU_HOME")241 if get_juju_major_version() == 1:
243 if jhome is None:242 return (
244 jhome = path_join(os.environ.get('HOME'), '.juju')243 os.environ.get("JUJU_HOME") or
245 return jhome244 path_join(os.environ.get('HOME'), '.juju')
245 )
246 return (
247 os.environ.get("JUJU_DATA") or
248 path_join(os.environ.get('HOME'), '.local', 'share', 'juju')
249 )
250
246251
247_juju_major_version = None252_juju_major_version = None
248def get_juju_major_version():253def get_juju_major_version():
@@ -274,14 +279,9 @@
274 stderr = kw['stderr']279 stderr = kw['stderr']
275 output = subprocess.check_output(280 output = subprocess.check_output(
276 params, cwd=cwd, stderr=stderr, env=os.environ, shell=shell)281 params, cwd=cwd, stderr=stderr, env=os.environ, shell=shell)
277 except subprocess.CalledProcessError, e:282 except subprocess.CalledProcessError as e:
278 if 'ignoreerr' in kw:283 if 'ignoreerr' in kw:
279 return284 return
280 #print "subprocess error"
281 #print " ".join(params), "\ncwd: %s\n" % cwd, "\n ".join(
282 # ["%s=%s" % (k, os.environ[k]) for k in os.environ
283 # if k.startswith("JUJU")])
284 #print e.output
285 log.error(*args)285 log.error(*args)
286 log.error("Command (%s) Output:\n\n %s", " ".join(params), e.output)286 log.error("Command (%s) Output:\n\n %s", " ".join(params), e.output)
287 if not max_retry or cur > max_retry:287 if not max_retry or cur > max_retry:
@@ -393,7 +393,7 @@
393393
394 with open(os.path.join(juju_home, 'environments.yaml')) as fh:394 with open(os.path.join(juju_home, 'environments.yaml')) as fh:
395 conf = yaml_load(fh.read())395 conf = yaml_load(fh.read())
396 if not 'default' in conf:396 if 'default' not in conf:
397 raise ValueError("No Environment specified")397 raise ValueError("No Environment specified")
398 return conf['default']398 return conf['default']
399 else:399 else:
400400
=== modified file 'setup.py'
--- setup.py 2016-04-05 20:26:10 +0000
+++ setup.py 2016-05-03 17:28:32 +0000
@@ -9,7 +9,7 @@
9 author="Kapil Thangavelu",9 author="Kapil Thangavelu",
10 author_email="kapil.foss@gmail.com",10 author_email="kapil.foss@gmail.com",
11 url="http://launchpad.net/juju-deployer",11 url="http://launchpad.net/juju-deployer",
12 install_requires=["jujuclient>=0.18", "PyYAML>=3.10"],12 install_requires=["jujuclient>=0.18", "PyYAML>=3.10", "bzr"],
13 packages=find_packages(),13 packages=find_packages(),
14 classifiers=[14 classifiers=[
15 "Development Status :: 4 - Beta",15 "Development Status :: 4 - Beta",

Subscribers

People subscribed via source and target branches