Merge lp:~jimbaker/pyjuju/juju-status-expose-hint into lp:pyjuju

Proposed by Jim Baker
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 537
Merged at revision: 554
Proposed branch: lp:~jimbaker/pyjuju/juju-status-expose-hint
Merge into: lp:pyjuju
Diff against target: 49 lines (+8/-3)
2 files modified
juju/control/status.py (+5/-1)
juju/control/tests/test_status.py (+3/-2)
To merge this branch: bzr merge lp:~jimbaker/pyjuju/juju-status-expose-hint
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
Review via email: mp+106474@code.launchpad.net

Description of the change

juju status should hint that a service may need to be exposed

Adjust juju status so that exposed: false is output for a service if there are open ports but not exposed

https://codereview.appspot.com/6206086/

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

Reviewers: mp+106474_code.launchpad.net,

Message:
Please take a look.

Description:
juju status should hint that a service may need to be exposed

Adjust juju status so that exposed: false is output for a service if
there are open ports but not exposed

https://code.launchpad.net/~jimbaker/juju/juju-status-expose-hint/+merge/106474

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/6206086/

Affected files:
   A [revision details]
   M juju/control/status.py
   M juju/control/tests/test_status.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision: <email address hidden>

Index: juju/control/status.py
=== modified file 'juju/control/status.py'
--- juju/control/status.py 2012-04-15 23:03:05 +0000
+++ juju/control/status.py 2012-05-18 21:41:15 +0000
@@ -311,10 +311,14 @@
                                 if unit_connected else "down"

          exposed = self.service_data[service.service_name].get("exposed")
+ open_ports = yield unit.get_open_ports()
          if exposed:
- open_ports = yield unit.get_open_ports()
              u["open-ports"] = ["{port}/{proto}".format(**port_info)
                                 for port_info in open_ports]
+ elif open_ports:
+ # Ensure a hint is provided that there are open ports if
+ # not exposed by setting the key in the output
+ self.service_data[service.service_name]["exposed"] = False

          u["public-address"] = yield unit.get_public_address()

Index: juju/control/tests/test_status.py
=== modified file 'juju/control/tests/test_status.py'
--- juju/control/tests/test_status.py 2012-04-09 19:40:57 +0000
+++ juju/control/tests/test_status.py 2012-05-18 21:41:15 +0000
@@ -425,6 +425,7 @@
          self.assertEqual(
              services["wordpress"],
              {"charm": "local:series/wordpress-3",
+ "exposed": False,
               "relations": {
                      "cache": ["memcache"],
                      "db": ["mysql"],
@@ -624,7 +625,7 @@
          self.assertEqual(set(services["varnish"].keys()),
                           set(["exposed", "charm", "relations", "units"]))
          self.assertEqual(set(services["wordpress"].keys()),
- set(["charm", "relations", "units"]))
+ set(["charm", "exposed", "relations", "units"]))

          for service in services.itervalues():
              self.assertGreaterEqual( # may also include "exposed" key
@@ -671,7 +672,7 @@
          self.assertEqual(set(services["varnish"].keys()),
                           set(["exposed", "charm", "relations", "units"]))
          self.assertEqual(set(services["wordpress"].keys()),
- set(["charm", "relations", "units"]))
+ set(["charm", "exposed", "relations", "units"]))

          for service in services.itervalues():
              self.assertTrue...

Read more...

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

This seems like a change in behavior, even though its a positive one, I think it should be delayed until honolulu.

Revision history for this message
Jim Baker (jimbaker) wrote :

Delaying to honolulu is reasonable.

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

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'juju/control/status.py'
2--- juju/control/status.py 2012-04-15 23:03:05 +0000
3+++ juju/control/status.py 2012-05-18 21:46:18 +0000
4@@ -311,10 +311,14 @@
5 if unit_connected else "down"
6
7 exposed = self.service_data[service.service_name].get("exposed")
8+ open_ports = yield unit.get_open_ports()
9 if exposed:
10- open_ports = yield unit.get_open_ports()
11 u["open-ports"] = ["{port}/{proto}".format(**port_info)
12 for port_info in open_ports]
13+ elif open_ports:
14+ # Ensure a hint is provided that there are open ports if
15+ # not exposed by setting the key in the output
16+ self.service_data[service.service_name]["exposed"] = False
17
18 u["public-address"] = yield unit.get_public_address()
19
20
21=== modified file 'juju/control/tests/test_status.py'
22--- juju/control/tests/test_status.py 2012-04-09 19:40:57 +0000
23+++ juju/control/tests/test_status.py 2012-05-18 21:46:18 +0000
24@@ -425,6 +425,7 @@
25 self.assertEqual(
26 services["wordpress"],
27 {"charm": "local:series/wordpress-3",
28+ "exposed": False,
29 "relations": {
30 "cache": ["memcache"],
31 "db": ["mysql"],
32@@ -624,7 +625,7 @@
33 self.assertEqual(set(services["varnish"].keys()),
34 set(["exposed", "charm", "relations", "units"]))
35 self.assertEqual(set(services["wordpress"].keys()),
36- set(["charm", "relations", "units"]))
37+ set(["charm", "exposed", "relations", "units"]))
38
39 for service in services.itervalues():
40 self.assertGreaterEqual( # may also include "exposed" key
41@@ -671,7 +672,7 @@
42 self.assertEqual(set(services["varnish"].keys()),
43 set(["exposed", "charm", "relations", "units"]))
44 self.assertEqual(set(services["wordpress"].keys()),
45- set(["charm", "relations", "units"]))
46+ set(["charm", "exposed", "relations", "units"]))
47
48 for service in services.itervalues():
49 self.assertTrue(service["charm"].startswith("local:series/"))

Subscribers

People subscribed via source and target branches

to status/vote changes: