Merge lp:~hazmat/pyjuju/local-machine into lp:pyjuju

Proposed by Kapil Thangavelu
Status: Merged
Approved by: Benjamin Saller
Approved revision: 347
Merged at revision: 348
Proposed branch: lp:~hazmat/pyjuju/local-machine
Merge into: lp:pyjuju
Prerequisite: lp:~hazmat/pyjuju/lib-files
Diff against target: 58 lines (+25/-1)
5 files modified
ensemble/lib/zk.py (+1/-1)
ensemble/providers/lxc/__init__.py (+1/-0)
ensemble/providers/lxc/machine.py (+10/-0)
ensemble/providers/lxc/tests/__init__.py (+1/-0)
ensemble/providers/lxc/tests/test_machine.py (+12/-0)
To merge this branch: bzr merge lp:~hazmat/pyjuju/local-machine
Reviewer Review Type Date Requested Status
Benjamin Saller (community) Approve
Gustavo Niemeyer Approve
William Reade (community) Needs Information
Review via email: mp+73617@code.launchpad.net

Description of the change

implementation of local provider machine.

To post a comment you must log in.
lp:~hazmat/pyjuju/local-machine updated
341. By Kapil Thangavelu

Merged lib-files into local-machine.

342. By Kapil Thangavelu

Merged lib-files into local-machine.

343. By Kapil Thangavelu

Merged lib-files into local-machine.

Revision history for this message
William Reade (fwereade) wrote :

[0]

Is anything using launch_time? We removed it from the EC2 machines because nothing was using it (the only use was in ZookeeperConnect, and niemeyer opined it was costing more complexity than it was worth: https://code.launchpad.net/~fwereade/ensemble/cobbler-zk-connect/+merge/71734).

[1]

Please add a test for .private_dns_name (it needs to exist for us to generate the zookeeper hosts)

[2]

...finally I guess I'm a bit confused about the hostname anyway. Will "localhost" resolve to the right place, even from within a container? If so, fine (but, eww!); if not, surely we should have something that does resolve to the right place?

I don't feel it's quite approvable as-is, but ping me to discuss.

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

Nice little change. +1 with a couple of trivials.

[1]

+ uptime_seconds = float(open(self.uptime_file).read().split(" ")[0])

The file should be closed explicitly (or via with..).

[2]

+ uptime_file = "/proc/uptime"

Private?

review: Approve
lp:~hazmat/pyjuju/local-machine updated
344. By Kapil Thangavelu

Merged lib-files into local-machine.

345. By Kapil Thangavelu

Merged lib-files into local-machine.

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

> [0]
>
> Is anything using launch_time? We removed it from the EC2 machines because
> nothing was using it (the only use was in ZookeeperConnect, and niemeyer
> opined it was costing more complexity than it was worth:
> https://code.launchpad.net/~fwereade/ensemble/cobbler-zk-
> connect/+merge/71734).

thanks, that's good to know.

>
> [1]
>
> Please add a test for .private_dns_name (it needs to exist for us to generate
> the zookeeper hosts)
>

it would be if local-dev was using that pathway.. easy to add in though, but it would be unused.

> [2]
>
> ...finally I guess I'm a bit confused about the hostname anyway. Will
> "localhost" resolve to the right place, even from within a container? If so,
> fine (but, eww!); if not, surely we should have something that does resolve to
> the right place?
>
> I don't feel it's quite approvable as-is, but ping me to discuss.

the containers don't use this to resolve to the host, this is soley to satisfy existing constraint notions of machine usage and assignment.

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

> Nice little change. +1 with a couple of trivials.
>
> [1]
>
> + uptime_seconds = float(open(self.uptime_file).read().split(" ")[0])
>
> The file should be closed explicitly (or via with..).
>
> [2]
>
>
> + uptime_file = "/proc/uptime"
>
> Private?

it was public there for easy testing manipulation, but that's going away since uptime isn't needed anymore.

lp:~hazmat/pyjuju/local-machine updated
346. By Kapil Thangavelu

Merged lib-files into local-machine.

347. By Kapil Thangavelu

simplify local machine, there is uptime spoon

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

LGTM +1

review: Approve
lp:~hazmat/pyjuju/local-machine updated
348. By Kapil Thangavelu

rip out vestige of old instance var name on zk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ensemble/lib/zk.py'
2--- ensemble/lib/zk.py 2011-09-13 23:07:31 +0000
3+++ ensemble/lib/zk.py 2011-09-14 22:23:28 +0000
4@@ -159,7 +159,7 @@
5 if not class_path:
6 raise RuntimeError(
7 "Zookeeper libraries not found in location %s." % (
8- self._software_dir))
9+ self._zk_location))
10 # Add the managed dir containing log4j properties, which are retrieved
11 # along classpath.
12 class_path.insert(0, self._run_dir)
13
14=== added directory 'ensemble/providers/lxc'
15=== added file 'ensemble/providers/lxc/__init__.py'
16--- ensemble/providers/lxc/__init__.py 1970-01-01 00:00:00 +0000
17+++ ensemble/providers/lxc/__init__.py 2011-09-14 22:23:28 +0000
18@@ -0,0 +1,1 @@
19+#
20
21=== added file 'ensemble/providers/lxc/machine.py'
22--- ensemble/providers/lxc/machine.py 1970-01-01 00:00:00 +0000
23+++ ensemble/providers/lxc/machine.py 2011-09-14 22:23:28 +0000
24@@ -0,0 +1,10 @@
25+from ensemble.machine import ProviderMachine
26+
27+
28+class LocalMachine(ProviderMachine):
29+ """Represents host machine, when doing local development.
30+ """
31+
32+ def __init__(self):
33+ self.instance_id = "local"
34+ self.private_dns_name = self.dns_name = "localhost"
35
36=== added directory 'ensemble/providers/lxc/tests'
37=== added file 'ensemble/providers/lxc/tests/__init__.py'
38--- ensemble/providers/lxc/tests/__init__.py 1970-01-01 00:00:00 +0000
39+++ ensemble/providers/lxc/tests/__init__.py 2011-09-14 22:23:28 +0000
40@@ -0,0 +1,1 @@
41+#
42
43=== added file 'ensemble/providers/lxc/tests/test_machine.py'
44--- ensemble/providers/lxc/tests/test_machine.py 1970-01-01 00:00:00 +0000
45+++ ensemble/providers/lxc/tests/test_machine.py 2011-09-14 22:23:28 +0000
46@@ -0,0 +1,12 @@
47+from ensemble.providers.lxc.machine import LocalMachine
48+from ensemble.lib.testing import TestCase
49+
50+
51+class LocalMachineTest(TestCase):
52+
53+ def test_machine_attributes(self):
54+
55+ machine = LocalMachine()
56+ self.assertEqual(machine.instance_id, "local")
57+ self.assertEqual(machine.dns_name, "localhost")
58+ self.assertEqual(machine.private_dns_name, "localhost")

Subscribers

People subscribed via source and target branches

to status/vote changes: