Merge lp:~hazmat/pyjuju/local-origin-passthrough into lp:pyjuju

Proposed by Kapil Thangavelu
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 417
Merged at revision: 384
Proposed branch: lp:~hazmat/pyjuju/local-origin-passthrough
Merge into: lp:pyjuju
Prerequisite: lp:~jimbaker/pyjuju/env-origin
Diff against target: 389 lines (+96/-31)
12 files modified
juju/environment/config.py (+3/-2)
juju/environment/tests/test_config.py (+1/-1)
juju/lib/lxc/__init__.py (+9/-3)
juju/lib/lxc/data/juju-create (+8/-6)
juju/lib/lxc/tests/test_lxc.py (+11/-8)
juju/machine/tests/test_unit_deployment.py (+30/-0)
juju/machine/unit.py (+18/-6)
juju/providers/local/__init__.py (+3/-0)
juju/providers/local/agent.py (+10/-3)
juju/providers/local/tests/test_agent.py (+1/-0)
juju/unit/address.py (+1/-1)
juju/unit/tests/test_address.py (+1/-1)
To merge this branch: bzr merge lp:~hazmat/pyjuju/local-origin-passthrough
Reviewer Review Type Date Requested Status
Benjamin Saller (community) Approve
Gustavo Niemeyer Approve
Jim Baker (community) Needs Information
Review via email: mp+77646@code.launchpad.net

This proposal supersedes a proposal from 2011-09-30.

Description of the change

Local provider should respect juju-origin

Minor fixes to pass juju origin to the machine agent, and to juju-create
to utilize jujuorigin for lp branch names.

Depends on env-origin AND unit-relation-with-addr...

the latter is probably immaterial.. just happened to be in the pipeline, i can extract if its a problem.

To post a comment you must log in.
Revision history for this message
Jim Baker (jimbaker) wrote :

The implementation looks good.

However, there were two problems:

1. I was unable to run this with our wordpress example. None of the service units start up. Are there any branches that this work implicitly depends on?

2. Probably related, this error was reported:

[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
  File "/home/jbaker/canonical/juju/hazmat/local-origin-passthrough/juju/machine/tests/test_unit_deployment.py", line 405, in test_origin_usage
    self.unit_name, self.juju_home, customize_log=customize_log)
exceptions.TypeError: __init__() got an unexpected keyword argument 'customize_log'

juju.machine.tests.test_unit_deployment.UnitContainerDeploymentTest.test_origin_usage

review: Needs Information
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

i'm still in progress on functionally testing this and the overall local provider end 2 end. with drawing from the review queue till that's completed.

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

> The implementation looks good.
>
> However, there were two problems:
>
> 1. I was unable to run this with our wordpress example. None of the service
> units start up. Are there any branches that this work implicitly depends on?
>

works pretty well for me now with juju-origin to a branch, the ppa still seems to hit the protocol version issue (i guess the ppa hasn't updated), i'd be happy to debug with you what's happening on your system. the master-customize.log is pretty critical to understanding most issues.

> 2. Probably related, this error was reported:
>

fixed.

thanks for having a look.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

LGTM. Just a couple of trivials:

[1]

149 - elif [ $JUJU_ORIGIN = "branch" ]; then
150 - echo "Using juju Branch $JUJU_SOURCE"
151 + elif [[ $JUJU_ORIGIN == lp:* ]]; then
152 + echo "Using juju branch $JUJU_SOURCE"

Hmmm.. What'd be the reason to have $JUJU_SOURCE if $JUJU_ORIGIN
already has the branch?

Also, is there a difference between == and = in this context? They're
both being used with the same purpose in the two different occurrences
of this test.

[2]

177 bash -c "cd /usr/lib/juju/juju && sudo python setup.py develop"
178 + chmod -R a+r /usr/lib/juju

Indentation is slightly off here.

review: Approve
Revision history for this message
Benjamin Saller (bcsaller) wrote :

[3]

132 - _customize_container(self.customize_script, self.rootfs)
133 + _, output = _customize_container(self.customize_script, self.rootfs)
134 +
135 + if self.customize_log:
136 + with open(self.customize_log, "w") as fh:
137 + fh.write(output)

Its very possible to write a customize_log location which is in the container but not writeable by the caller. In cases like this opening a temp file and using [sudo mv tmp customize_log] might make sense. Then again I suppose there is a single supported use of this and its already written so I don't feel strongly.

[4]

+ apt-get install --force-yes -y bzr tmux sudo python-software-properties python-yaml

I am reminded reminded that we have a bug around hook execution needing the DEBIAN_FRONTEND=noninteractive. I think we should do this in this file as well

DEBIAN_FRONTEND=noninteractive
APT_OPTIONS="-o Dpkg::Options::="--force-confnew --force-yes -fuy"

apt-get install $APT_OPTIONS ...

might make sense in this file as well.

[5]
175 + # light weight checkout is significantly faster, no history though
176 + bzr co --lightweight $JUJU_ORIGIN /usr/lib/juju/juju

This strikes me as very much the correct thing to so here.

[6] The private address relation stuff seems like a good idea, but I'll be more pleased when the unit-get stuff you did lands. This branch still can't run the examples as they stand now.

review: Approve
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

Excerpts from Benjamin Saller's message of Tue Oct 04 20:26:25 UTC 2011:
> Review: Approve
>
> [3]
>
> 132 - _customize_container(self.customize_script, self.rootfs)
> 133 + _, output = _customize_container(self.customize_script, self.rootfs)
> 134 +
> 135 + if self.customize_log:
> 136 + with open(self.customize_log, "w") as fh:
> 137 + fh.write(output)
>
> Its very possible to write a customize_log location which is in the container but not writeable by the caller. In cases like this opening a temp file and using [sudo mv tmp customize_log] might make sense. Then again I suppose there is a single supported use of this and its already written so I don't feel strongly.

Customize is only invoked once for master template container, not per container
in practice since its not used for clones. To make it easy to discover and find
this file we end up putting it into data-dir/units/master-customize.log. Putting
it in the container would detract from easy discovery. In practice most of the
issues with setting up the local provider where localized to the output from
this script, and keeping it outside the container helps ensure it survives
a destroy-environment if its needed for additional debugging. iotw, i think its
in a good spot for now.

>
> [4]
>
> + apt-get install --force-yes -y bzr tmux sudo python-software-properties python-yaml
>
> I am reminded reminded that we have a bug around hook execution needing the DEBIAN_FRONTEND=noninteractive. I think we should do this in this file as well
>
> DEBIAN_FRONTEND=noninteractive
> APT_OPTIONS="-o Dpkg::Options::="--force-confnew --force-yes -fuy"
>
> apt-get install $APT_OPTIONS ...
>
> might make sense in this file as well.
>

Sounds good, thanks.

>
>
> [5]
> 175 + # light weight checkout is significantly faster, no history though
> 176 + bzr co --lightweight $JUJU_ORIGIN /usr/lib/juju/juju
>
> This strikes me as very much the correct thing to so here.
>

Indeed, if needed they can be easily bound on a per container basis. I'm a
little concerned that this will end up stale because customize is only invoked
once, but i don't see any other easy options here, and it has a nice side
benefit ensuring consistency across a deploy.

>
> [6] The private address relation stuff seems like a good idea, but I'll be more pleased when the unit-get stuff you did lands. This branch still can't run the examples as they stand now.

Yeah.. but they where already broken for local deploy before the branch.. they
unit-get cli branch should be merged shortly.

thanks for the review.
cheers,
Kapil

418. By Kapil Thangavelu

merge pipeline, resolve conflict

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

Excerpts from Gustavo Niemeyer's message of Tue Oct 04 02:08:27 UTC 2011:
> Review: Approve
>
> LGTM. Just a couple of trivials:
>
> [1]
>
> 149 - elif [ $JUJU_ORIGIN = "branch" ]; then
> 150 - echo "Using juju Branch $JUJU_SOURCE"
> 151 + elif [[ $JUJU_ORIGIN == lp:* ]]; then
> 152 + echo "Using juju branch $JUJU_SOURCE"
>
> Hmmm.. What'd be the reason to have $JUJU_SOURCE if $JUJU_ORIGIN
> already has the branch?

Leftover from previous usage, replaced with JUJU_ORIGIN

>
> Also, is there a difference between == and = in this context? They're
> both being used with the same purpose in the two different occurrences
> of this test.

Sounds good, both work, i'll use '=' for consistency.

>
> [2]
>
> 177 bash -c "cd /usr/lib/juju/juju && sudo python setup.py develop"
> 178 + chmod -R a+r /usr/lib/juju
>
> Indentation is slightly off here.

Fixed, thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'juju/environment/config.py'
--- juju/environment/config.py 2011-10-04 19:44:11 +0000
+++ juju/environment/config.py 2011-10-04 22:53:25 +0000
@@ -55,8 +55,9 @@
55 "storage-url": String(),55 "storage-url": String(),
56 "placement": String(),56 "placement": String(),
57 "default-series": String()},57 "default-series": String()},
58 optional=["storage-url", "placement"]),58 optional=["storage-url", "placement",
59 "lxc": KeyDict({"admin-secret": String(),59 "default-series"]),
60 "local": KeyDict({"admin-secret": String(),
60 "data-dir": String(),61 "data-dir": String(),
61 "placement": Constant("local"),62 "placement": Constant("local"),
62 "default-series": String()},63 "default-series": String()},
6364
=== modified file 'juju/environment/tests/test_config.py'
--- juju/environment/tests/test_config.py 2011-10-04 19:44:11 +0000
+++ juju/environment/tests/test_config.py 2011-10-04 22:53:25 +0000
@@ -43,7 +43,7 @@
4343
44environments:44environments:
45 sample:45 sample:
46 type: lxc46 type: local
47 admin-secret: sekret47 admin-secret: sekret
48 default-series: oneiric48 default-series: oneiric
49"""49"""
5050
=== modified file 'juju/lib/lxc/__init__.py'
--- juju/lib/lxc/__init__.py 2011-09-29 22:04:55 +0000
+++ juju/lib/lxc/__init__.py 2011-10-04 22:53:25 +0000
@@ -152,7 +152,9 @@
152 origin_source=None,152 origin_source=None,
153 network_name="virbr0",153 network_name="virbr0",
154 customize_script=None,154 customize_script=None,
155 debug_log=None, console_log=None):155 debug_log=None,
156 console_log=None,
157 customize_log=None):
156 """Create an LXCContainer158 """Create an LXCContainer
157159
158 :param container_name: should be unique within the system160 :param container_name: should be unique within the system
@@ -174,7 +176,7 @@
174 self.container_name = container_name176 self.container_name = container_name
175 self.debug_log = debug_log177 self.debug_log = debug_log
176 self.console_log = console_log178 self.console_log = console_log
177179 self.customize_log = customize_log
178 if customize_script is None:180 if customize_script is None:
179 customize_script = os.path.join(DATA_PATH,181 customize_script = os.path.join(DATA_PATH,
180 "juju-create")182 "juju-create")
@@ -240,7 +242,11 @@
240 print >>fp, escape("JUJU_SOURCE", self.source)242 print >>fp, escape("JUJU_SOURCE", self.source)
241243
242 _cmd(["sudo", "mv", fn, target])244 _cmd(["sudo", "mv", fn, target])
243 _customize_container(self.customize_script, self.rootfs)245 _, output = _customize_container(self.customize_script, self.rootfs)
246
247 if self.customize_log:
248 with open(self.customize_log, "w") as fh:
249 fh.write(output)
244250
245 def execute(self, args):251 def execute(self, args):
246 if not isinstance(args, (list, tuple)):252 if not isinstance(args, (list, tuple)):
247253
=== modified file 'juju/lib/lxc/data/juju-create'
--- juju/lib/lxc/data/juju-create 2011-09-30 01:57:00 +0000
+++ juju/lib/lxc/data/juju-create 2011-10-04 22:53:25 +0000
@@ -69,8 +69,8 @@
6969
70 if [ $JUJU_ORIGIN = "ppa" ]; then70 if [ $JUJU_ORIGIN = "ppa" ]; then
71 echo "Using juju PPA for container"71 echo "Using juju PPA for container"
72 elif [ $JUJU_ORIGIN = "branch" ]; then72 elif [[ $JUJU_ORIGIN == lp:* ]]; then
73 echo "Using juju Branch $JUJU_SOURCE"73 echo "Using juju branch $JUJU_SOURCE"
74 elif [ $JUJU_ORIGIN = "distro" ]; then74 elif [ $JUJU_ORIGIN = "distro" ]; then
75 echo "Using juju distribution packages"75 echo "Using juju distribution packages"
76 else76 else
@@ -79,7 +79,7 @@
79 fi79 fi
8080
81 echo "Setting up juju in container"81 echo "Setting up juju in container"
82 apt-get install --force-yes -y bzr tmux sudo python-software-properties82 apt-get install --force-yes -y bzr tmux sudo python-software-properties python-yaml
8383
84 if [ $JUJU_ORIGIN = "ppa" ]; then84 if [ $JUJU_ORIGIN = "ppa" ]; then
85 # the echo forces an enter to get around the interactive85 # the echo forces an enter to get around the interactive
@@ -87,11 +87,13 @@
87 echo y | apt-add-repository ppa:juju/pkgs87 echo y | apt-add-repository ppa:juju/pkgs
88 apt-get update88 apt-get update
89 apt-get install --force-yes -y juju python-txzookeeper89 apt-get install --force-yes -y juju python-txzookeeper
90 elif [ $JUJU_ORIGIN = "branch" ]; then90 elif [[ $JUJU_ORIGIN = lp:* ]]; then
91 apt-get install --force-yes -y python-txzookeeper91 apt-get install --force-yes -y python-txzookeeper python-setuptools
92 mkdir /usr/lib/juju92 mkdir /usr/lib/juju
93 bzr branch $JUJU_SOURCE /usr/lib/juju/juju93 # light weight checkout is significantly faster, no history though
94 bzr co --lightweight $JUJU_ORIGIN /usr/lib/juju/juju
94 bash -c "cd /usr/lib/juju/juju && sudo python setup.py develop"95 bash -c "cd /usr/lib/juju/juju && sudo python setup.py develop"
96 chmod -R a+r /usr/lib/juju
95 elif [ $JUJU_ORIGIN = "distro" ]; then97 elif [ $JUJU_ORIGIN = "distro" ]; then
96 apt-get install --force-yes -y juju python-txzookeeper98 apt-get install --force-yes -y juju python-txzookeeper
97 fi99 fi
98100
=== modified file 'juju/lib/lxc/tests/test_lxc.py'
--- juju/lib/lxc/tests/test_lxc.py 2011-09-28 18:04:36 +0000
+++ juju/lib/lxc/tests/test_lxc.py 2011-10-04 22:53:25 +0000
@@ -76,14 +76,16 @@
76 @inlineCallbacks76 @inlineCallbacks
77 def test_lxc_deferred(self):77 def test_lxc_deferred(self):
78 self.addCleanup(self.clean_container, DEFAULT_CONTAINER)78 self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
79 yield deferToThread(_lxc_create, DEFAULT_CONTAINER, config_file=self.config)79 yield deferToThread(
80 _lxc_create, DEFAULT_CONTAINER, config_file=self.config)
80 yield deferToThread(_lxc_start, DEFAULT_CONTAINER)81 yield deferToThread(_lxc_start, DEFAULT_CONTAINER)
8182
82 @inlineCallbacks83 @inlineCallbacks
83 def test_lxc_container(self):84 def test_lxc_container(self):
84 self.addCleanup(self.clean_container, DEFAULT_CONTAINER)85 self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
8586 customize_log = self.makeFile()
86 c = LXCContainer(DEFAULT_CONTAINER, "dsa...", "ppa")87 c = LXCContainer(
88 DEFAULT_CONTAINER, "dsa...", "ppa", customize_log=customize_log)
8789
88 running = yield c.is_running()90 running = yield c.is_running()
89 self.assertFalse(running)91 self.assertFalse(running)
@@ -123,6 +125,9 @@
123 containers = yield get_containers(None)125 containers = yield get_containers(None)
124 self.assertNotIn(DEFAULT_CONTAINER, containers)126 self.assertNotIn(DEFAULT_CONTAINER, containers)
125127
128 # Verify the customize log file.
129 self.assertTrue(os.path.exists(customize_log))
130
126 # and its gone131 # and its gone
127 output = _lxc_ls()132 output = _lxc_ls()
128 self.assertNotIn(DEFAULT_CONTAINER, output)133 self.assertNotIn(DEFAULT_CONTAINER, output)
@@ -240,7 +245,9 @@
240 # we'd have to run customize_constainer again which removes245 # we'd have to run customize_constainer again which removes
241 # some of the point of the clone support to repair this.246 # some of the point of the clone support to repair this.
242 # droppping assertion for now and replacing with a lax one247 # droppping assertion for now and replacing with a lax one
243 #XXX::: self.assertIn("127.0.0.1 %s localhost" % c.container_name, sudo_get("etc/hosts"))248 #XXX::: self.assertIn("127.0.0.1 %s localhost" % c.container_name,
249 #XXX sudo_get("etc/hosts"))
250
244 self.assertIn(c.container_name, sudo_get("etc/hosts"))251 self.assertIn(c.container_name, sudo_get("etc/hosts"))
245252
246 # nameserver253 # nameserver
@@ -263,7 +270,3 @@
263 self.assertEqual(1, run(["dpkg-query", "-s", "juju"]))270 self.assertEqual(1, run(["dpkg-query", "-s", "juju"]))
264 # but the branch is checked out271 # but the branch is checked out
265 self.asssertTrue(os.path.exists(p("usr/lib/juju/juju")))272 self.asssertTrue(os.path.exists(p("usr/lib/juju/juju")))
266
267
268
269
270273
=== modified file 'juju/machine/tests/test_unit_deployment.py'
--- juju/machine/tests/test_unit_deployment.py 2011-09-29 22:04:55 +0000
+++ juju/machine/tests/test_unit_deployment.py 2011-10-04 22:53:25 +0000
@@ -386,6 +386,30 @@
386 self.assertIn("Destroyed container for riak/0", output)386 self.assertIn("Destroyed container for riak/0", output)
387387
388 @inlineCallbacks388 @inlineCallbacks
389 def test_origin_usage(self):
390 """The machine agent is started with a origin environment variable
391 """
392 mock_container = self.mocker.patch(LXCContainer)
393 mock_container.is_constructed()
394 self.mocker.result(True)
395 mock_container.is_constructed()
396 self.mocker.result(True)
397 self.mocker.replay()
398
399 environ = dict(os.environ)
400 environ["JUJU_ORIGIN"] = "lp:~juju/foobar"
401
402 self.change_environment(**environ)
403 unit_deploy = UnitContainerDeployment(
404 self.unit_name, self.juju_home)
405 container = yield unit_deploy._get_master_template(
406 "local", "127.0.0.1:1", "abc")
407 self.assertEqual(container.origin, "lp:~juju/foobar")
408 self.assertEqual(
409 container.customize_log,
410 os.path.join(self.juju_home, "units", "master-customize.log"))
411
412 @inlineCallbacks
389 def test_start(self):413 def test_start(self):
390 container = LXCContainer(self.unit_name, None, None, None)414 container = LXCContainer(self.unit_name, None, None, None)
391 rootfs = self.makeDir()415 rootfs = self.makeDir()
@@ -429,6 +453,12 @@
429 self.unit_deploy.directory, "var", "lib", "juju", "units",453 self.unit_deploy.directory, "var", "lib", "juju", "units",
430 self.unit_deploy.unit_path_name, "charm", "metadata.yaml")))454 self.unit_deploy.unit_path_name, "charm", "metadata.yaml")))
431455
456 # Verify the directory structure in the unit.
457 self.assertTrue(os.path.exists(os.path.join(
458 self.unit_deploy.directory, "var", "lib", "juju", "state")))
459 self.assertTrue(os.path.exists(os.path.join(
460 self.unit_deploy.directory, "var", "log", "juju")))
461
432 # Verify log output462 # Verify log output
433 output = self.output.getvalue()463 output = self.output.getvalue()
434 self.assertIn("Charm extracted into container", output)464 self.assertIn("Charm extracted into container", output)
435465
=== modified file 'juju/machine/unit.py'
--- juju/machine/unit.py 2011-09-30 03:20:11 +0000
+++ juju/machine/unit.py 2011-10-04 22:53:25 +0000
@@ -188,6 +188,7 @@
188 super(UnitContainerDeployment, self).__init__(unit_name, juju_home)188 super(UnitContainerDeployment, self).__init__(unit_name, juju_home)
189189
190 self._unit_namespace = os.environ.get("JUJU_UNIT_NS")190 self._unit_namespace = os.environ.get("JUJU_UNIT_NS")
191 self._juju_origin = os.environ.get("JUJU_ORIGIN")
191 assert self._unit_namespace is not None, "Required unit ns not found"192 assert self._unit_namespace is not None, "Required unit ns not found"
192193
193 self.pid_file = None194 self.pid_file = None
@@ -248,7 +249,13 @@
248 self._unit_namespace, machine_id)249 self._unit_namespace, machine_id)
249250
250 master_template = LXCContainer(251 master_template = LXCContainer(
251 container_template_name, origin="ppa", public_key=public_key)252 container_template_name, origin=self._juju_origin,
253 public_key=public_key)
254
255 # Debug log for the customize script, customize is only run on master.
256 customize_log_path = os.path.join(
257 self.juju_home, "units", "master-customize.log")
258 master_template.customize_log = customize_log_path
252259
253 if not master_template.is_constructed():260 if not master_template.is_constructed():
254 log.debug("Creating master container...")261 log.debug("Creating master container...")
@@ -286,7 +293,7 @@
286 # Build a template container that can be cloned in deploy293 # Build a template container that can be cloned in deploy
287 # we leave the loosely initialized self.container in place for294 # we leave the loosely initialized self.container in place for
288 # the class as thats all we need for methods other than start.295 # the class as thats all we need for methods other than start.
289 container, directory = yield self._get_container(machine_id,296 self.container, self.directory = yield self._get_container(machine_id,
290 zookeeper_hosts,297 zookeeper_hosts,
291 bundle,298 bundle,
292 public_key)299 public_key)
@@ -295,14 +302,14 @@
295302
296 # Extract the charm bundle303 # Extract the charm bundle
297 charm_path = os.path.join(304 charm_path = os.path.join(
298 directory, "var", "lib", "juju", "units",305 self.directory, "var", "lib", "juju", "units",
299 self.unit_path_name, "charm")306 self.unit_path_name, "charm")
300 bundle.extract_to(charm_path)307 bundle.extract_to(charm_path)
301 log.debug("Charm extracted into container")308 log.debug("Charm extracted into container")
302309
303 # Write upstart file for the agent into the container310 # Write upstart file for the agent into the container
304 upstart_path = os.path.join(311 upstart_path = os.path.join(
305 directory, "etc", "init",312 self.directory, "etc", "init",
306 "%s-unit-agent.conf" % self.unit_path_name)313 "%s-unit-agent.conf" % self.unit_path_name)
307 with open(upstart_path, "w") as fh:314 with open(upstart_path, "w") as fh:
308 fh.write(self.get_upstart_unit_job(machine_id, zookeeper_hosts))315 fh.write(self.get_upstart_unit_job(machine_id, zookeeper_hosts))
@@ -312,12 +319,17 @@
312 self.juju_home, "units", self.unit_path_name, "unit.log")319 self.juju_home, "units", self.unit_path_name, "unit.log")
313 if not os.path.lexists(unit_log_path_host):320 if not os.path.lexists(unit_log_path_host):
314 os.symlink(321 os.symlink(
315 os.path.join(directory, "var", "log", "juju",322 os.path.join(self.directory, "var", "log", "juju",
316 "unit-%s.log" % self.unit_path_name),323 "unit-%s.log" % self.unit_path_name),
317 unit_log_path_host)324 unit_log_path_host)
318325
326 # Debug log for the container
327 container_log_path = os.path.join(
328 self.juju_home, "units", self.unit_path_name, "container.log")
329 self.container.debug_log = container_log_path
330
319 log.debug("Starting container...")331 log.debug("Starting container...")
320 yield container.run()332 yield self.container.run()
321 log.info("Started container for %s" % self.unit_name)333 log.info("Started container for %s" % self.unit_name)
322334
323 @inlineCallbacks335 @inlineCallbacks
324336
=== modified file 'juju/providers/local/__init__.py'
--- juju/providers/local/__init__.py 2011-09-30 03:20:11 +0000
+++ juju/providers/local/__init__.py 2011-10-04 22:53:25 +0000
@@ -125,11 +125,14 @@
125 log.info("Starting machine agent...")125 log.info("Starting machine agent...")
126 pid_file = os.path.join(self._directory, "machine-agent.pid")126 pid_file = os.path.join(self._directory, "machine-agent.pid")
127 log_file = os.path.join(self._directory, "machine-agent.log")127 log_file = os.path.join(self._directory, "machine-agent.log")
128
129 juju_origin = self.config.get("juju-origin")
128 agent = ManagedMachineAgent(pid_file,130 agent = ManagedMachineAgent(pid_file,
129 zookeeper_hosts=zookeeper.address,131 zookeeper_hosts=zookeeper.address,
130 machine_id="0",132 machine_id="0",
131 juju_directory=self._directory,133 juju_directory=self._directory,
132 log_file=log_file,134 log_file=log_file,
135 juju_origin=juju_origin,
133 juju_unit_namespace=self._qualified_name,136 juju_unit_namespace=self._qualified_name,
134 public_key=public_key)137 public_key=public_key)
135 yield agent.start()138 yield agent.start()
136139
=== modified file 'juju/providers/local/agent.py'
--- juju/providers/local/agent.py 2011-09-27 16:51:50 +0000
+++ juju/providers/local/agent.py 2011-10-04 22:53:25 +0000
@@ -7,6 +7,8 @@
7from twisted.internet.defer import inlineCallbacks, returnValue7from twisted.internet.defer import inlineCallbacks, returnValue
8from twisted.internet.threads import deferToThread8from twisted.internet.threads import deferToThread
99
10from juju.providers.common.cloudinit import get_default_origin
11
1012
11class ManagedMachineAgent(object):13class ManagedMachineAgent(object):
1214
@@ -15,8 +17,7 @@
15 def __init__(17 def __init__(
16 self, pid_file, zookeeper_hosts=None, machine_id="0",18 self, pid_file, zookeeper_hosts=None, machine_id="0",
17 log_file=None, juju_directory="/var/lib/juju",19 log_file=None, juju_directory="/var/lib/juju",
18 juju_unit_namespace="",20 juju_unit_namespace="", public_key=None, juju_origin="ppa"):
19 public_key=None):
20 """21 """
21 :param pid_file: Path to file used to store process id.22 :param pid_file: Path to file used to store process id.
22 :param machine_id: machine id for the local machine.23 :param machine_id: machine id for the local machine.
@@ -37,6 +38,10 @@
37 self._juju_unit_namespace = juju_unit_namespace38 self._juju_unit_namespace = juju_unit_namespace
38 self._log_file = log_file39 self._log_file = log_file
39 self._public_key = public_key40 self._public_key = public_key
41 self._juju_origin = juju_origin
42
43 if self._juju_origin is None:
44 self._juju_origin = get_default_origin()
4045
41 @inlineCallbacks46 @inlineCallbacks
42 def start(self):47 def start(self):
@@ -51,6 +56,7 @@
51 # to the command.56 # to the command.
52 args = ["sudo",57 args = ["sudo",
53 "JUJU_ZOOKEEPER=%s" % self._zookeeper_hosts,58 "JUJU_ZOOKEEPER=%s" % self._zookeeper_hosts,
59 "JUJU_ORIGIN=%s" % self._juju_origin,
54 "JUJU_MACHINE_ID=%s" % self._machine_id,60 "JUJU_MACHINE_ID=%s" % self._machine_id,
55 "JUJU_HOME=%s" % self._juju_directory,61 "JUJU_HOME=%s" % self._juju_directory,
56 "JUJU_UNIT_NS=%s" % self._juju_unit_namespace,62 "JUJU_UNIT_NS=%s" % self._juju_unit_namespace,
@@ -60,7 +66,8 @@
60 "--logfile", self._log_file]66 "--logfile", self._log_file]
6167
62 if self._public_key:68 if self._public_key:
63 args.insert(1, "JUJU_PUBLIC_KEY=%s" % pipes.quote(self._public_key))69 args.insert(
70 1, "JUJU_PUBLIC_KEY=%s" % pipes.quote(self._public_key))
6471
65 yield deferToThread(subprocess.check_call, args)72 yield deferToThread(subprocess.check_call, args)
6673
6774
=== modified file 'juju/providers/local/tests/test_agent.py'
--- juju/providers/local/tests/test_agent.py 2011-09-27 16:51:50 +0000
+++ juju/providers/local/tests/test_agent.py 2011-10-04 22:53:25 +0000
@@ -47,6 +47,7 @@
47 dict(JUJU_ZOOKEEPER=get_test_zookeeper_address(),47 dict(JUJU_ZOOKEEPER=get_test_zookeeper_address(),
48 JUJU_MACHINE_ID="0",48 JUJU_MACHINE_ID="0",
49 JUJU_HOME=juju_directory,49 JUJU_HOME=juju_directory,
50 JUJU_ORIGIN="ppa",
50 JUJU_UNIT_NS="ns1"))51 JUJU_UNIT_NS="ns1"))
5152
52 @inlineCallbacks53 @inlineCallbacks
5354
=== modified file 'juju/unit/address.py'
--- juju/unit/address.py 2011-09-25 06:47:08 +0000
+++ juju/unit/address.py 2011-10-04 22:53:25 +0000
@@ -16,7 +16,7 @@
16 provider_type = yield settings.get_provider_type()16 provider_type = yield settings.get_provider_type()
17 if provider_type == "ec2":17 if provider_type == "ec2":
18 returnValue(EC2UnitAddress())18 returnValue(EC2UnitAddress())
19 elif provider_type == "lxc":19 elif provider_type == "local":
20 returnValue(LocalUnitAddress())20 returnValue(LocalUnitAddress())
21 elif provider_type == "orchestra":21 elif provider_type == "orchestra":
22 returnValue(OrchestraUnitAddress())22 returnValue(OrchestraUnitAddress())
2323
=== modified file 'juju/unit/tests/test_address.py'
--- juju/unit/tests/test_address.py 2011-09-26 17:11:52 +0000
+++ juju/unit/tests/test_address.py 2011-10-04 22:53:25 +0000
@@ -33,7 +33,7 @@
3333
34 @inlineCallbacks34 @inlineCallbacks
35 def test_get_local_address(self):35 def test_get_local_address(self):
36 address = yield self.get_address_for("lxc")36 address = yield self.get_address_for("local")
37 self.assertTrue(isinstance(address, LocalUnitAddress))37 self.assertTrue(isinstance(address, LocalUnitAddress))
3838
39 @inlineCallbacks39 @inlineCallbacks

Subscribers

People subscribed via source and target branches

to status/vote changes: